[Profile] Add unknown layer for unmapped vISA insts
authorDongju Chae <dongju.chae@samsung.com>
Wed, 17 Feb 2021 02:09:19 +0000 (11:09 +0900)
committer채동주/On-Device Lab(SR)/Staff Engineer/삼성전자 <dongju.chae@samsung.com>
Mon, 22 Feb 2021 04:38:55 +0000 (13:38 +0900)
This patch adds unknown layer for unmapped vISA insts.
This layer contains their accumlated values.

Signed-off-by: Dongju Chae <dongju.chae@samsung.com>
include/common/typedef.h
src/core/npu/NPUdrvAPI_emul.cc

index beb33d1..18ee9f4 100644 (file)
@@ -329,8 +329,8 @@ typedef struct {
 typedef struct {
   union {
     struct {
-      char name[NPU_OPNAME_MAX];
-      uint32_t node_id;
+      char name[NPU_OPNAME_MAX];  /**< node name (null-terminated) */
+      int32_t node_id;            /**< node id ('-1' means unknown node) */
 
       int64_t running_cycles;
 
index f79615b..3fdfad2 100644 (file)
@@ -686,7 +686,20 @@ TrinityEmulAPI::manipulateProfile (EmulTask *task, npu_profile *profile) const
   npubin_meta_profile *meta_profile =
          static_cast<npubin_meta_profile *> (elem->getAddr ());
   npu_profile_layer * new_layers =
-    new npu_profile_layer[meta_profile->node_entry_num];
+    new npu_profile_layer[meta_profile->node_entry_num + 1];
+
+  npu_profile_layer * unknown_layer =
+    &new_layers[meta_profile->node_entry_num];
+
+  snprintf (unknown_layer->name, NPU_OPNAME_MAX - 1, "%s", "Unknown");
+  unknown_layer->name[NPU_OPNAME_MAX - 1] = '\x00';
+  unknown_layer->node_id = -1;
+
+  unknown_layer->running_cycles = 0;
+  unknown_layer->dram_read_bytes = 0;
+  unknown_layer->dram_write_bytes = 0;
+  unknown_layer->sram_read_bytes = 0;
+  unknown_layer->sram_write_bytes = 0;
 
   /** 1) parsing node table */
   std::unordered_map<uint32_t, npu_profile_layer *> node_table;
@@ -738,7 +751,6 @@ TrinityEmulAPI::manipulateProfile (EmulTask *task, npu_profile *profile) const
     memcpy (&node_num, meta_profile->entry_data + pos, sizeof (uint32_t));
     pos += sizeof (uint32_t);
 
-    /** TODO: for now, let's skip vISA insts unmapped to node layers */
     if (node_num > 0) {
       uint32_t * node_ids = (uint32_t *) (meta_profile->entry_data + pos);
 
@@ -759,6 +771,12 @@ TrinityEmulAPI::manipulateProfile (EmulTask *task, npu_profile *profile) const
           std::cerr << "Unable to find the node ID " << node_id << std::endl;
         }
       }
+    } else {
+      unknown_layer->running_cycles += profile->layers[i].running_cycles;
+      unknown_layer->dram_read_bytes += profile->layers[i].dram_read_bytes;
+      unknown_layer->dram_write_bytes += profile->layers[i].dram_write_bytes;
+      unknown_layer->sram_read_bytes += profile->layers[i].sram_read_bytes;
+      unknown_layer->sram_write_bytes += profile->layers[i].sram_write_bytes;
     }
 
     pos += sizeof (uint32_t) * node_num;
@@ -770,7 +788,7 @@ TrinityEmulAPI::manipulateProfile (EmulTask *task, npu_profile *profile) const
     delete [] profile->layers;
 
     profile->layers = new_layers;
-    profile->num_layers = num_layers;
+    profile->num_layers = num_layers + 1;
   }
 }