Change tensor arena size to be a power of two

The size of the memory used for the message handler's tensor arena will
always be rounded up to the next power of two when the Linux kernel
allocates it. Therefore, to align the tensor arena size with how the
memory is allocated and be able to use the full size allocated, the
tensor arena size must now be a power of two.

Change-Id: Ib67e77d1ffeb233ad12762a56ddbc20d26c71052
Signed-off-by: Mikael Olsson <mikael.olsson@arm.com>
diff --git a/applications/message_handler_openamp/CMakeLists.txt b/applications/message_handler_openamp/CMakeLists.txt
index f60e376..3a36c8d 100644
--- a/applications/message_handler_openamp/CMakeLists.txt
+++ b/applications/message_handler_openamp/CMakeLists.txt
@@ -29,7 +29,7 @@
 set(MESSAGE_HANDLER_MODEL_2 "" CACHE STRING "Path to built in model 2")
 set(MESSAGE_HANDLER_MODEL_3 "" CACHE STRING "Path to built in model 3")
 
-set(MESSAGE_HANDLER_ARENA_SIZE 2000000 CACHE STRING "Total size of all message handler tensor arenas")
+set(MESSAGE_HANDLER_ARENA_SIZE 0x200000 CACHE STRING "Total size of all message handler tensor arenas in bytes (Must be a power of two)")
 
 #############################################################################
 # TFLM arena
diff --git a/applications/message_handler_openamp/main.cpp b/applications/message_handler_openamp/main.cpp
index c120610..480156e 100644
--- a/applications/message_handler_openamp/main.cpp
+++ b/applications/message_handler_openamp/main.cpp
@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
+ * SPDX-FileCopyrightText: Copyright 2022-2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
  * SPDX-License-Identifier: Apache-2.0
  *
  * Licensed under the Apache License, Version 2.0 (the License); you may
@@ -50,11 +50,12 @@
 #endif
 
 #ifndef TENSOR_ARENA_SIZE
-#define TENSOR_ARENA_SIZE 2000000
+#define TENSOR_ARENA_SIZE 0x200000
 #endif
 
 // TensorArena static initialisation
 constexpr size_t arenaSize = TENSOR_ARENA_SIZE;
+static_assert(arenaSize && ((arenaSize & (arenaSize - 1)) == 0), "TENSOR_ARENA_SIZE must be a power of two");
 
 /*****************************************************************************
  * Resource table