From f7edeb7fcbb6fcb67c2711db16386c03d6f29d9d Mon Sep 17 00:00:00 2001 From: Kristofer Jonsson Date: Mon, 17 Jan 2022 09:40:09 +0100 Subject: Build system updates Move finding Python after the project command. This was causing incremental CMake configurations to fail. Moving ETHOSU_TARGET_* variables after adding the common subdirectory. It is necessary to set the variables before the core driver is included. Change-Id: I1c6883061cb9247336f8b33d82d2e2de870634fa --- applications/trustzone_inference/CMakeLists.txt | 4 +- scripts/run_ctest.py | 15 ++++-- targets/corstone-300/CMakeLists.txt | 72 +++++++++++-------------- 3 files changed, 44 insertions(+), 47 deletions(-) diff --git a/applications/trustzone_inference/CMakeLists.txt b/applications/trustzone_inference/CMakeLists.txt index a985437..5a99129 100644 --- a/applications/trustzone_inference/CMakeLists.txt +++ b/applications/trustzone_inference/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2021 Arm Limited. All rights reserved. +# Copyright (c) 2021-2022 Arm Limited. All rights reserved. # # SPDX-License-Identifier: Apache-2.0 # @@ -16,7 +16,7 @@ # limitations under the License. # -if (NOT ${ETHOSU_TARGET} STREQUAL "corstone-300" OR NOT TARGET ethosu_core_driver) +if (NOT ${ETHOSU_TARGET} STREQUAL "corstone-300" OR NOT TARGET ethosu_core_driver OR NOT ETHOSU_TARGET_NPU_CONFIG STREQUAL "ethos-u55-128") return() endif() diff --git a/scripts/run_ctest.py b/scripts/run_ctest.py index c72d0f7..3e7abfc 100755 --- a/scripts/run_ctest.py +++ b/scripts/run_ctest.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -# Copyright (c) 2021 Arm Limited. All rights reserved. +# Copyright (c) 2021-2022 Arm Limited. All rights reserved. # # SPDX-License-Identifier: Apache-2.0 # @@ -45,15 +45,22 @@ def check_output(args, **kwargs): return subprocess.check_output(args, **kwargs) def run_corstone_300(args): + if not args.arch or args.arch == 'ethos-u55': + fvp = 'FVP_Corstone_SSE-300_Ethos-U55' + elif args.arch == 'ethos-u65': + fvp = 'FVP_Corstone_SSE-300_Ethos-U65' + else: + raise 'Unsupported NPU arch' + # Verify supported FVP version - version = subprocess.check_output(['FVP_Corstone_SSE-300_Ethos-U55', '--version']).decode() + version = subprocess.check_output([fvp, '--version']).decode() supported_version = ['11.13', '11.14', '11.15', '11.16'] if not [s for s in supported_version if s in version]: raise Exception("Incorrect FVP version. Supported versions are '{}'.".format(supported_version)) # FVP executable - cmd = ['FVP_Corstone_SSE-300_Ethos-U55'] + cmd = [fvp] # NPU configuration cmd += ['-C', 'ethosu.num_macs=' + str(args.macs)] @@ -86,7 +93,7 @@ def run_corstone_300(args): if __name__ == '__main__': parser = argparse.ArgumentParser(description='Run a test with given test command and test binary.') parser.add_argument('-t', '--target', choices=['corstone-300'], required=True, help='FVP target.') - parser.add_argument('-a', '--arch', choices=['ethos-u55'], default='ethos-u55', help='NPU architecture.') + parser.add_argument('-a', '--arch', choices=['ethos-u55', 'ethos-u65'], help='NPU architecture.') parser.add_argument('-m', '--macs', type=int, choices=[32, 64, 128, 256], default=128, help='NPU number of MACs.') parser.add_argument('args', nargs='+', help='Arguments.') args = parser.parse_args() diff --git a/targets/corstone-300/CMakeLists.txt b/targets/corstone-300/CMakeLists.txt index 5742cb1..3a6f291 100644 --- a/targets/corstone-300/CMakeLists.txt +++ b/targets/corstone-300/CMakeLists.txt @@ -26,10 +26,17 @@ if (NOT CMAKE_TOOLCHAIN_FILE) set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/toolchain/armclang.cmake") endif() -set(Python3_FIND_STRATEGY LOCATION) -find_package(Python3 COMPONENTS Interpreter) +set(ETHOSU_TARGET_NPU_CONFIG "ethos-u55-128" CACHE STRING "NPU configuration") +set(ETHOSU_TARGET_NPU_COUNT 1 CACHE INTERNAL "Number of NPUs") +set(ETHOSU_TARGET_NPU_TA_COUNT 2 CACHE INTERNAL "Number of timing adapters per NPU") -set(ETHOSU_COMMAND_DEFAULT ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/run_ctest.py -t corstone-300 CACHE INTERNAL "Default test command") +set(ETHOSU_PMU_EVENT_0 -1 CACHE STRING "PMU Event #0") +set(ETHOSU_PMU_EVENT_1 -1 CACHE STRING "PMU Event #1") +set(ETHOSU_PMU_EVENT_2 -1 CACHE STRING "PMU Event #2") +set(ETHOSU_PMU_EVENT_3 -1 CACHE STRING "PMU Event #3") + +set(MEMORY_MODEL "dram" CACHE STRING "Memory config for model") +set(MEMORY_ARENA "dram" CACHE STRING "Memory config for arena") ############################################################################# # Project @@ -39,8 +46,6 @@ cmake_minimum_required(VERSION 3.21) project(ethos-u-corstone-300 VERSION 0.0.1) -include(CTest) - include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/helpers.cmake) ############################################################################# @@ -50,52 +55,37 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/helpers.cmake) get_filename_component(ETHOSU_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME) message("Configuring target ${ETHOSU_TARGET}") +# Enable CTest +include(CTest) +set(Python3_FIND_STRATEGY LOCATION) +find_package(Python3 COMPONENTS Interpreter) +ethosu_get_architecture(${ETHOSU_TARGET_NPU_CONFIG}) +set(ETHOSU_COMMAND_DEFAULT ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/run_ctest.py + -t corstone-300 + -a ethos-${ETHOSU_ARCH} + -m ${ETHOSU_NUM_MACS} + CACHE INTERNAL "Default test command") + # Enable trustzone support in core_software set(TRUSTZONE_BUILD ON) +# Include common targets add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../common target) -set(ETHOSU_TARGET_NPU_CONFIG "ethos-u55-128" CACHE STRING "NPU configuration") -set(ETHOSU_TARGET_NPU_COUNT 1 CACHE INTERNAL "Number of NPUs") -set(ETHOSU_TARGET_NPU_TA_COUNT 2 CACHE INTERNAL "Number of timing adapters per NPU") - -set(ETHOSU_PMU_EVENT_0 -1 CACHE STRING "PMU Event #0") -set(ETHOSU_PMU_EVENT_1 -1 CACHE STRING "PMU Event #1") -set(ETHOSU_PMU_EVENT_2 -1 CACHE STRING "PMU Event #2") -set(ETHOSU_PMU_EVENT_3 -1 CACHE STRING "PMU Event #3") - target_compile_definitions(ethosu_target_common INTERFACE + # Confiugure NPU architecture and number of timing adapters + ETHOSU_NPU_COUNT=${ETHOSU_TARGET_NPU_COUNT} + ETHOSU_NPU_TA_COUNT=${ETHOSU_TARGET_NPU_TA_COUNT} + + # Configure PMU events ETHOSU_PMU_EVENT_0=${ETHOSU_PMU_EVENT_0} ETHOSU_PMU_EVENT_1=${ETHOSU_PMU_EVENT_1} ETHOSU_PMU_EVENT_2=${ETHOSU_PMU_EVENT_2} - ETHOSU_PMU_EVENT_3=${ETHOSU_PMU_EVENT_3}) + ETHOSU_PMU_EVENT_3=${ETHOSU_PMU_EVENT_3} -set(MEMORY_MODEL "dram" CACHE STRING "Memory config for model") -set(MEMORY_ARENA "dram" CACHE STRING "Memory config for arena") - -target_compile_definitions(ethosu_target_common INTERFACE - ETHOSU_NPU_TA_COUNT=${ETHOSU_TARGET_NPU_TA_COUNT} - ETHOSU_NPU_COUNT=${ETHOSU_TARGET_NPU_COUNT}) - -# Model memory configuration -# For ETHOSU_MODEL: 0 - SRAM, 1 - DRAM -if (MEMORY_MODEL STREQUAL "dram") - target_compile_definitions(ethosu_target_common INTERFACE - ETHOSU_MODEL=1) -else() - target_compile_definitions(ethosu_target_common INTERFACE - ETHOSU_MODEL=0) -endif() - -# Arena memory configuration -# For ETHOSU_ARENA: 0 - SRAM, 1 - DRAM -if (MEMORY_ARENA STREQUAL "dram") - target_compile_definitions(ethosu_target_common INTERFACE - ETHOSU_ARENA=1) -else() - target_compile_definitions(ethosu_target_common INTERFACE - ETHOSU_ARENA=0) -endif() + # Placement or TLFu model and area. 0 = SRAM, 1 = DRAM + ETHOSU_MODEL=$ + ETHOSU_ARENA=$) # AXI Timing adaptors set(registers MAXR MAXW MAXRW RLATENCY WLATENCY PULSE_ON PULSE_OFF BWCAP PERFCTRL PERFCNT MODE HISTBIN HISTCNT) -- cgit v1.2.1