[Fix] Rename DSP-related ones to HW/Recurring
authorDongju Chae <dongju.chae@samsung.com>
Fri, 6 Mar 2020 05:33:18 +0000 (14:33 +0900)
committer송욱/On-Device Lab(SR)/Staff Engineer/삼성전자 <wook16.song@samsung.com>
Fri, 6 Mar 2020 07:26:29 +0000 (16:26 +0900)
This commit renames DSP to HW/recurring because TRIV2 already
contains DSP inside SoC, and we don't know exact HW used in VD.

Signed-off-by: Dongju Chae <dongju.chae@samsung.com>
include/common/typedef.h
src/core/meson.build
src/core/ne-hw-input-service.c [moved from src/core/ne-dsp-input-service.c with 60% similarity]
src/core/ne-scheduler.c
src/core/ne-utils.c
tests/apptests/dummy_inference_hw.c [moved from tests/apptests/dummy_inference_dsp.c with 90% similarity]
tests/apptests/meson.build

index b74d875..dce1f54 100644 (file)
@@ -92,7 +92,7 @@ typedef enum {
                                   model. */
   NPUINPUT_I2S_MIC = 2, /**< ASR mode with on-chip internal I2S. modelid is ignored. */
   NPUINPUT_HOST = 3, /**< Process input frames transmitted from Host. Both ASR or Vision NPUs may use this. */
-  NPUINPUT_DSP = 4, /**< Process input frames transmitted from DSP. */
+  NPUINPUT_HW = 4, /**< Process input frames transmitted from third-party HW. */
 } npu_input_opmode;
 
 #define IS_DEVICE (val, devname)       (((val) & DEVICETYPE_MASK) == DEVICETYPE_ ## devname) /** E.g., IS_DEVICE(dev, ASR) */
@@ -106,7 +106,7 @@ typedef enum {
   SMODEL_OPS_INTERNAL_CAM = 2, /**< Internal Camera model */
   SMODEL_OPS_I2S_MIC = 3,  /**< Internal Mic model */
   SMODEL_OPS_NPU_ASR = 4, /** NPU-ASR model (used only internally) */
-  SMODEL_OPS_NPU_DSP = 5, /** NPU-DSP model (TRIV-2) */
+  SMODEL_OPS_RECURRING = 5,  /** NPU Recurring model (TRIV-2) */
   SMODEL_OPS_END,
 } model_opmode;
 
