Add TIDL_SUBGRAPH_NUM_EVES env var
authorYuan Zhao <yuanzhao@ti.com>
Fri, 6 Mar 2020 22:47:32 +0000 (16:47 -0600)
committerYuan Zhao <yuanzhao@ti.com>
Fri, 6 Mar 2020 22:51:42 +0000 (16:51 -0600)
- Current subgraph implementation will initialize and use all available
  EVEs and DSPs, with streaming/batch inputs in mind.  There are cases
  we only need 1 EVE and 1 DSP, for example, demonstrating subgraph
  offloading on a single input.
  This commit adds an environment variable, TIDL_SUBGRAPH_NUM_EVES,
  to specify number of EVEs used for subgraph inferencing.
- MCT-1243

docs/source/changelog.rst
docs/source/using_api.rst
tidl_api/src/subgraph_runtime.cpp

index 42c4cf1987c4699634da1950e4d6112d56289bcb..da4370f03238d21ea99f075eb8646d597cf5e235 100644 (file)
@@ -2,11 +2,12 @@
 Changelog
 #########
 
-1.5.0 [Processor Linux SDK 6.3]
+1.5.1 [Processor Linux SDK 6.3]
 ===============================
 **Changed**
 
-#. Cleaned up subgraph cfg file entries.  Added TIDL_SUBGRAPH_DIR env var.
+#. Cleaned up subgraph cfg file entries.  Added TIDL_SUBGRAPH_DIR and
+   TIDL_SUBGRAPH_NUM_EVES env var.
 
 1.4.0 [Processor Linux SDK 6.2]
 ===============================
index d56bd52914dae4a8efb9a01e85e6e36737a174a7..f7446902e4a4b845bd7aef5e8da5febd0fdae8e7 100644 (file)
@@ -326,7 +326,7 @@ Subgraph config file
 
 Subgraph config file are named as "subgraph<number>.cfg", while <number>
 is the subgraph index in the original graph/network.  The environment
-variable `TIDL_SUBGRAPH_DIR` speicifies the directory where subgraph config
+variable `TIDL_SUBGRAPH_DIR` specifies the directory where subgraph config
 files reside.  If not specified, the current directory is assumed.
 
 Subgraph config file requires extra parameters to describe data conversion
@@ -337,3 +337,7 @@ set of required parameters.
 Subgraph runtime API
 ====================
 Please see `tidl_api/inc/subgraph_runtime.h` for details.
+
+The envrionment variable `TIDL_SUBGRAPH_NUM_EVES` specifies the number of
+EVEs used for inferencing.  If not specified, all available EVEs will be
+initialized and used.
index 5ac6e973bb75bb65275aeb12b380237389d61bfe..12705d50d02e3e033ecbf94bcbadb9e1e6b96ead 100644 (file)
@@ -218,6 +218,16 @@ void ResM::Init(uint32_t num_subgraphs)
     num_eves_m = Executor::GetNumDevices(DeviceType::EVE);
     num_dsps_m = Executor::GetNumDevices(DeviceType::DSP);
 
+    char *env_subgraph_num_eves = getenv("TIDL_SUBGRAPH_NUM_EVES");
+    if (env_subgraph_num_eves != nullptr)
+    {
+        uint32_t subgraph_num_eves = atoi(env_subgraph_num_eves);
+        if (subgraph_num_eves > 0 && subgraph_num_eves < num_eves_m)
+            num_eves_m = subgraph_num_eves;
+        if (subgraph_num_eves > 0 && subgraph_num_eves < num_dsps_m)
+            num_dsps_m = subgraph_num_eves;
+    }
+
     assert(num_eves_m > 0 || num_dsps_m > 0);
     assert(num_subgraphs_m <= num_eves_m || num_subgraphs_m <= num_dsps_m);
     num_es_per_subgraph_m = num_eves_m / num_subgraphs_m;