Kristofer Jonsson | 3f5510f | 2023-02-08 14:23:00 +0100 | [diff] [blame] | 1 | # |
Mikael Olsson | 34b190b | 2024-02-12 13:14:18 +0100 | [diff] [blame] | 2 | # SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its affiliates <open-source-office@arm.com> |
Kristofer Jonsson | 3f5510f | 2023-02-08 14:23:00 +0100 | [diff] [blame] | 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the License); you may |
| 6 | # not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an AS IS BASIS, WITHOUT |
| 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | |
| 18 | if(NOT TARGET freertos_kernel) |
| 19 | message("Skipping message handler openamp") |
| 20 | return() |
| 21 | endif() |
| 22 | |
| 23 | ############################################################################# |
| 24 | # Configuration |
| 25 | ############################################################################# |
| 26 | |
| 27 | set(MESSAGE_HANDLER_MODEL_0 "" CACHE STRING "Path to built in model 0") |
| 28 | set(MESSAGE_HANDLER_MODEL_1 "" CACHE STRING "Path to built in model 1") |
| 29 | set(MESSAGE_HANDLER_MODEL_2 "" CACHE STRING "Path to built in model 2") |
| 30 | set(MESSAGE_HANDLER_MODEL_3 "" CACHE STRING "Path to built in model 3") |
| 31 | |
Mikael Olsson | 10ecba8 | 2024-03-21 14:07:54 +0100 | [diff] [blame] | 32 | set(MESSAGE_HANDLER_ARENA_SIZE 0x200000 CACHE STRING "Total size of all message handler tensor arenas in bytes (Must be a power of two)") |
Kristofer Jonsson | 3f5510f | 2023-02-08 14:23:00 +0100 | [diff] [blame] | 33 | |
| 34 | ############################################################################# |
| 35 | # TFLM arena |
| 36 | ############################################################################# |
| 37 | |
| 38 | # Split total tensor arena equally for each NPU |
| 39 | if(TARGET ethosu_core_driver AND ETHOSU_TARGET_NPU_COUNT GREATER 0) |
| 40 | set(NUM_ARENAS ${ETHOSU_TARGET_NPU_COUNT}) |
| 41 | else() |
| 42 | set(NUM_ARENAS 1) |
| 43 | endif() |
| 44 | |
| 45 | math(EXPR TENSOR_ARENA_SIZE "${MESSAGE_HANDLER_ARENA_SIZE} / ${NUM_ARENAS}") |
| 46 | |
| 47 | ############################################################################# |
| 48 | # Message handler application |
| 49 | ############################################################################# |
| 50 | |
| 51 | ethosu_add_executable(message_handler_openamp |
| 52 | SOURCES |
| 53 | main.cpp |
| 54 | core_driver_mutex.cpp |
| 55 | freertos_allocator.cpp |
| 56 | inference_runner.cpp |
| 57 | message_handler.cpp |
| 58 | remoteproc.cpp |
| 59 | LIBRARIES |
| 60 | $<$<TARGET_EXISTS:ethosu_core_driver>:ethosu_core_driver> |
| 61 | ethosu_log |
| 62 | ethosu_mailbox |
Mikael Olsson | 918cd90 | 2023-12-13 09:57:42 +0100 | [diff] [blame] | 63 | ethosu_profiler |
Kristofer Jonsson | 3f5510f | 2023-02-08 14:23:00 +0100 | [diff] [blame] | 64 | freertos_kernel |
| 65 | inference_process |
| 66 | openamp-freertos) |
| 67 | |
| 68 | target_include_directories(message_handler_openamp PRIVATE |
Mikael Olsson | 34b190b | 2024-02-12 13:14:18 +0100 | [diff] [blame] | 69 | ${LINUX_DRIVER_STACK_PATH}/kernel/include) |
Kristofer Jonsson | 3f5510f | 2023-02-08 14:23:00 +0100 | [diff] [blame] | 70 | |
| 71 | target_compile_definitions(message_handler_openamp PRIVATE |
Ledion Daja | b00e4ed | 2023-05-22 10:45:31 +0200 | [diff] [blame] | 72 | $<$<BOOL:${ENABLE_REMOTEPROC_TRACE_BUFFER}>:REMOTEPROC_TRACE_BUFFER> |
Kristofer Jonsson | 3f5510f | 2023-02-08 14:23:00 +0100 | [diff] [blame] | 73 | TENSOR_ARENA_SIZE=${TENSOR_ARENA_SIZE} |
| 74 | $<$<BOOL:${MESSAGE_HANDLER_MODEL_0}>:MODEL_0=${MESSAGE_HANDLER_MODEL_0}> |
| 75 | $<$<BOOL:${MESSAGE_HANDLER_MODEL_1}>:MODEL_1=${MESSAGE_HANDLER_MODEL_1}> |
| 76 | $<$<BOOL:${MESSAGE_HANDLER_MODEL_2}>:MODEL_2=${MESSAGE_HANDLER_MODEL_2}> |
| 77 | $<$<BOOL:${MESSAGE_HANDLER_MODEL_3}>:MODEL_3=${MESSAGE_HANDLER_MODEL_3}>) |