aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuan Zhao2019-08-27 13:56:02 -0500
committerYuan Zhao2019-08-27 13:57:26 -0500
commitc0aaf795d8f486a7d46b23a64b36f6b01d924161 (patch)
treec2bf0243a2095550c0add57e29e53bea124d9c7d
parent76a36460928b6f3ae9cc649a02c4f8dfa717d376 (diff)
downloadtidl-api-c0aaf795d8f486a7d46b23a64b36f6b01d924161.tar.gz
tidl-api-c0aaf795d8f486a7d46b23a64b36f6b01d924161.tar.xz
tidl-api-c0aaf795d8f486a7d46b23a64b36f6b01d924161.zip
Control heap size and alloc opt using env vars
- TIDL_PARAM_HEAP_SIZE_EVE, TIDL_PARAM_HEAP_SIZE_DSP, TIDL_NETWORK_HEAP_SIZE_EVE, TIDL_NETWORK_HEAP_SIZE_DSP, TIDL_EXTMEM_ALLOC_OPT_EVE, TIDL_EXTMEM_ALLOC_OPT_DSP are provided to overwrite the heap sizes and heap allocation optimization level (1 or 2) that are specified by default or by application. - MCT-1215
-rw-r--r--docs/source/using_api.rst13
-rw-r--r--tidl_api/src/configuration.cpp4
-rw-r--r--tidl_api/src/executor.cpp29
-rw-r--r--tidl_api/src/executor_impl.h1
-rw-r--r--tidl_api/src/parameters.h2
5 files changed, 45 insertions, 4 deletions
diff --git a/docs/source/using_api.rst b/docs/source/using_api.rst
index 47c0d9c..80d8a74 100644
--- a/docs/source/using_api.rst
+++ b/docs/source/using_api.rst
@@ -280,7 +280,20 @@ and the ``configuration.showHeapStats = true`` line can be removed.
280 280
281 The memory for parameter and network heaps is itself allocated from OpenCL global memory (CMEM). Refer :ref:`opencl-global-memory` for details. 281 The memory for parameter and network heaps is itself allocated from OpenCL global memory (CMEM). Refer :ref:`opencl-global-memory` for details.
282 282
283In addition, the following environment variables are provided to overwrite
284the heap sizes and heap allocation optimization level (1 or 2) that are
285specified by default or by application.
283 286
287.. code-block:: bash
288
289 TIDL_PARAM_HEAP_SIZE_EVE
290 TIDL_PARAM_HEAP_SIZE_DSP
291 TIDL_NETWORK_HEAP_SIZE_EVE
292 TIDL_NETWORK_HEAP_SIZE_DSP
293 TIDL_EXTMEM_ALLOC_OPT_EVE
294 TIDL_EXTMEM_ALLOC_OPT_DSP
295 # # for example,
296 # TIDL_PARAM_HEAP_SIZE_EVE=3000000 TIDL_NETWORK_HEAP_SIZE_EVE=21000000 TIDL_PARAM_HEAP_SIZE_DSP=3000000 TIDL_NETWORK_HEAP_SIZE_DSP=2000000 ./tidl_classification -g 2 -d 1 -e 4 -l ./imagenet.txt -s ./classlist.txt -i ./clips/test10.mp4 -c ./stream_config_j11_v2.txt
284 297
285.. _network_layer_output: 298.. _network_layer_output:
286 299
diff --git a/tidl_api/src/configuration.cpp b/tidl_api/src/configuration.cpp
index 8f512e8..c67b22c 100644
--- a/tidl_api/src/configuration.cpp
+++ b/tidl_api/src/configuration.cpp
@@ -39,8 +39,8 @@ Configuration::Configuration(): numFrames(0), inHeight(0), inWidth(0),
39 noZeroCoeffsPercentage(100), 39 noZeroCoeffsPercentage(100),
40 preProcType(0), 40 preProcType(0),
41 runFullNet(false), 41 runFullNet(false),
42 NETWORK_HEAP_SIZE(64 << 20), // 64MB for inceptionNetv1 42 NETWORK_HEAP_SIZE(internal::DEFAULT_NETWORK_HEAP_SIZE),
43 PARAM_HEAP_SIZE(9 << 20), // 9MB for mobileNet1 43 PARAM_HEAP_SIZE(internal::DEFAULT_PARAM_HEAP_SIZE),
44 enableOutputTrace(false), 44 enableOutputTrace(false),
45 enableApiTrace(false), 45 enableApiTrace(false),
46 showHeapStats(false), 46 showHeapStats(false),
diff --git a/tidl_api/src/executor.cpp b/tidl_api/src/executor.cpp
index 8020d4e..7a86040 100644
--- a/tidl_api/src/executor.cpp
+++ b/tidl_api/src/executor.cpp
@@ -27,6 +27,7 @@
27 *****************************************************************************/ 27 *****************************************************************************/
28 28
29#include <assert.h> 29#include <assert.h>
30#include <cstdlib>
30#include "executor.h" 31#include "executor.h"
31#include "executor_impl.h" 32#include "executor_impl.h"
32#include "parameters.h" 33#include "parameters.h"
@@ -85,7 +86,8 @@ ExecutorImpl::ExecutorImpl(DeviceType core_type, const DeviceIds& ids,
85 shared_networkparam_heap_m(nullptr, &__free_ddr), 86 shared_networkparam_heap_m(nullptr, &__free_ddr),
86 device_ids_m(ids), 87 device_ids_m(ids),
87 core_type_m(core_type), 88 core_type_m(core_type),
88 layers_group_id_m(layers_group_id) 89 layers_group_id_m(layers_group_id),
90 extmem_alloc_opt_m(TIDL_optimiseExtMemL1)
89{ 91{
90 std::string name = STRING(SETUP_KERNEL) ";" STRING(INIT_KERNEL) ";" 92 std::string name = STRING(SETUP_KERNEL) ";" STRING(INIT_KERNEL) ";"
91 STRING(PROCESS_KERNEL) ";" STRING(CLEANUP_KERNEL); 93 STRING(PROCESS_KERNEL) ";" STRING(CLEANUP_KERNEL);
@@ -107,6 +109,29 @@ bool ExecutorImpl::Initialize(const Configuration& configuration)
107{ 109{
108 configuration_m = configuration; 110 configuration_m = configuration;
109 111
112 // Env Vars: Overwrite default heap sizes and allocation optimization level
113 char *param_heap = nullptr;
114 char *network_heap = nullptr;
115 char *extmem_opt = nullptr;
116 if (core_type_m == DeviceType::DSP)
117 {
118 param_heap = getenv("TIDL_PARAM_HEAP_SIZE_DSP");
119 network_heap = getenv("TIDL_NETWORK_HEAP_SIZE_DSP");
120 extmem_opt = getenv("TIDL_EXTMEM_ALLOC_OPT_DSP");
121 }
122 else
123 {
124 param_heap = getenv("TIDL_PARAM_HEAP_SIZE_EVE");
125 network_heap = getenv("TIDL_NETWORK_HEAP_SIZE_EVE");
126 extmem_opt = getenv("TIDL_EXTMEM_ALLOC_OPT_EVE");
127 }
128 if (param_heap != nullptr)
129 configuration_m.PARAM_HEAP_SIZE = atoi(param_heap);
130 if (network_heap != nullptr)
131 configuration_m.NETWORK_HEAP_SIZE = atoi(network_heap);
132 if (extmem_opt != nullptr && *extmem_opt == '2')
133 extmem_alloc_opt_m = TIDL_optimiseExtMemL2;
134
110 // Allocate, initialize TIDL_CreateParams object 135 // Allocate, initialize TIDL_CreateParams object
111 up_malloc_ddr<TIDL_CreateParams> shared_createparam( 136 up_malloc_ddr<TIDL_CreateParams> shared_createparam(
112 malloc_ddr<TIDL_CreateParams>(), 137 malloc_ddr<TIDL_CreateParams>(),
@@ -251,7 +276,7 @@ void ExecutorImpl::InitializeNetworkCreateParam(TIDL_CreateParams *CP,
251 if (configuration_m.enableOutputTrace) 276 if (configuration_m.enableOutputTrace)
252 CP->optimiseExtMem = TIDL_optimiseExtMemL0; 277 CP->optimiseExtMem = TIDL_optimiseExtMemL0;
253 else 278 else
254 CP->optimiseExtMem = TIDL_optimiseExtMemL1; 279 CP->optimiseExtMem = extmem_alloc_opt_m;
255} 280}
256 281
257Exception::Exception(const std::string& error, const std::string& file, 282Exception::Exception(const std::string& error, const std::string& file,
diff --git a/tidl_api/src/executor_impl.h b/tidl_api/src/executor_impl.h
index bc6b187..8e79351 100644
--- a/tidl_api/src/executor_impl.h
+++ b/tidl_api/src/executor_impl.h
@@ -74,6 +74,7 @@ class ExecutorImpl
74 DeviceIds device_ids_m; 74 DeviceIds device_ids_m;
75 DeviceType core_type_m; 75 DeviceType core_type_m;
76 int layers_group_id_m; 76 int layers_group_id_m;
77 eTIDL_optimiseExtMem extmem_alloc_opt_m;
77}; 78};
78 79
79} // namespace tidl 80} // namespace tidl
diff --git a/tidl_api/src/parameters.h b/tidl_api/src/parameters.h
index 6c66358..721feec 100644
--- a/tidl_api/src/parameters.h
+++ b/tidl_api/src/parameters.h
@@ -31,6 +31,8 @@
31namespace tidl { 31namespace tidl {
32namespace internal { 32namespace internal {
33 33
34const size_t DEFAULT_PARAM_HEAP_SIZE = (9<<20); // 9MB for mobileNet1
35const size_t DEFAULT_NETWORK_HEAP_SIZE = (64<<20); // 64MB for inceptionNetv1
34const size_t DMEM0_SIZE = 8*1024; 36const size_t DMEM0_SIZE = 8*1024;
35const size_t DMEM1_SIZE = 128*1024; 37const size_t DMEM1_SIZE = 128*1024;
36const size_t OCMC_SIZE = 320*1024; 38const size_t OCMC_SIZE = 320*1024;