blob: 3a36c8d8274704f15d5facb039e0fdcfcdbecf1b [file] [log] [blame]
Kristofer Jonsson3f5510f2023-02-08 14:23:00 +01001#
Mikael Olsson34b190b2024-02-12 13:14:18 +01002# SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
Kristofer Jonsson3f5510f2023-02-08 14:23:00 +01003# 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
18if(NOT TARGET freertos_kernel)
19 message("Skipping message handler openamp")
20 return()
21endif()
22
23#############################################################################
24# Configuration
25#############################################################################
26
27set(MESSAGE_HANDLER_MODEL_0 "" CACHE STRING "Path to built in model 0")
28set(MESSAGE_HANDLER_MODEL_1 "" CACHE STRING "Path to built in model 1")
29set(MESSAGE_HANDLER_MODEL_2 "" CACHE STRING "Path to built in model 2")
30set(MESSAGE_HANDLER_MODEL_3 "" CACHE STRING "Path to built in model 3")
31
Mikael Olsson10ecba82024-03-21 14:07:54 +010032set(MESSAGE_HANDLER_ARENA_SIZE 0x200000 CACHE STRING "Total size of all message handler tensor arenas in bytes (Must be a power of two)")
Kristofer Jonsson3f5510f2023-02-08 14:23:00 +010033
34#############################################################################
35# TFLM arena
36#############################################################################
37
38# Split total tensor arena equally for each NPU
39if(TARGET ethosu_core_driver AND ETHOSU_TARGET_NPU_COUNT GREATER 0)
40 set(NUM_ARENAS ${ETHOSU_TARGET_NPU_COUNT})
41else()
42 set(NUM_ARENAS 1)
43endif()
44
45math(EXPR TENSOR_ARENA_SIZE "${MESSAGE_HANDLER_ARENA_SIZE} / ${NUM_ARENAS}")
46
47#############################################################################
48# Message handler application
49#############################################################################
50
51ethosu_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 Olsson918cd902023-12-13 09:57:42 +010063 ethosu_profiler
Kristofer Jonsson3f5510f2023-02-08 14:23:00 +010064 freertos_kernel
65 inference_process
66 openamp-freertos)
67
68target_include_directories(message_handler_openamp PRIVATE
Mikael Olsson34b190b2024-02-12 13:14:18 +010069 ${LINUX_DRIVER_STACK_PATH}/kernel/include)
Kristofer Jonsson3f5510f2023-02-08 14:23:00 +010070
71target_compile_definitions(message_handler_openamp PRIVATE
Ledion Dajab00e4ed2023-05-22 10:45:31 +020072 $<$<BOOL:${ENABLE_REMOTEPROC_TRACE_BUFFER}>:REMOTEPROC_TRACE_BUFFER>
Kristofer Jonsson3f5510f2023-02-08 14:23:00 +010073 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}>)