From a739d21efeb9a5e79bc3454c4badad6477235969 Mon Sep 17 00:00:00 2001 From: Kristofer Jonsson Date: Thu, 5 May 2022 12:11:52 +0200 Subject: Update documentation Add documentation about how base addresses are used by the driver unit tests. Update message handler application to use TENSOR_ARENA_SIZE the same way as the FreeRTOS application. Add documenation about Corstone-310. Change-Id: I08a315b95ca757ce3449cb7af104b8f1ac7f8865 --- README.md | 21 +++++- applications/driver_unit_tests/conv.cpp | 109 ++++++++-------------------- applications/message_handler/CMakeLists.txt | 13 +++- applications/message_handler/main.cpp | 4 +- 4 files changed, 63 insertions(+), 84 deletions(-) diff --git a/README.md b/README.md index 2c02a81..1efefec 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ $ cmake --build build It is also possible to build with a different toolchain. ``` -$ cmake -B build targets/corstone-300 -DCMAKE_TOOLCHAIN_FILE=$PWD/cmake/toolchain/arm-none-eabi-gcc.cmake +$ cmake -B build targets/corstone-300 --toolchain $PWD/cmake/toolchain/arm-none-eabi-gcc.cmake $ cmake --build build ``` @@ -62,7 +62,7 @@ $ cmake --build build Building on a Windows host requires no special tools or shells, and can for example be done from a CMD prompt, Git Bash or from the CMake GUI. Only -requirment is the build tools have been added to the path variable. +requirement is the build tools have been added to the path variable. CMake supports a long list of generators, for example Ninja, NMake or Makefiles. For Windows Ninja has been verified to work well, but any of the supported @@ -129,6 +129,23 @@ Same as above but for Ethos-U65 FVP. $ FVP_Corstone_SSE-300_Ethos-U65 -C ethosu.num_macs=512 applications/freertos/freertos.elf ``` +## Corstone-310 FVP + +Applications for the Corstone-310 FVP are built and tested similarly to the +Corstone-300. + +``` +$ cmake -B build targets/corstone-310 +$ cmake --build build +``` + +Assuming the `FVP_Corstone_SSE-310` executable can be found via the PATH +variable, the unit tests can be executed with `ctest`. + +``` +$ ctest --test-dir build +``` + ## Corstone-300 MPS3 FPGA The files needed to get started for Corstone-300 can be found on diff --git a/applications/driver_unit_tests/conv.cpp b/applications/driver_unit_tests/conv.cpp index 63515fa..9e3dcc9 100644 --- a/applications/driver_unit_tests/conv.cpp +++ b/applications/driver_unit_tests/conv.cpp @@ -102,7 +102,7 @@ __attribute__((section(".sram.data"), aligned(16))) char commandStream[] = { 0x00, 0x00, 0xff, 0xff, // cmd0.NPU_OP_STOP 65535 - }; // clang-format on -__attribute__((section(".sram.data"), aligned(16))) char weightsBiases0[] = { +__attribute__((section(".sram.data"), aligned(16))) char tflmModel[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0xa4, 0x7b, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0xa4, 0x7b, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x5c, 0xe6, 0x4d, 0xf9, 0xef, 0x6f, 0xcf, @@ -111,74 +111,7 @@ __attribute__((section(".sram.data"), aligned(16))) char weightsBiases0[] = { 0x4f, 0xbb, 0x39, 0x01, 0x08, 0x9e, 0x96, 0x87, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x4c, 0x35, 0x30, 0x89, 0x1d, 0x00, 0xe0, 0xfc, 0xff, 0xbf, 0x1f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; -__attribute__((section(".sram.data"), aligned(16))) char scratch[] = { - 0xac, 0x0a, 0x7f, 0x8c, 0x2f, 0xaa, 0xc4, 0x97, 0x75, 0xa6, 0x16, 0xb7, 0xc0, 0xcc, 0x21, 0xd8, 0x43, 0xb3, 0x4e, - 0x9a, 0xfb, 0x52, 0xa2, 0xdb, 0xc3, 0x76, 0x7d, 0x8b, 0x67, 0x7d, 0xe5, 0xd8, 0x09, 0xa4, 0x74, 0x6c, 0xd3, 0xde, - 0xa1, 0x9f, 0x15, 0x51, 0x59, 0xa5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 0x60, 0x40, 0xbd, 0x7f, 0xe9, 0x1d, 0x05, 0x00, 0x36, 0x08, 0x0a, 0x8a, 0xf7, 0x13, 0x71, - 0x72, 0x09, 0x66, 0x48, 0x2b, 0x32, 0xc6, 0xfa, 0xba, 0x33, 0xc5, 0x1e, 0x7f, 0x8d, 0x04, 0x5c, 0x17, 0xd8, 0xcf, - 0x4b, 0xbb, 0xd6, 0x1b, 0x7b, 0x82, 0xf0, 0x64, 0x1e, 0x79, 0x19, 0x4c, 0xb0, 0x62, 0x58, 0x67, 0x51, 0x3e, 0xde, - 0x66, 0xe1, 0xa3, 0x23, 0x0d, 0x6a, 0xde, 0x7a, 0x11, 0xeb, 0x7b, 0xf8, 0x6b, 0x10, 0xc3, 0xa7, 0x81, 0x37, 0x52, - 0xda, 0x45, 0xb1, 0xae, 0x37, 0xb0, 0x90, 0xe3, 0xca, 0x0c, 0x91, 0x94, 0x5c, 0x77, 0xdd, 0xd1, 0x90, 0xf0, 0x43, - 0x32, 0xca, 0x4b, 0x82, 0x9b, 0x95, 0xf3, 0x85, 0x0e, 0x5b, 0xae, 0xea, 0x29, 0x7c, 0x0c, 0x18, 0x3a, 0xfc, 0xd0, - 0xeb, 0xc1, 0x3a, 0x71, 0x93, 0x24, 0xdc, 0x46, 0x15, 0x0a, 0x5b, 0xe6, 0xed, 0x56, 0x90, 0x18, 0x47, 0x2b, 0xbc, - 0x8d, 0x51, 0x68, 0x33, 0x65, 0x02, 0x0b, 0x68, 0xdb, 0xaa, 0x02, 0xbb, 0xa3, 0xd7, 0x33, 0x81, 0xbd, 0x21, 0x50, - 0x34, 0xad, 0xa5, 0x20, 0x38, 0x61, 0xb7, 0xb6, 0x14, 0x65, 0xd7, 0x80, 0x84, 0x16, 0x4a, 0x26, 0x5b, 0xc5, 0x43, - 0x13, 0xa1, 0xe5, 0x2e, 0xae, 0x94, 0xd7, 0x65, 0x2a, 0xb6, 0x25, 0x96, 0x73, 0xb5, 0x85, 0x8d, 0xb8, 0xc4,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0x43, 0xaa, 0xb9, 0x79, 0x07, 0xe0, 0xa8, 0x76, - 0xcb, 0x56, 0x80, 0x75, 0x34, 0x80, 0x88, 0xbd, 0xe5, 0xc1, 0xf4, 0x53, 0x36, 0x04, 0x3b, 0xa1, 0x8a, 0xdc, 0xa4, - 0x68, 0x27, 0x16, 0x65, 0xa0, 0xc3, 0x81, 0x6c, 0xe4, 0x3c, 0x6a, 0x9e, 0xfb, 0x95, 0x3c, 0x9b, 0xfb, 0xea, 0x90, - 0x79, 0x79, 0xd8, 0xe9, 0x04, 0x46, 0x95, 0x5a, 0x78, 0xd5, 0x01, 0x34, 0x4d, 0x1f, 0xa9, 0x50, 0xb7, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -__attribute__((section(".sram.data"), aligned(16))) char fastScratch[] = { +__attribute__((section(".sram.data"), aligned(16))) char tflmArena[] = { 0xac, 0x0a, 0x7f, 0x8c, 0x2f, 0xaa, 0xc4, 0x97, 0x75, 0xa6, 0x16, 0xb7, 0xc0, 0xcc, 0x21, 0xd8, 0x43, 0xb3, 0x4e, 0x9a, 0xfb, 0x52, 0xa2, 0xdb, 0xc3, 0x76, 0x7d, 0x8b, 0x67, 0x7d, 0xe5, 0xd8, 0x09, 0xa4, 0x74, 0x6c, 0xd3, 0xde, 0xa1, 0x9f, 0x15, 0x51, 0x59, 0xa5, 0xf2, 0xd6, 0x66, 0x62, 0x24, 0xb7, 0x05, 0x70, 0x57, 0x3a, 0x2b, 0x4c, 0x46, @@ -315,22 +248,42 @@ char expected0[] = {0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, ****************************************************************************/ int main() { - CommandStream cs(DataPointer(commandStream, sizeof(commandStream)), - BasePointers({DataPointer(weightsBiases0, sizeof(weightsBiases0)), - DataPointer(scratch, sizeof(scratch)), - DataPointer(fastScratch, sizeof(fastScratch))}), - PmuEvents({ETHOSU_PMU_CYCLE, ETHOSU_PMU_NPU_IDLE, ETHOSU_PMU_NPU_ACTIVE})); + /* + * The command stream compiled by Vela only uses two base addresses (for a + * network without fast scratch). + * + * The first base address points at the TFLM model. This buffer contains + * constant data, like the command stream, weights and biases. + * + * The second base address points at the TFLM arena. This buffer contains + * variable data, like the IFM, OFM, activations etc. + * + * NOTE! Really important to understand is that the command stream will + * access the IFM and OFM buffers using the second base address only. + * Consequently the input- and output pointers below are referring to an + * offset within the TFLM arena. + * + * NOTE! The offsets of the IFM and OFM buffers within the TFLM arena + * varies between models. They can be found comparing input tensor 4 and + * output tensor 0 with the address of the TFLM arena. + * + * The remaining base addresses are unused. + */ + CommandStream cs( + DataPointer(commandStream, sizeof(commandStream)), + BasePointers({DataPointer(tflmModel, sizeof(tflmModel)), DataPointer(tflmArena, sizeof(tflmArena))}), + PmuEvents({ETHOSU_PMU_CYCLE, ETHOSU_PMU_NPU_IDLE, ETHOSU_PMU_NPU_ACTIVE})); const size_t repeat = 100; uint64_t cycleCount = 0; int errors = 0; int res; - // Input data located inside the scratch buffer - DataPointer inputPointer(scratch, sizeof(input0)); + // Input data located inside the arena + DataPointer inputPointer(tflmArena, sizeof(input0)); - // Output data located inside the scratch buffer - DataPointer outputPointer(scratch + 1024, sizeof(expected0)); + // Output data located inside the arena + DataPointer outputPointer(tflmArena + 1024, sizeof(expected0)); // Expected output data DataPointer expectedPointer(expected0, sizeof(expected0)); diff --git a/applications/message_handler/CMakeLists.txt b/applications/message_handler/CMakeLists.txt index 3f87e64..040b27d 100644 --- a/applications/message_handler/CMakeLists.txt +++ b/applications/message_handler/CMakeLists.txt @@ -21,7 +21,7 @@ if (NOT TARGET freertos_kernel) return() endif() -set(MESSAGE_HANDLER_ARENA_SIZE 2000000 CACHE STRING "Size of message handler tensor arena") +set(MESSAGE_HANDLER_ARENA_SIZE 2000000 CACHE STRING "Total size of all message handler tensor arenas") set(MESSAGE_HANDLER_MODEL_0 FALSE CACHE STRING "Path to built in model 0") set(MESSAGE_HANDLER_MODEL_1 FALSE CACHE STRING "Path to built in model 1") set(MESSAGE_HANDLER_MODEL_2 FALSE CACHE STRING "Path to built in model 2") @@ -42,8 +42,17 @@ ethosu_add_executable(message_handler target_include_directories(message_handler PRIVATE ${LINUX_DRIVER_STACK_PATH}/kernel) +# Split total tensor arena equally for each NPU +if (TARGET ethosu_core_driver AND ETHOSU_TARGET_NPU_COUNT GREATER 0) + set(NUM_ARENAS ${ETHOSU_TARGET_NPU_COUNT}) +else() + set(NUM_ARENAS 1) +endif() + +math(EXPR TENSOR_ARENA_SIZE "${MESSAGE_HANDLER_ARENA_SIZE} / ${NUM_ARENAS}") + target_compile_definitions(message_handler PRIVATE - TENSOR_ARENA_SIZE=${MESSAGE_HANDLER_ARENA_SIZE} + TENSOR_ARENA_SIZE=${TENSOR_ARENA_SIZE} $<$:MODEL_0=${MESSAGE_HANDLER_MODEL_0}> $<$:MODEL_1=${MESSAGE_HANDLER_MODEL_1}> $<$:MODEL_2=${MESSAGE_HANDLER_MODEL_2}> diff --git a/applications/message_handler/main.cpp b/applications/message_handler/main.cpp index b527840..8db9e0b 100644 --- a/applications/message_handler/main.cpp +++ b/applications/message_handler/main.cpp @@ -52,14 +52,14 @@ using namespace MessageHandler; ****************************************************************************/ // Nr. of tasks to process inferences with, reserves driver & runs inference (Normally 1 per NPU, but not a must) -#if defined(ETHOSU_NPU_COUNT) +#if defined(ETHOSU) && defined(ETHOSU_NPU_COUNT) && ETHOSU_NPU_COUNT > 0 constexpr size_t NUM_PARALLEL_TASKS = ETHOSU_NPU_COUNT; #else constexpr size_t NUM_PARALLEL_TASKS = 1; #endif // TensorArena static initialisation -constexpr size_t arenaSize = TENSOR_ARENA_SIZE / NUM_PARALLEL_TASKS; +constexpr size_t arenaSize = TENSOR_ARENA_SIZE; __attribute__((section(".bss.tensor_arena"), aligned(16))) uint8_t tensorArena[NUM_PARALLEL_TASKS][arenaSize]; -- cgit v1.2.1