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