From edaf2f8cb3ed557c655ef414f135f4a4a9f50526 Mon Sep 17 00:00:00 2001 From: Lior Dekel Date: Tue, 10 Aug 2021 17:06:16 +0300 Subject: small fixes to FreeRTOS app. Change-Id: Ib1e59fda457edc90ceb324f35252c3def451c751 --- applications/freertos/main.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/applications/freertos/main.cpp b/applications/freertos/main.cpp index 5abcca2..1c1821d 100644 --- a/applications/freertos/main.cpp +++ b/applications/freertos/main.cpp @@ -46,7 +46,7 @@ using namespace InferenceProcess; // Nr. of tasks to process inferences with. Task reserves driver & runs inference (Normally 1 per NPU, but not a must) #define NUM_INFERENCE_TASKS 1 // Nr. of tasks to create jobs and recieve responses -#define NUM_JOB_TASKS 1 +#define NUM_JOB_TASKS 2 // Nr. of jobs to create per job task #define NUM_JOBS_PER_TASK 1 @@ -62,7 +62,7 @@ using namespace InferenceProcess; ****************************************************************************/ struct ProcessTaskParams { - ProcessTaskParams() {} + ProcessTaskParams() : queueHandle(nullptr), tensorArena(nullptr), arenaSize(0) {} ProcessTaskParams(QueueHandle_t _queue, uint8_t *_tensorArena, size_t _arenaSize) : queueHandle(_queue), tensorArena(_tensorArena), arenaSize(_arenaSize) {} @@ -71,11 +71,18 @@ struct ProcessTaskParams { size_t arenaSize; }; +namespace { // Number of total completed jobs, needed to exit application correctly if NUM_JOB_TASKS > 1 -static int totalCompletedJobs = 0; +int totalCompletedJobs = 0; // TensorArena static initialisation -static const size_t arenaSize = TENSOR_ARENA_SIZE_PER_INFERENCE; +const size_t arenaSize = TENSOR_ARENA_SIZE_PER_INFERENCE; + +// Declare below variables in global scope to avoid stack since FreeRTOS resets stack when the scheduler is started +QueueHandle_t inferenceProcessQueue; +ProcessTaskParams taskParams[NUM_INFERENCE_TASKS]; +} // namespace + __attribute__((section(".bss.tensor_arena"), aligned(16))) uint8_t inferenceProcessTensorArena[NUM_INFERENCE_TASKS][arenaSize]; @@ -210,11 +217,6 @@ void inferenceSenderTask(void *pvParameters) { /**************************************************************************** * Application ****************************************************************************/ - -// Declare variables in global scope to avoid stack since FreeRTOS resets stack when the scheduler is started -static QueueHandle_t inferenceProcessQueue; -static ProcessTaskParams taskParams[NUM_INFERENCE_TASKS]; - // FreeRTOS application. NOTE: Additional tasks may require increased heap size. int main() { BaseType_t ret; @@ -246,4 +248,4 @@ int main() { exit(1); return 0; -} \ No newline at end of file +} -- cgit v1.2.1