Allow specifying benchmark arena size - The change to a 2MB arena caused some benchmark targets to fail to link due to needing more than 4MB. Add a parameter to the build rules to allow specifying the arena size per-target, and default to the old 1.5MB size. Change-Id: I37b49fb2d866fe0d7df33316374c3bc3d0271058
diff --git a/benchmarks/benchmark_kelvin.cc b/benchmarks/benchmark_kelvin.cc index eac9fe8..fdec54a 100644 --- a/benchmarks/benchmark_kelvin.cc +++ b/benchmarks/benchmark_kelvin.cc
@@ -52,7 +52,11 @@ #endif namespace { -constexpr int kTensorArenaSize = 2 * 1024 * 1024; +#ifdef ARENA_SIZE_BYTES +constexpr int kTensorArenaSize = ARENA_SIZE_BYTES; +#else +constexpr int kTensorArenaSize = 1536 * 1024; +#endif uint8_t g_tensor_arena[kTensorArenaSize] __attribute__((aligned(64))); __attribute__((section(".model_output_header"))) BenchmarkOutputHeader output_header = {
diff --git a/benchmarks/benchmarks.bzl b/benchmarks/benchmarks.bzl index 5f919f8..d49ba07 100644 --- a/benchmarks/benchmarks.bzl +++ b/benchmarks/benchmarks.bzl
@@ -30,6 +30,7 @@ hw_test_tags = [], iss_test_size = "small", iss_test_tags = [], + arena_size_bytes = 1536 * 1024, # 1.5MB **kwargs): if kelvin_binary_info: @@ -81,6 +82,7 @@ "-DTEST_DATA_OUTPUT={}".format(1 if test_data_output else 0), "-DPROFILE={}".format(1 if profile else 0), "-DBENCHMARK_PATH={}".format(benchmark_path), + "-DARENA_SIZE_BYTES={}".format(arena_size_bytes), ], deps = [ "@kelvin_sw//crt", @@ -190,6 +192,7 @@ profile = False, kelvin_binary_info = None, benchmark_path = "benchmarks", + arena_size_bytes = 1536 * 1024, # 1.5MB **kwargs): # Creation of binaries for running on FPGA @@ -294,6 +297,7 @@ "-DTEST_DATA_OUTPUT={}".format(1 if test_data_output else 0), "-DPROFILE={}".format(1 if profile else 0), "-DBENCHMARK_PATH={}".format(benchmark_path), + "-DARENA_SIZE_BYTES={}".format(arena_size_bytes), ], hdrs = kelvin_headers, deps = [