index 19c5494..2970b60 100644 (file)
@@ -10,7 +10,7 @@ ne_core_dependencies = [
 # Sources
 ne_core_sources = [
   'ne-host-input-service.c',
-  'ne-dsp-input-service.c',
+  'ne-hw-input-service.c',
   'ne-thread-pool.c',
   'ne-handler.c',
   'ne-scheduler.c',
similarity index 60%
rename from src/core/ne-dsp-input-service.c
rename to src/core/ne-hw-input-service.c
index c6324ae..e757b22 100644 (file)
@@ -4,9 +4,9 @@
  * Copyright (C) 2020 Dongju Chae <dongju.chae@samsung.com>
 */
 /**
- * @file ne-dsp-input-service.c
+ * @file ne-hw-input-service.c
  * @date 27 Feb 2020
- * @brief Handles input data from DSP to NPU for processing
+ * @brief Handles input data from third-party HW to NPU for processing
  * @author Dongju Chae <dongju.chae@samsung.com>
  * @bug No known bugs except for NYI items
  */
 #define DEVICE_ID 2 /** @todo fix this */
 #define TLB_NAME "srtlb"
 
-/** Get the dsp inservice element */
-#define DSP_PRIV(INPUT_SERVICE) ((dsp_priv_t *) INPUT_SERVICE->pdata)
+/** Get the hw inservice element */
+#define HW_PRIV(INPUT_SERVICE) ((hw_priv_t *) INPUT_SERVICE->pdata)
 
 typedef struct {
   /** private data structure per opened device */
   int device_npu_id;          /**< npu device number */
-  int device_dsp_id;          /**< dsp device number */
+  int device_hw_id;          /**< hw device number */
 
   int fd;                     /**< configured file descriptor */
   int tlb_fd;                 /**< file descriptor of TLB driver */
@@ -69,13 +69,13 @@ typedef struct {
 
   /** could be changed during execution */
   bool started;               /**< check it was started */
-} dsp_priv_t;
+} hw_priv_t;
 
 /**
  * @brief private data structure for worker data
  */
 typedef struct {
-  dsp_priv_t *dpriv;         /**< dsp private data */
+  hw_priv_t *hpriv;         /**< hw private data */
   config_priv_t config;       /**< the configured setup */
   npu_priority priority;      /**< the inference priority */
   uint64_t timestamp;         /**< the timestamp when it was requested */
@@ -84,9 +84,9 @@ typedef struct {
 /**
  * @brief register constructor and destructor functions
  */
-int init_dsp_inputservice(void) __attribute__ ((
+int init_hw_inputservice(void) __attribute__ ((
       constructor(INPUTSERVICE_PRIORITY)));
-void fini_dsp_inputservice(void) __attribute__ ((
+void fini_hw_inputservice(void) __attribute__ ((
       destructor(INPUTSERVICE_PRIORITY)));
 
 /**
@@ -103,44 +103,44 @@ static int get_dmabuf_id (int tlb_fd, const hwmem * hwmem_ptr)
 }
 
 /**
- * @brief configure the dsp input service
+ * @brief configure the hw input service
  */
-static int configureDSP (inputservice *me, const model *m, n40_data *data)
+static int configureHW (inputservice *me, const model *m, n40_data *data)
 {
   int status = 0;
-  dsp_priv_t *dpriv;
+  hw_priv_t *hpriv;
   uint64_t model_base_offset;
   npu_model_config model_config;
   npubin_meta *meta;
 
-  dpriv = DSP_PRIV (me);
-  assert (dpriv);
+  hpriv = HW_PRIV (me);
+  assert (hpriv);
 
   /** make sure that thread isnt created, else halt should be called */
-  if (dpriv->started) {
+  if (hpriv->started) {
     logerr(TAG, "Cannot configure device in non idle state of service\n");
     return -EBUSY;
   }
 
   meta = m->meta;
-  dpriv->config.model = m;
-  dpriv->config.data = data;
+  hpriv->config.model = m;
+  hpriv->config.data = data;
 
   /** set the mode for the device */
-  if (meta->type == SMODEL_OPS_NPU_DSP) {
-    dpriv->config.opmode = NPUINPUT_DSP;
-    dpriv->config.fd = dpriv->config.npu_fd;
+  if (meta->type == SMODEL_OPS_RECURRING) {
+    hpriv->config.opmode = NPUINPUT_HW;
+    hpriv->config.fd = hpriv->config.npu_fd;
   } else {
     logerr(TAG, "Unknown metadata provided, type: %d\n", meta->type);
     return -EINVAL;
   }
 
-  npu_set_mode (dpriv->config.fd, dpriv->config.opmode);
+  npu_set_mode (hpriv->config.fd, hpriv->config.opmode);
 
   /** ensure npu is in ready state */
-  status = npu_check_compute_ready(dpriv->config.fd);
+  status = npu_check_compute_ready(hpriv->config.fd);
   if (status < 0) {
-    logerr(TAG, "Cannot configure dsp in busy state of the device\n");
+    logerr(TAG, "Cannot configure HW in busy state of the device\n");
     return status;
   }
 
@@ -152,26 +152,26 @@ static int configureDSP (inputservice *me, const model *m, n40_data *data)
       return status;
     }
 
-    /** dsp input service passes dmabuf id as dmabuf_id */
-    model_config.dmabuf_id = get_dmabuf_id (dpriv->config.tlb_fd, m->memblock);
+    /** hw input service passes dmabuf id as dmabuf_id */
+    model_config.dmabuf_id = get_dmabuf_id (hpriv->config.tlb_fd, m->memblock);
     if (model_config.dmabuf_id < 0) {
       logerr(TAG, "Invalid dmabuf id for the provided model, errno: %d\n",
           model_config.dmabuf_id);
       return -EINVAL;
     }
 
-    /** setup model; @todo fix this when model for NPU-DSP is finalized*/
+    /** setup model; @todo fix this when model for the interface with HW is finalized*/
     model_config.program_size = meta->program_size;
     model_config.program_offset_addr = model_base_offset + NPUBIN_META_SIZE;
     model_config.weight_offset_addr = model_base_offset + NPUBIN_META_SIZE +
       model_config.program_size;
-    status = npu_set_model(dpriv->config.fd, &model_config);
+    status = npu_set_model(hpriv->config.fd, &model_config);
     if (status < 0) {
       logerr(TAG, "Unable to set the model on the NPU\n");
       return status;
     }
-    dpriv->config.model_id = model_config.model_id;
-    assert (dpriv->config.model_id >= 0);
+    hpriv->config.model_id = model_config.model_id;
+    assert (hpriv->config.model_id >= 0);
   }
 
   return 0;
@@ -180,20 +180,20 @@ static int configureDSP (inputservice *me, const model *m, n40_data *data)
 /**
  * @brief halt the service
  */
-static int haltDSP (inputservice *me, n40_haltmode mode)
+static int haltHW (inputservice *me, n40_haltmode mode)
 {
-  dsp_priv_t *dpriv;
+  hw_priv_t *hpriv;
 
-  dpriv = DSP_PRIV (me);
+  hpriv = HW_PRIV (me);
 
-  if (!dpriv->started) {
+  if (!hpriv->started) {
     logerr(TAG, "Halting device which has already been halted/not started\n");
     return -EPERM;
   }
 
   assert (mode != HALT_NONE);
-  /** just stop the DSP service */
-  dpriv->started = false;
+  /** just stop the HW service */
+  hpriv->started = false;
 
   return 0;
 }
@@ -202,18 +202,18 @@ static int haltDSP (inputservice *me, n40_haltmode mode)
  * @brief get the status for the service
  * @todo need refactoring
  */
-static n40_status getStatusDSP (inputservice *me, model_opmode opmode)
+static n40_status getStatusHW (inputservice *me, model_opmode opmode)
 {
   n40_status nstatus;
-  dsp_priv_t *dpriv;
+  hw_priv_t *hpriv;
 
-  if (opmode != SMODEL_OPS_NPU_DSP)
+  if (opmode != SMODEL_OPS_RECURRING)
     return N40_ERROR;
 
-  dpriv = DSP_PRIV (me);
-  assert (dpriv);
+  hpriv = HW_PRIV (me);
+  assert (hpriv);
 
-  if (dpriv->started) {
+  if (hpriv->started) {
     nstatus = N40_BUSY;
   } else {
     nstatus = N40_IDLE;
@@ -225,7 +225,7 @@ static n40_status getStatusDSP (inputservice *me, model_opmode opmode)
 static int perform_inference (void *data)
 {
   work_priv_t *wpriv;
-  dsp_priv_t *dpriv;
+  hw_priv_t *hpriv;
 
   npu_input_config input_config;
   uint64_t cur_timestamp;
@@ -234,22 +234,22 @@ static int perform_inference (void *data)
   assert (data);
 
   wpriv = (work_priv_t *) data;
-  dpriv = wpriv->dpriv;
+  hpriv = wpriv->hpriv;
 
-  if (dpriv == NULL) {
-    logerr (TAG, "Fail to find DSP inputservice\n");
+  if (hpriv == NULL) {
+    logerr (TAG, "Fail to find HW inputservice\n");
     status = -EINVAL;
     goto exit;
   }
 
-  /** check DSP inputservice first */
-  pthread_mutex_lock(dpriv->mutex);
-  if (!dpriv->started) {
-    pthread_mutex_unlock(dpriv->mutex);
+  /** check HW inputservice first */
+  pthread_mutex_lock(hpriv->mutex);
+  if (!hpriv->started) {
+    pthread_mutex_unlock(hpriv->mutex);
     status = 0;
     goto exit;
   }
-  pthread_mutex_unlock(dpriv->mutex);
+  pthread_mutex_unlock(hpriv->mutex);
 
   /** @todo set ioctl argument correctly */
   input_config.enable = 1;
@@ -279,7 +279,7 @@ static int perform_inference (void *data)
         "but still work without any errors\n");
   }
 
-  /** DSP does not require callback handling */
+  /** HW does not require callback handling */
 
 exit:
   free (wpriv);
@@ -290,19 +290,19 @@ exit:
 /**
  * @brief start the input service
  */
-static int startDSP (inputservice *me)
+static int startHW (inputservice *me)
 {
-  dsp_priv_t *dpriv;
+  hw_priv_t *hpriv;
 
-  dpriv = DSP_PRIV (me);
-  assert (dpriv);
+  hpriv = HW_PRIV (me);
+  assert (hpriv);
 
-  if (dpriv->started) {
+  if (hpriv->started) {
     logerr(TAG, "Cannot start already-started service\n");
     return -EBUSY;
   }
 
-  dpriv->started = true;
+  hpriv->started = true;
 
   return 0;
 }
@@ -310,18 +310,18 @@ static int startDSP (inputservice *me)
 /**
  * @brief move to the next input data
  */
-static int nextDSP (inputservice *me, buffer *buffer,
+static int nextHW (inputservice *me, buffer *buffer,
     npu_priority priority, uint64_t timestamp)
 {
-  dsp_priv_t *dpriv;
+  hw_priv_t *hpriv;
   work_priv_t *wpriv;
   int status;
 
-  dpriv = DSP_PRIV (me);
-  assert (dpriv);
+  hpriv = HW_PRIV (me);
+  assert (hpriv);
 
-  if (!dpriv->started) {
-    logerr(TAG, "Cannot feed dsp input to unstarted input service\n");
+  if (!hpriv->started) {
+    logerr(TAG, "Cannot feed HW input to unstarted input service\n");
     return -EINVAL;
   }
 
@@ -329,8 +329,8 @@ static int nextDSP (inputservice *me, buffer *buffer,
   if (!wpriv)
     return -ENOMEM;
 
-  memcpy (&wpriv->config, &dpriv->config, sizeof(config_priv_t));
-  wpriv->dpriv = dpriv;
+  memcpy (&wpriv->config, &hpriv->config, sizeof(config_priv_t));
+  wpriv->hpriv = hpriv;
   wpriv->priority = priority;
   wpriv->timestamp = timestamp;
 
@@ -349,91 +349,91 @@ static int nextDSP (inputservice *me, buffer *buffer,
 /**
  * @brief open the input service device
  * @param[in] device_id device number of npu for the input service
- * @param[in] dpriv dsp service private obj
+ * @param[in] hpriv hw service private obj
  * @return 0 on success, errno on failure
  * @note at least one NPU device should be opened
  */
-static int open_dsp_inputservice (int device_id, dsp_priv_t *dpriv)
+static int open_hw_inputservice (int device_id, hw_priv_t *hpriv)
 {
-  dpriv->config.npu_fd = npu_open(device_id, NPUCOND_CONN_SOCIP);
-  if (dpriv->config.npu_fd < 0) {
-    logerr(TAG, "Failed to open the NPU device, errno = %d\n", dpriv->config.npu_fd);
+  hpriv->config.npu_fd = npu_open(device_id, NPUCOND_CONN_SOCIP);
+  if (hpriv->config.npu_fd < 0) {
+    logerr(TAG, "Failed to open the NPU device, errno = %d\n", hpriv->config.npu_fd);
   } else {
-    dpriv->config.device_npu_id = device_id;
+    hpriv->config.device_npu_id = device_id;
   }
-  return (dpriv->config.npu_fd >= 0);
+  return (hpriv->config.npu_fd >= 0);
 }
 
 /**
  * @brief deregister the dsp input service
- * @param[in] dpriv dsp service private obj
+ * @param[in] hpriv dsp service private obj
  */
-static void close_dsp_inputservice (dsp_priv_t *dpriv)
+static void close_hw_inputservice (hw_priv_t *hpriv)
 {
   int status;
 
-  if (dpriv->config.npu_fd >= 0) {
-    status = npu_close (dpriv->config.npu_fd);
+  if (hpriv->config.npu_fd >= 0) {
+    status = npu_close (hpriv->config.npu_fd);
     if (status < 0)
       logwarn(TAG, "Fail to close npu device, (fd:%d, err: %d)\n",
-          dpriv->config.npu_fd, status);
+          hpriv->config.npu_fd, status);
   }
 }
 
 /**
- * @brief dsp inputservice object
+ * @brief hw inputservice object
  */
-static inputservice dsp_inputservice = {
-  .configure = configureDSP,
-  .halt = haltDSP,
-  .getStatus = getStatusDSP,
-  .start = startDSP,
-  .next = nextDSP,
+static inputservice hw_inputservice = {
+  .configure = configureHW,
+  .halt = haltHW,
+  .getStatus = getStatusHW,
+  .start = startHW,
+  .next = nextHW,
 };
 
 /**
- * @brief Start the dsp input service
+ * @brief Start the hw input service
  */
-int init_dsp_inputservice (void)
+int init_hw_inputservice (void)
 {
-  dsp_priv_t *dpriv;
+  hw_priv_t *hpriv;
   int status;
 
-  dpriv = (dsp_priv_t *) malloc(sizeof(dsp_priv_t));
-  if (dpriv == NULL) {
+  hpriv = (hw_priv_t *) malloc(sizeof(hw_priv_t));
+  if (hpriv == NULL) {
     return -ENOMEM;
   }
 
-  memset (dpriv, 0, sizeof (dsp_priv_t));
-  dpriv->mutex = &dsp_inputservice.mutex;
-  dpriv->cond = &dsp_inputservice.cond;
+  memset (hpriv, 0, sizeof (hw_priv_t));
+  hpriv->mutex = &hw_inputservice.mutex;
+  hpriv->cond = &hw_inputservice.cond;
 
   if ((status = tlb_open (TLB_NAME)) < 0) {
     logerr (TAG, "Fail to open a TLB driver\n");
-    free (dpriv);
+    free (hpriv);
     return status;
   }
-  dpriv->config.tlb_fd = status;
+  hpriv->config.tlb_fd = status;
 
-  if ((status = open_dsp_inputservice (DEVICE_ID, dpriv)) < 0) {
-    tlb_close (dpriv->config.tlb_fd);
-    free (dpriv);
+  if ((status = open_hw_inputservice (DEVICE_ID, hpriv)) < 0) {
+    tlb_close (hpriv->config.tlb_fd);
+    free (hpriv);
     return status;
   }
 
-  pthread_mutex_init(dpriv->mutex, NULL);
-  pthread_cond_init(dpriv->cond, NULL);
+  pthread_mutex_init(hpriv->mutex, NULL);
+  pthread_cond_init(hpriv->cond, NULL);
 
-  dsp_inputservice.pdata = (void *) dpriv;
-  dsp_inputservice.initialized = 1;
-  status = n40_register_input_service (SMODEL_OPS_NPU_DSP, &dsp_inputservice);
+  hw_inputservice.pdata = (void *) hpriv;
+  hw_inputservice.initialized = 1;
+  status = n40_register_input_service (SMODEL_OPS_RECURRING, &hw_inputservice);
   if (status < 0) {
-    pthread_mutex_destroy(dpriv->mutex);
-    pthread_cond_destroy(dpriv->cond);
-    close_dsp_inputservice (dpriv);
-    tlb_close (dpriv->config.tlb_fd);
-    free (dpriv);
-    dsp_inputservice.initialized = 0;
+    pthread_mutex_destroy(hpriv->mutex);
+    pthread_cond_destroy(hpriv->cond);
+    close_hw_inputservice (hpriv);
+    tlb_close (hpriv->config.tlb_fd);
+    free (hpriv);
+    hw_inputservice.initialized = 0;
     return status;
   }
 
@@ -441,25 +441,25 @@ int init_dsp_inputservice (void)
 }
 
 /**
- * @brief Terminate dsp input service
+ * @brief Terminate hw input service
  */
-void fini_dsp_inputservice (void)
+void fini_hw_inputservice (void)
 {
-  dsp_priv_t *dpriv;
+  hw_priv_t *hpriv;
 
-  if (dsp_inputservice.initialized == 1) {
-    dpriv = dsp_inputservice.pdata;
+  if (hw_inputservice.initialized == 1) {
+    hpriv = hw_inputservice.pdata;
 
     /** free all resources */
-    n40_unregister_input_service (SMODEL_OPS_NPU_DSP);
+    n40_unregister_input_service (SMODEL_OPS_RECURRING);
 
-    pthread_mutex_destroy(dpriv->mutex);
-    pthread_cond_destroy(dpriv->cond);
+    pthread_mutex_destroy(hpriv->mutex);
+    pthread_cond_destroy(hpriv->cond);
 
-    close_dsp_inputservice (dpriv);
-    tlb_close (dpriv->config.tlb_fd);
+    close_hw_inputservice (hpriv);
+    tlb_close (hpriv->config.tlb_fd);
     /** fini done */
-    dsp_inputservice.initialized = 0;
-    free (dpriv);
+    hw_inputservice.initialized = 0;
+    free (hpriv);
   }
 }
index 122a75c..e072f7a 100644 (file)
@@ -45,8 +45,8 @@ opmode_npu_to_n4 (npu_input_opmode op)
   switch (op) {
     case NPUINPUT_HOST:
       return SMODEL_OPS_NPU;
-    case NPUINPUT_DSP:
-      return SMODEL_OPS_NPU_DSP;
+    case NPUINPUT_HW:
+      return SMODEL_OPS_RECURRING;
     case NPUINPUT_I2S_MIC:
       return SMODEL_OPS_I2S_MIC;
     case NPUINPUT_INTERNAL_CAM:
index 6fa9dcb..c91e441 100644 (file)
@@ -276,7 +276,7 @@ static const char *modulestr[] = {
   [_N42] = "N42/Host",
   [_N43] = "N43/iMIC",
   [_N44] = "N44/ARMp",
-  [_N45] = "N45/iDSP",
+  [_N45] = "N45/iHW ",
   [_N50] = "N50/Pool",
   [_N7] =  "N7/Mem  ",
   [_N71] = "N71/CMA ",
similarity index 90%
rename from tests/apptests/dummy_inference_dsp.c
rename to tests/apptests/dummy_inference_hw.c
index 69f5cbe..1c7c54c 100644 (file)
@@ -4,9 +4,9 @@
  * Copyright (C) 2020 Dongju Chae <dongju.chae@samsung.com>
  */
 /**
- * @file dummy_inference_dsp.c
+ * @file dummy_inference_hw.c
  * @date 27 Feb 2020
- * @brief AppTest to test inference capability from internal inputs (e.g., DSP).
+ * @brief AppTest to test inference capability from recurring inputs (e.g., HW).
  * @author Dongju Chae <dongju.chae@samsung.com>
  * @bug No known bugs except for NYI items
  */
@@ -52,7 +52,7 @@ run_inference (npudev_h dev)
     .model_version = 1,
     .buffer_size = buffer_size,
     .size = NPUBIN_META_SIZE + program_size + weight_size,
-    .type = SMODEL_OPS_NPU_DSP,
+    .type = SMODEL_OPS_RECURRING,
     .input_offset = input_offset,
     .input_size = input_size,
     .output_offset = output_offset,
@@ -84,8 +84,8 @@ run_inference (npudev_h dev)
   for (i = 0; i < 100; i++) {
     /** @todo FastModel/Emulator doesn't support this application yet */
 #if 0
-    /** run with internal input (DSP). it doesn't require a callback */
-    err = runNPU_internalInput (dev, model_id, NPUINPUT_DSP, NULL, NULL);
+    /** run with internal input (HW). it doesn't require a callback */
+    err = runNPU_internalInput (dev, model_id, NPUINPUT_HW, NULL, NULL);
     if (err < 0)
       goto out_unregister;
 #endif
index 4e9dd41..0d38d49 100644 (file)
@@ -64,9 +64,9 @@ executable ('apptest_dummy_inference_asr',
   install_dir : join_paths(ne_bindir, 'apptests')
 )
 
-## VDNPU DSP
-executable ('apptest_dummy_inference_dsp',
-  'dummy_inference_dsp.c',
+## VDNPU third-party HW
+executable ('apptest_dummy_inference_hw',
+  'dummy_inference_hw.c',
   include_directories : ne_apptest_inc,
   dependencies : ne_test_utils_dep,
   link_with : ne_library_shared,