[API/Profile] Seperate profiling data
authorDongju Chae <dongju.chae@samsung.com>
Tue, 4 May 2021 10:30:00 +0000 (19:30 +0900)
committer채동주/On-Device Lab(SR)/Staff Engineer/삼성전자 <dongju.chae@samsung.com>
Thu, 6 May 2021 06:24:51 +0000 (15:24 +0900)
This patch seperates profiling data depending on its profile level.

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

index 55d0947..aab8d9d 100644 (file)
@@ -338,11 +338,14 @@ typedef struct {
 #define NPU_PROFILE_SIZE (256)
 #define NPU_OPNAME_MAX (128)
 
+/**
+ * Note that the below structure is shared among kernel/decoder and emulation codes.
+ * Please make sure any updates do not hurt the exising SW stack.
+ */
 typedef struct {
   union {
     struct {
-      char name[NPU_OPNAME_MAX]; /**< node name (null-terminated) */
-      int32_t node_id;           /**< node id ('-1' means unclassified node) */
+      char name[NPU_OPNAME_MAX]; /**< node/vISA name (null-terminated) */
 
       int64_t running_cycles;
 
@@ -352,11 +355,21 @@ typedef struct {
       int64_t sram_read_bytes;
       int64_t sram_write_bytes;
 
-      int64_t visa_exec_seq; /**< vISA global execution sequence */
-
       int64_t start_cycles;
       int64_t end_cycles;
 
+      union {
+        /* layer-level profiling specific info. */
+        struct {
+          int32_t node_id; /**< node id ('-1' means unclassified node) */
+        };
+        /* vISA-level profiling specific info. */
+        struct {
+          uint32_t visa_opcode;  /**< viSA opcode */
+          int64_t visa_prog_seq; /**< vISA program sequence */
+          int64_t visa_exec_seq; /**< vISA execution sequence (global) */
+        };
+      };
       /** TODO: Add more info */
     } __attribute__ ((packed, aligned));
     char reserved[NPU_PROFILE_SIZE];
index cab26c1..5c4f410 100644 (file)
@@ -23,6 +23,7 @@
 #include <ne-conf.h>
 
 #define MAX_EMUL_DEVICES (3)
+static uint64_t global_exec_seq = 0;
 
 class EmulReq {
  public:
@@ -119,6 +120,10 @@ class EmulReq {
         layer->running_cycles = common.cycle_end - common.cycle_start;
         layer->start_cycles = common.cycle_start;
         layer->end_cycles = common.cycle_end;
+        layer->visa_opcode = 0; /* NYI */
+        layer->visa_prog_seq = i;
+        /* In the first run, program sequence == exec sequence */
+        layer->visa_exec_seq = global_exec_seq++;
 
         switch (common.block_id) {
           case TRIV2PROF_BLOCKID_NNA: