[Build/Dir] Reconstruct core source directory
authorDongju Chae <dongju.chae@samsung.com>
Fri, 9 Aug 2019 07:00:19 +0000 (16:00 +0900)
committer채동주/On-Device Lab(SR)/Staff Engineer/삼성전자 <dongju.chae@samsung.com>
Fri, 9 Aug 2019 07:12:43 +0000 (16:12 +0900)
This commit reconstructs core source directory.

The below is the summary of what's changed.

1. reconstruct src directory (issue #153), like
+-- src/
|   +-- host/
|   +-- core/
|       +-- ne-*.c/ne-*.h
|       +-- ip/
|       +-- gem/
|       +-- npu/
|   +-- test/
|       +-- unittests/
|       +-- apptests/
2. change meson.build scripts to keep the same style.
3. change source file names to have the same prefix.

It resolves #153.

Signed-off-by: Dongju Chae <dongju.chae@samsung.com>
53 files changed:
meson.build
meson_options.txt
packaging/npu-engine.spec
src/README.md [moved from src/core/npu-engine/ip/README.md with 100% similarity]
src/core/gem/GEMdrvAPI.c [moved from src/core/libgem-core/GEMdrvAPI.c with 100% similarity]
src/core/gem/GEMdrvAPI.h [moved from src/core/libgem-core/GEMdrvAPI.h with 100% similarity]
src/core/gem/README.md [moved from src/core/npu-engine/README.md with 100% similarity]
src/core/gem/meson.build [new file with mode: 0644]
src/core/ip/README.md [moved from src/core/libnpu-core/README.md with 100% similarity]
src/core/ip/meson.build [new file with mode: 0644]
src/core/ip/plugin-comm-ip.c [moved from src/core/npu-engine/ip/plugin-ip-comm.c with 99% similarity]
src/core/libgem-core/meson.build [deleted file]
src/core/libnpu-core/meson.build [deleted file]
src/core/libutils-core/meson.build [deleted file]
src/core/main.c [moved from src/core/npu-engine/main.c with 100% similarity]
src/core/meson.build
src/core/ne-armplugin.c [moved from src/core/npu-engine/ne-armplugin.c with 100% similarity]
src/core/ne-comm.h [moved from src/core/npu-engine/ne-comm.h with 100% similarity]
src/core/ne-common.h [moved from src/core/npu-engine/ne-common.h with 100% similarity]
src/core/ne-conf.c [moved from src/core/libutils-core/ne-conf.c with 100% similarity]
src/core/ne-conf.h [moved from src/core/libutils-core/ne-conf.h with 100% similarity]
src/core/ne-handler.c [moved from src/core/npu-engine/ne-handler.c with 100% similarity]
src/core/ne-handler.h [moved from src/core/npu-engine/ne-handler.h with 100% similarity]
src/core/ne-host-input-service.c [moved from src/core/npu-engine/ne-host-input-service.c with 100% similarity]
src/core/ne-inf.c [moved from src/core/npu-engine/ne-inf.c with 100% similarity]
src/core/ne-inf.h [moved from src/core/npu-engine/ne-inf.h with 100% similarity]
src/core/ne-inputservice.h [moved from src/core/npu-engine/ne-inputservice.h with 100% similarity]
src/core/ne-mem.c [moved from src/core/npu-engine/ne-mem.c with 100% similarity]
src/core/ne-mem.h [moved from src/core/npu-engine/ne-mem.h with 100% similarity]
src/core/ne-model.h [moved from src/core/npu-engine/ne-model.h with 100% similarity]
src/core/ne-scheduler.c [moved from src/core/npu-engine/ne-scheduler.c with 100% similarity]
src/core/ne-scheduler.h [moved from src/core/npu-engine/ne-scheduler.h with 100% similarity]
src/core/ne-utils.c [moved from src/core/libutils-core/ne-utils.c with 100% similarity]
src/core/ne-utils.h [moved from src/core/libutils-core/ne-utils.h with 100% similarity]
src/core/npu-engine/fm/meson.build [deleted file]
src/core/npu-engine/fm/plugin-fastmodel.c [deleted file]
src/core/npu-engine/ip/meson.build [deleted file]
src/core/npu-engine/meson.build [deleted file]
src/core/npu-engine/usb/meson.build [deleted file]
src/core/npu/NPUdrvAPI.c [moved from src/core/libnpu-core/NPUdrvAPI.c with 100% similarity]
src/core/npu/NPUdrvAPI.h [moved from src/core/libnpu-core/NPUdrvAPI.h with 100% similarity]
src/core/npu/README.md [moved from src/core/libgem-core/README.md with 100% similarity]
src/core/npu/meson.build [new file with mode: 0644]
src/host/libnpuhost/meson.build
src/host/meson.build
src/meson.build
src/test/apptests/meson.build [new file with mode: 0644]
src/test/meson.build
src/test/unittests/meson.build [new file with mode: 0644]
src/test/unittests/ne_core_gem_test.cpp [moved from src/test/libgem_test.cpp with 94% similarity]
src/test/unittests/ne_core_mem_test.cpp [moved from src/test/ne_mem_test.cpp with 98% similarity]
src/test/unittests/ne_core_npu_test.cpp [moved from src/test/npu_api_test.cpp with 96% similarity]
src/test/unittests/ne_core_utils_test.cpp [moved from src/test/ne_utils_test.cpp with 95% similarity]

index e5bf8f7..756bdff 100644 (file)
@@ -50,20 +50,6 @@ iniparser_dep = dependency('iniparser') # iniparser library
 
 subdir('src')
 
-comm_opt = get_option('comm_opt')
-
-if comm_opt == 'ip'
-  ne_dependencies = [
-    npu_engine_dep
-  ]
-
-  # Build final exported so
-  plugin_ip_executable = shared_library('npu-engine',
-    dependencies: ne_dependencies,
-    install : true,
-    install_dir: ne_libdir)
-endif
-
 # Set configuration to install .ini
 ne_install_conf = configuration_data()
 
index df19b21..9b721b8 100644 (file)
@@ -1,4 +1,4 @@
-option('comm_opt', type : 'combo', choices : ['ip', 'fm'], value : 'ip')
+option('comm_opt', type : 'string', value : 'ip')
 option('resv_mem_size', type : 'string', value : '512M')
 option('working_dir', type : 'string', value : '/tmp/')
 option('log_dir', type : 'string', value : '/tmp')
index b2619fd..e761a80 100644 (file)
@@ -67,7 +67,7 @@ DESTDIR=%{buildroot} ninja install -C build %{?_smp_mflags}
 # Perform unit tests
 %check
 %if 0%{?unit_test}
-  pushd build/src/test
+  pushd build/src/test/unittests
   find . -maxdepth 1 -type f -perm 0755 -print0 | while IFS= read -r -d $'\0' unittest_exec; do
   %if 0%{?use_valgrind}
     %ifarch x86_64
@@ -114,6 +114,7 @@ DESTDIR=%{buildroot} ninja install -C build %{?_smp_mflags}
 %files
 %%defattr(-,root,root,-)
 %{_libdir}/libnpu-engine.so
+%{_libdir}/libnpu-engine.a
 %{_sysconfdir}/npu-engine.ini
 
 %package devel
diff --git a/src/core/gem/meson.build b/src/core/gem/meson.build
new file mode 100644 (file)
index 0000000..3622ef0
--- /dev/null
@@ -0,0 +1,6 @@
+ne_core_gem_inc = include_directories('.')
+ne_core_gem_src = ['GEMdrvAPI.c']
+ne_core_gem_dep = declare_dependency(
+  sources : ne_core_gem_src,
+  dependencies : [libdrm_dep, ne_core_utils_dep],
+  include_directories : ne_core_gem_inc)
diff --git a/src/core/ip/meson.build b/src/core/ip/meson.build
new file mode 100644 (file)
index 0000000..f08debd
--- /dev/null
@@ -0,0 +1,4 @@
+ne_plugin_comm_ip_src = ['plugin-comm-ip.c']
+ne_plugin_comm_dep = declare_dependency(
+  sources : ne_plugin_comm_ip_src,
+  include_directories : [ne_common_inc, ne_host_inc, ne_core_inc])
similarity index 99%
rename from src/core/npu-engine/ip/plugin-ip-comm.c
rename to src/core/ip/plugin-comm-ip.c
index 2258de5..b8d0cd3 100644 (file)
@@ -5,7 +5,7 @@
  * Copyright (C) 2019 Parichay Kapoor <pk.kapoor@samsung.com>
  */
 /**
- * @file plugin-ip-comm.c
+ * @file plugin-comm-ip.c
  * @date 26 Jul 2019
  * @brief Implement API to access NPU from Host
  * @see http://suprem.sec.samsung.net/confluence/display/ODLC/Software+Stack
diff --git a/src/core/libgem-core/meson.build b/src/core/libgem-core/meson.build
deleted file mode 100644 (file)
index e7ebebd..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-libgem_src = ['GEMdrvAPI.c']
-libgem_inc = include_directories('.')
-libgem_dependencies = [libdrm_dep, libutils_dep]
-
-# Build library (static)
-libgem_build = static_library('gem-core',
-  libgem_src,
-  dependencies: libgem_dependencies,
-  install: false
-)
-
-# Declare dependency for other modules
-libgem_dep = declare_dependency(link_with : libgem_build,
-  include_directories : libgem_inc)
diff --git a/src/core/libnpu-core/meson.build b/src/core/libnpu-core/meson.build
deleted file mode 100644 (file)
index b3c09bb..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-libnpucore_src = ['NPUdrvAPI.c']
-libnpucore_inc = include_directories('.')
-
-# Build library (static)
-libnpucore = static_library('npu-core',
-  libnpucore_src,
-  include_directories: ne_common_inc,
-  dependencies: libutils_dep,
-  install : false)
-
-# Declare dependency for other modules
-libnpucore_dep = declare_dependency(link_with : libnpucore,
-  include_directories: [ne_common_inc, libnpucore_inc])
diff --git a/src/core/libutils-core/meson.build b/src/core/libutils-core/meson.build
deleted file mode 100644 (file)
index 51a0a16..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-libutils_inc = include_directories('.')
-libutils_src = [
-  'ne-conf.c',
-  'ne-utils.c'
-]
-
-# Build library (static)
-libutils = static_library('libutils',
-  libutils_src,
-  include_directories: libutils_inc,
-  dependencies: iniparser_dep,
-  install : false)
-
-# Declare dependency for other modules
-libutils_dep = declare_dependency(link_with : libutils,
-  include_directories: libutils_inc)
similarity index 100%
rename from src/core/npu-engine/main.c
rename to src/core/main.c
index 3f27ca3..fcf2eda 100644 (file)
@@ -1,4 +1,48 @@
-subdir('libutils-core')
-subdir('libgem-core')
-subdir('libnpu-core')
-subdir('npu-engine')
+# Headers
+ne_core_inc = include_directories('.')
+
+# Dependencies
+ne_core_dependencies = [
+  libm_dep,
+  thread_dep
+]
+
+# Sources
+ne_core_sources = [
+  'ne-host-input-service.c',
+  'ne-handler.c',
+  'ne-scheduler.c',
+  'ne-inf.c',
+  'ne-mem.c'
+]
+
+ne_core_utils_sources = [
+  'ne-conf.c',
+  'ne-utils.c',
+]
+
+# Dependency for utils
+ne_core_utils_dep = declare_dependency(
+  sources : ne_core_utils_sources,
+  dependencies : iniparser_dep,
+  include_directories : ne_core_inc
+)
+ne_core_dependencies += [ne_core_utils_dep]
+
+# Dependency for driver APIs
+subdir('npu')
+subdir('gem')
+
+ne_core_dependencies += [ne_core_npu_dep, ne_core_gem_dep]
+
+# Dependency for plugin comm.
+comm_opt = get_option('comm_opt')
+subdir(comm_opt)
+
+ne_core_dependencies += [ne_plugin_comm_dep]
+
+# Declare dependency for npu engine core
+ne_core_dep = declare_dependency(
+  sources : ne_core_sources,
+  dependencies : ne_core_dependencies
+)
diff --git a/src/core/npu-engine/fm/meson.build b/src/core/npu-engine/fm/meson.build
deleted file mode 100644 (file)
index 067beff..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-plugin_fm_inc = include_directories('.')
-plugin_fm_sources = ['plugin-fastmodel.c']
-plugin_fm_dep = declare_dependency(
-  sources : plugin_fm_sources,
-  include_directories : plugin_fm_inc)
diff --git a/src/core/npu-engine/fm/plugin-fastmodel.c b/src/core/npu-engine/fm/plugin-fastmodel.c
deleted file mode 100644 (file)
index d5fe585..0000000
+++ /dev/null
@@ -1,420 +0,0 @@
-/**
- * Proprietary
- * Copyright (C) 2019 Samsung Electronics
- * Copyright (C) 2019 Dongju Chae <dongju.chae@samsung.com>
- */
-/**
- * @file plugin-fastmodel.c
- * @date 29 Jul 2019
- * @brief NPU Engine's communication plugin for FastModel (N12)
- * @see http://suprem.sec.samsung.net/confluence/display/ODLC/Software+Stack
- * @see http://suprem.sec.samsung.net/confluence/pages/viewpage.action?pageId=128465352
- * @author Dongju Chae <dongju.chae@samsung.com>
- * @bug No known bugs except for NYI items
- */
-
-#include <ne-comm.h>
-#include <ne-mem.h>
-#include <ne-utils.h>
-#include <npubinfmt.h>
-
-#include <pthread.h>
-#include <errno.h>
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-/** @todo change this */
-#define SERVER_FM_ADDR        "127.0.0.1"
-#define SERVER_FM_INPUT_PORT  5515
-#define SERVER_FM_OUTPUT_PORT 5516
-
-/** @brief recv/send macros for TCP/IP */
-#define RECV(fd, buf, size) (read(fd, buf, size) == size)
-#define SEND(fd, buf, size) (write(fd, buf, size) == size)
-
-/**
- * @note This retrieves model files and input frames from the host server via a TCP/IP comm.
- *       But, actual USB communications will work in the opposite way.
- */
-
-/** @brief command enum */
-typedef enum {
-  COMM_NONE = 0,
-  COMM_REGISTER,
-  COMM_UNREGISTER,
-  COMM_NEW_INPUT,
-  COMM_SET_OPMODE,
-} n12_command;
-
-/** @brief n12's private data structure */
-typedef struct {
-  const hostHandlerInfo *handler;
-  int running;
-  int sockfd;
-  pthread_t comm_thread, output_thread;
-  pthread_mutex_t mutex;
-} n12_private;
-
-static n12_private priv;
-
-/** @brief internal thread for sending output data via TCP/IP */
-static void*
-run_output (void *data)
-{
-  pthread_mutex_lock (&priv.mutex);
-
-  while (priv.running) {
-    struct sockaddr_in server_addr;
-    int sockfd, err = 0;
-    buffer *output_buffer;
-    hwmem *output_hwmem;
-    void *ptr;
-
-    pthread_mutex_unlock (&priv.mutex);
-
-    output_buffer = priv.handler->getCurrentOutputBuffer (&err);
-    if (err != 0) {
-      fprintf (stderr, "Fail to get output buffer (errno: %d)\n", err);
-      break;
-    }
-
-    err = buffer_get_hwmem (output_buffer, &output_hwmem);
-    if (err != 0) {
-      GET_MEM()->return_buffer (output_buffer);
-      fprintf (stderr, "Fail to get hwmem (errno: %d)\n", err);
-      break;
-    }
-
-    err = hwmem_get_data (output_hwmem, &ptr);
-    if (err != 0) {
-      GET_MEM()->return_buffer (output_buffer);
-      fprintf (stderr, "Fail to get data pointer (errno: %d)\n", err);
-      break;
-    }
-
-    if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-      GET_MEM()->return_buffer (output_buffer);
-      fprintf (stderr, "Fail to create a socket\n");
-      break;
-    }
-
-    memset (&server_addr, '\x00', sizeof (server_addr));
-
-    server_addr.sin_family = AF_INET;
-    server_addr.sin_port = htons(SERVER_FM_OUTPUT_PORT);
-    server_addr.sin_addr.s_addr = inet_addr(SERVER_FM_ADDR);
-
-    if (connect (sockfd, (struct sockaddr *) &server_addr, sizeof (server_addr)) < 0) {
-      fprintf (stderr, "Fail to connect the server (%s:%d)\n",
-                       SERVER_FM_ADDR, SERVER_FM_OUTPUT_PORT);
-      GET_MEM()->return_buffer (output_buffer);
-      close (sockfd);
-      break;
-    }
-
-    if (!SEND (sockfd, ptr, output_hwmem->size)) {
-      fprintf (stderr, "Fail to send output data %lu\n", output_hwmem->size);
-      GET_MEM()->return_buffer (output_buffer);
-      close (sockfd);
-      break;
-    }
-
-    GET_MEM()->return_buffer (output_buffer);
-    close (sockfd);
-
-    pthread_mutex_lock (&priv.mutex);
-  }
-  pthread_mutex_unlock (&priv.mutex);
-
-  return NULL;
-}
-
-static int
-handle_register (void)
-{
-  uint64_t data_size;
-  hwmem *hwmem;
-  void *ptr;
-  int err = 0;
-
-  /* recv meta data */
-  if (!RECV (priv.sockfd, &data_size, sizeof (data_size))) {
-    fprintf (stderr, "Fail to receive data size\n");
-    err = -errno; 
-    goto out;
-  }
-
-  if (priv.handler->getAvailableModelMemory() < data_size) {
-    fprintf (stderr, "No availabl memory size\n");
-    err = -ENOMEM;
-    goto out;
-  }
-
-  if ((err = GET_MEM()->alloc (data_size, &hwmem)) != 0) {
-    fprintf (stderr, "Fail to allocate memory with size %lu\n", data_size);
-    goto out;
-  }
-
-  if ((err = hwmem_activate (hwmem)) != 0) {
-    fprintf (stderr, "Fail to activate hwmem\n");
-    goto out_free;
-  }
-
-  if ((err = hwmem_get_data (hwmem, &ptr)) != 0) {
-    fprintf (stderr, "Fail to get data pointer\n");
-    goto out_deactivate;
-  }
-
-  if (!RECV (priv.sockfd, ptr, data_size)) {
-    fprintf (stderr, "Fail to receive data\n");
-    err = -errno;
-    goto out_deactivate;
-  }
-
-  if ((err = priv.handler->registerModel (hwmem)) != 0) {
-    fprintf (stderr, "Fail to registermodel\n");
-    goto out_deactivate;
-  }
-
-  return 0;
-
-out_deactivate:
-  hwmem_deactivate (hwmem);
-out_free:
-  GET_MEM()->dealloc (hwmem);
-out:
-  return err;
-}
-
-static int
-handle_unregister (void)
-{
-  uint64_t model_id, model_version;
-
-  if (!RECV (priv.sockfd, &model_id, sizeof (model_id))) {
-    fprintf (stderr, "Fail to receive model id\n");
-    return -errno;
-  }
-
-  if (!RECV (priv.sockfd, &model_version, sizeof (model_version))) {
-    fprintf (stderr, "Fail to receive model version\n");
-    return -errno;
-  }
-
-  return priv.handler->unregisterModel (model_id, model_version);
-}
-
-static int
-handle_new_input (void)
-{
-  uint64_t data_size;
-  buffer *buffer;
-  hwmem *hwmem;
-  void *ptr;
-  int err = 0;
-
-  buffer = priv.handler->getCurrentInputBuffer (&err);
-  if (err != 0) {
-    fprintf (stderr, "Fail to get input buffer (errno: %d)\n", err);
-    goto out;
-  }
-
-  if ((err = buffer_get_hwmem (buffer, &hwmem)) != 0) {
-    GET_MEM()->return_buffer (buffer);
-    fprintf (stderr, "Fail to get hwmem (errno: %d)\n", err);
-    goto out;
-  }
-
-  if ((err = hwmem_get_data (hwmem, &ptr)) != 0) {
-    GET_MEM()->return_buffer (buffer);
-    fprintf (stderr, "Fail to get data pointer (errno: %d)\n", err);
-    goto out;
-  }
-
-  /* recv meta data */
-  if (!RECV (priv.sockfd, &data_size, sizeof (data_size))) {
-    fprintf (stderr, "Fail to receive data size\n");
-    err = -errno; 
-    goto out;
-  }
-
-  if (!RECV (priv.sockfd, ptr, data_size)) {
-    fprintf (stderr, "Fail to receive input data\n");
-    err = -errno; 
-    goto out;
-  }
-
-  if ((err = priv.handler->validateBuffer (buffer)) != 0) {
-    fprintf (stderr, "Fail to validate buffer\n");
-    goto out;
-  }
-
-  return 0;
-out:
-  return err;
-}
-
-static void
-n1_cb (buffer *buf, uint64_t offset, uint64_t size, void *data)
-{
-  /** @todo */ 
-}
-
-static int
-handle_set_opmode (void)
-{
-  npu_input_opmode op;
-  int force;
-  uint64_t model_id, model_version;
-
-  if (!RECV (priv.sockfd, &op, sizeof (op))) {
-    fprintf (stderr, "Fail to receive npu input opmode\n");
-    return -errno;
-  }
-  if (!RECV (priv.sockfd, &force, sizeof (force))) {
-    fprintf (stderr, "Fail to receive force variable\n");
-    return -errno;
-  }
-
-  if (!RECV (priv.sockfd, &model_id, sizeof (model_id))) {
-    fprintf (stderr, "Fail to receive model id\n");
-    return -errno;
-  }
-
-  if (!RECV (priv.sockfd, &model_version, sizeof (model_version))) {
-    fprintf (stderr, "Fail to receive model version\n");
-    return -errno;
-  }
-
-  return priv.handler->setOpMode (op, force, model_id, model_version, n1_cb, NULL /* TBD */);
-}
-
-static void
-raise_error (void)
-{
-  pthread_mutex_lock (&priv.mutex);
-  priv.running = 0;
-  pthread_mutex_unlock (&priv.mutex);
-}
-
-/** @brief internal thread for reading command/input data via TCP/IP */
-static void*
-run_comm (void *data)
-{
-  n12_command command;
-  int status;
-
-  if (pthread_create (&priv.output_thread, NULL, run_output, (void*) NULL) < 0) {
-    fprintf (stderr, "Fail to create the internal output thread\n");
-    goto out;
-  }
-  pthread_mutex_lock (&priv.mutex);
-  while (priv.running) {
-    pthread_mutex_unlock (&priv.mutex);
-
-    if (!RECV (priv.sockfd, &command, sizeof (n12_command))) {
-      fprintf (stderr, "Fail to receive command\n");
-      raise_error ();
-      break;
-    }
-
-    switch (command) {
-      case COMM_REGISTER:
-        if (handle_register () != 0)
-          raise_error ();
-        break;
-      case COMM_UNREGISTER:
-        if (handle_unregister () != 0)
-          raise_error ();
-        break;
-      case COMM_NEW_INPUT:
-        if (handle_new_input () != 0)
-          raise_error ();
-        break;
-      case COMM_SET_OPMODE:
-        if (handle_set_opmode () != 0)
-          raise_error ();
-      default:
-        raise_error ();
-    }
-
-    pthread_mutex_lock (&priv.mutex);
-  }
-  pthread_mutex_unlock (&priv.mutex);
-
-  pthread_join (priv.output_thread, (void **)&status);
-out:
-  close (priv.sockfd);
-
-  return NULL;
-}
-
-/** @brief init function for fastmodel plugin */
-int 
-initNEcomm (const hostHandlerInfo *hh)
-{
-  struct sockaddr_in server_addr;
-  int sockfd;
-
-  if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-    fprintf (stderr, "Fail to create a socket\n");
-    return -errno;
-  }
-
-  memset (&server_addr, '\x00', sizeof (server_addr));
-
-  server_addr.sin_family = AF_INET;
-  server_addr.sin_port = htons(SERVER_FM_INPUT_PORT);
-  server_addr.sin_addr.s_addr = inet_addr(SERVER_FM_ADDR);
-
-  if (connect (sockfd, (struct sockaddr *)&server_addr, sizeof (server_addr)) < 0) {
-    fprintf (stderr, "Fail to connect the server (%s:%d)\n",
-                     SERVER_FM_ADDR, SERVER_FM_INPUT_PORT);
-    return -errno;
-  }
-
-  priv.sockfd = sockfd;
-  priv.handler = hh;
-  priv.running = 1;
-
-  pthread_mutex_init (&priv.mutex, NULL);
-
-  if (pthread_create (&priv.comm_thread, NULL, run_comm, (void*) NULL) < 0) {
-    fprintf (stderr, "Fail to create the internal thread\n");
-    close (sockfd);
-    priv.running = 0;
-    pthread_mutex_destroy (&priv.mutex);
-    return -errno;
-  }
-
-  return 0;
-}
-
-/** @brief exit function for fastmodel plugin */
-int
-exitNEcomm (void)
-{
-  if (priv.running == 1) {
-    int status;
-
-    pthread_mutex_lock (&priv.mutex);
-    priv.running = 0;
-    pthread_mutex_unlock (&priv.mutex);
-
-    pthread_join (priv.comm_thread, (void*)&status);
-    pthread_mutex_destroy (&priv.mutex);;
-  }
-
-  return 0;
-}
diff --git a/src/core/npu-engine/ip/meson.build b/src/core/npu-engine/ip/meson.build
deleted file mode 100644 (file)
index 1cf0934..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-plugin_ip_sources = []
-plugin_ip_common_sources = ['plugin-ip-comm.c']
-
-foreach s : plugin_ip_common_sources
-  plugin_ip_sources += join_paths(meson.current_source_dir(), s)
-endforeach
-
-# Declare dependency
-plugin_ip_src_dep = declare_dependency(
-  sources : plugin_ip_sources,
-  include_directories: [ne_common_inc, ne_host_inc, npu_engine_inc]
-)
diff --git a/src/core/npu-engine/meson.build b/src/core/npu-engine/meson.build
deleted file mode 100644 (file)
index c003fa7..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-npu_engine_sources = []
-
-# Dependencies
-npu_engine_dependencies = [
-  libm_dep,
-  thread_dep,
-  libutils_dep,
-  libnpucore_dep,
-  libgem_dep
-]
-
-# Sources
-npu_engine_common_sources = [
-  'ne-host-input-service.c',
-  'ne-handler.c',
-  'ne-scheduler.c',
-  'ne-inf.c',
-  'ne-mem.c',
-]
-
-# Headers
-npu_engine_inc = include_directories('.')
-
-foreach s : npu_engine_common_sources
-  npu_engine_sources += join_paths(meson.current_source_dir(), s)
-endforeach
-
-comm_opt = get_option('comm_opt')
-
-# Build executable
-if comm_opt == 'fm'
-  subdir('fm')
-  npu_engine_dependencies += [plugin_fm_dep]
-  # Declare dependency
-  npu_engine_dep = declare_dependency(
-      sources : npu_engine_common_sources,
-      include_directories : ne_common_inc,
-      dependencies : npu_engine_dependencies
-  )
-
-  npu_engine_executable = executable('npu-engine-test',
-    sources : join_paths(meson.current_source_dir(), 'main.c'),
-    include_directories : ne_common_inc,
-    dependencies : npu_engine_dependencies)
-
-else # ip comm
-  subdir('ip')
-  npu_engine_dependencies += [plugin_ip_src_dep]
-
-  npu_engine_build = static_library('npu-engine-common',
-    npu_engine_sources,
-    include_directories : ne_common_inc,
-    dependencies: npu_engine_dependencies,
-    install : false)
-
-  # Declare dependency for other modules
-  npu_engine_dep = declare_dependency(link_with : npu_engine_build,
-    include_directories : [ne_common_inc, npu_engine_inc],
-    dependencies : npu_engine_dependencies)
-endif
diff --git a/src/core/npu-engine/usb/meson.build b/src/core/npu-engine/usb/meson.build
deleted file mode 100644 (file)
index 6607342..0000000
+++ /dev/null
@@ -1 +0,0 @@
-# DO NOTHING, YET
diff --git a/src/core/npu/meson.build b/src/core/npu/meson.build
new file mode 100644 (file)
index 0000000..8225a19
--- /dev/null
@@ -0,0 +1,6 @@
+ne_core_npu_inc = include_directories('.')
+ne_core_npu_src = ['NPUdrvAPI.c']
+ne_core_npu_dep = declare_dependency(
+  sources : ne_core_npu_src,
+  dependencies : ne_core_utils_dep,
+  include_directories : [ne_common_inc, ne_core_npu_inc])
index 2a5ddb4..8cf91da 100644 (file)
@@ -1,2 +1,5 @@
+## This is not used in the current design (i.e., NPU-IP).
+## The function in libnpuhost are implemented in /src/core/ip/plugin-comm-ip.c
+
 libnpuhost_inc = include_directories('.')
 libnpuhost_dep = declare_dependency(include_directories: libnpuhost_inc)
index 7a39a98..ee5139f 100644 (file)
@@ -1 +1,3 @@
 subdir('libnpuhost')
+
+ne_host_dep = [libnpuhost_dep]
index 31c349f..dc9ed8d 100644 (file)
@@ -1,3 +1,23 @@
 subdir('core')
 subdir('host')
+
+# Final dependencies
+ne_dependencies = [
+  ne_core_dep,
+  ne_host_dep    # not used yet
+]
+
+# Build library
+ne_library_static = static_library('npu-engine',
+  include_directories : ne_common_inc,
+  dependencies: ne_dependencies,
+  install : true,
+  install_dir : ne_libdir)
+ne_library_shared = shared_library('npu-engine',
+  include_directories : ne_common_inc,
+  dependencies: ne_dependencies,
+  install : true,
+  install_dir : ne_libdir)
+
+# Build tests
 subdir('test')
diff --git a/src/test/apptests/meson.build b/src/test/apptests/meson.build
new file mode 100644 (file)
index 0000000..5a253c8
--- /dev/null
@@ -0,0 +1 @@
+## For app tests, make build executables which links with 'ne_library_shared'
index e509787..7d5fe4d 100644 (file)
@@ -1,62 +1,2 @@
-# C++ may be enabled inside test because this is not supposed to be installed in NPU-Core machine for deployment.
-# However, try not to contaminate other parts of core with C++ dependencies.
-
-add_languages('cpp')
-
-gtest_dep = dependency('gtest', required: false)
-if gtest_dep.found()
-  libgem_unittest_deps = [
-    libgem_dep,
-    gtest_dep
-  ]
-
-  unittest_libgem = executable('unittest_libgem',
-    ['libgem_test.cpp'],
-    dependencies: [libgem_unittest_deps],
-    cpp_args : '-std=c++11',
-    install : true,
-    install_dir : join_paths(ne_bindir, 'unittests')
-  )
-
- test('unittest_libgem', unittest_libgem)
-
-  libnpu_unittest_deps = [
-    libnpucore_dep,
-    gtest_dep
-  ]
-
-  unittest_libnpu = executable('unittest_libnpu',
-    ['npu_api_test.cpp'],
-    dependencies: [libnpu_unittest_deps],
-    cpp_args : '-std=c++11',
-    install : true,
-    install_dir : join_paths(ne_bindir, 'unittests')
-  )
-
-  test('unittest_libnpu', unittest_libnpu)
-
-  npu_engine_unittest_deps = [
-    npu_engine_dep,
-    gtest_dep
-  ]
-
-  unittest_ne_mem = executable('unittest_ne_mem',
-    ['ne_mem_test.cpp'],
-    dependencies: [npu_engine_unittest_deps],
-    cpp_args : '-std=c++11',
-    install : true,
-    install_dir : join_paths(ne_bindir, 'unittests')
-  )
-
-  test('unittest_ne_mem', unittest_ne_mem)
-
-  unittest_ne_utils = executable('unittest_ne_utils',
-    ['ne_utils_test.cpp'],
-    dependencies: [npu_engine_unittest_deps],
-    cpp_args : '-std=c++11',
-    install : true,
-    install_dir : join_paths(ne_bindir, 'unittests')
-  )
-
-  test('unittest_ne_utils', unittest_ne_utils)
-endif
+subdir('unittests')
+subdir('apptests')
diff --git a/src/test/unittests/meson.build b/src/test/unittests/meson.build
new file mode 100644 (file)
index 0000000..907f75b
--- /dev/null
@@ -0,0 +1,67 @@
+# C++ may be enabled inside test because this is not supposed to be installed in NPU-Core machine for deployment.
+# However, try not to contaminate other parts of core with C++ dependencies.
+
+add_languages('cpp')
+
+gtest_dep = dependency('gtest', required: false)
+if gtest_dep.found()
+  ne_core_gem_unittest_deps = [
+    ne_core_gem_dep,
+    gtest_dep
+  ]
+
+  unittest_ne_core_gem = executable('unittest_ne_core_gem',
+    ['ne_core_gem_test.cpp'],
+    dependencies: [ne_core_gem_unittest_deps],
+    cpp_args : '-std=c++11',
+    install : true,
+    install_dir : join_paths(ne_bindir, 'unittests')
+  )
+
+  test('unittest_ne_core_gem', unittest_ne_core_gem)
+
+  ne_core_npu_unittest_deps = [
+    ne_core_npu_dep,
+    gtest_dep
+  ]
+
+  unittest_ne_core_npu = executable('unittest_ne_core_npu',
+    ['ne_core_npu_test.cpp'],
+    dependencies: [ne_core_npu_unittest_deps],
+    cpp_args : '-std=c++11',
+    install : true,
+    install_dir : join_paths(ne_bindir, 'unittests')
+  )
+
+  test('unittest_ne_core_npu', unittest_ne_core_npu)
+
+  ne_core_utils_unittest_deps = [
+    ne_core_utils_dep,
+    gtest_dep
+  ]
+
+  unittest_ne_core_utils = executable('unittest_ne_core_utils',
+    ['ne_core_utils_test.cpp'],
+    dependencies: [ne_core_utils_unittest_deps],
+    cpp_args : '-std=c++11',
+    install : true,
+    install_dir : join_paths(ne_bindir, 'unittests')
+  )
+
+  test('unittest_ne_core_utils', unittest_ne_core_utils)
+
+  ne_core_unittest_deps = [
+    ne_core_dep,
+    gtest_dep
+  ]
+
+  unittest_ne_core_mem = executable('unittest_ne_core_mem',
+    ['ne_core_mem_test.cpp'],
+    dependencies: [ne_core_unittest_deps],
+    cpp_args : '-std=c++11',
+    install : true,
+    install_dir : join_paths(ne_bindir, 'unittests')
+  )
+
+  test('unittest_ne_core_mem', unittest_ne_core_mem)
+endif
similarity index 94%
rename from src/test/libgem_test.cpp
rename to src/test/unittests/ne_core_gem_test.cpp
index 1a9011e..4abe74f 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2019 Dongju Chae <dongju.chae@samsung.com>
  */
 /**
- * @file libgem_test.cpp
+ * @file ne_core_gem_test.cpp
  * @date 30 Jun 2019
  * @brief UnitTests to test functions in libgem-core
  * @author Dongju Chae <dongju.chae@samsung.com>
@@ -26,7 +26,7 @@ extern "C"
 /**
  * @brief subtest function testing 'gem_open'
  */
-TEST (test_gem, open) 
+TEST (ne_core_gem_test, open) 
 {
   int fd = gem_open(GEM_NAME);
 
@@ -41,7 +41,7 @@ TEST (test_gem, open)
 /**
  * @brief subtest function testing 'gem_create/destroy'
  */
-TEST (test_gem, create) 
+TEST (ne_core_gem_test, create) 
 {
   int fd = gem_open(GEM_NAME);
   uint32_t size;
@@ -70,7 +70,7 @@ TEST (test_gem, create)
 /**
  * @brief subtest function testing 'gem_mmap'
  */
-TEST (test_gem, mmap) 
+TEST (ne_core_gem_test, mmap) 
 {
   uint32_t handle, size, page;
   uint32_t *ptr;
@@ -100,7 +100,7 @@ TEST (test_gem, mmap)
 /**
  * @brief subtest function testing to export a gem buffer and mmap for dmabuf
  */
-TEST (test_gem, export_dmabuf)
+TEST (ne_core_gem_test, export_dmabuf)
 {
   uint32_t handle, size, page;
   uint32_t *ptr;
similarity index 98%
rename from src/test/ne_mem_test.cpp
rename to src/test/unittests/ne_core_mem_test.cpp
index 44783ef..9f3c812 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2019 Dongju Chae <dongju.chae@samsung.com>
  */
 /**
- * @file ne_mem_tests.cpp
+ * @file ne_core_mem_test.cpp
  * @date 30 Jun 2019
  * @brief UnitTests to test functions in memory allocator for NPU Engine
  * @author Dongju Chae <dongju.chae@samsung.com>
@@ -33,7 +33,7 @@ extern "C"
  * @brief register NPU model
  * @detail The memory size of model and I/O buffer will be provided as arguments
  */
-TEST (test_mem, register_model)
+TEST (ne_core_mem_test, register_model)
 {
   mem *mem = GET_MEM ();
   hwmem *hwmem;
@@ -60,7 +60,7 @@ TEST (test_mem, register_model)
 /**
  * @brief prepare input buffer
  */
-TEST (test_mem, prepare_input)
+TEST (ne_core_mem_test, prepare_input)
 {
   mem *mem = GET_MEM ();
   buffer *buffer;
@@ -101,7 +101,7 @@ TEST (test_mem, prepare_input)
 /**
  * @brief when output is ready (in a syncronized manner)
  */
-TEST (test_mem, output_ready)
+TEST (ne_core_mem_test, output_ready)
 {
   mem *mem = GET_MEM ();
   buffer *buffer;
@@ -249,7 +249,7 @@ output_thread (void* data)
 /**
  * @brief running in parallel with fork()
  */
-TEST (test_mem, running_parallel)
+TEST (ne_core_mem_test, running_parallel)
 {
   mem *mem = GET_MEM ();
   uint64_t size_out, size_in = 1 * M;
@@ -275,7 +275,7 @@ TEST (test_mem, running_parallel)
 /**
  * @brief test for memory compaction
  */
-TEST (test_mem, memory_compaction)
+TEST (ne_core_mem_test, memory_compaction)
 {
   mem *mem = GET_MEM ();
   hwmem *hwmem[6];
@@ -393,7 +393,7 @@ get_buffer_wait_thread (void *data)
 /**
  * @brief test handling input priorities and synchronization for memory
  */
-TEST (test_mem, get_next_buffer_modes)
+TEST (ne_core_mem_test, get_next_buffer_modes)
 {
   mem *mem = GET_MEM ();
   buffer *buffer1, *buffer2;
similarity index 96%
rename from src/test/npu_api_test.cpp
rename to src/test/unittests/ne_core_npu_test.cpp
index 4c6d2fa..be76677 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2019 Parichay Kapoor <pk.kapoor@samsung.com>
  */
 /**
- * @file npu_api_test.cpp
+ * @file ne_core_npu_test.cpp
  * @date 24 Jul 2019
  * @brief Test npu driver api
  * @author Parichay Kapoor <pk.kapoor@samsung.com>
@@ -30,7 +30,7 @@ extern "C"
 /**
  * @brief base open and close a device
  */
-TEST (npu_api, dev_open_close)
+TEST (ne_core_npu_test, dev_open_close)
 {
   int fd;
   int ret;
@@ -80,7 +80,7 @@ TEST (npu_api, dev_open_close)
 /**
  * @brief set data in the device
  */
-TEST (npu_api, set_dev_data)
+TEST (ne_core_npu_test, set_dev_data)
 {
   int fd = 1;
   int ret;
@@ -139,7 +139,7 @@ TEST (npu_api, set_dev_data)
 /**
  * @brief check device statuses
  */
-TEST (npu_api, check_dev_status)
+TEST (ne_core_npu_test, check_dev_status)
 {
   int fd = 1;
   int ret;
similarity index 95%
rename from src/test/ne_utils_test.cpp
rename to src/test/unittests/ne_core_utils_test.cpp
index fc89df1..b06e191 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2019 Dongju Chae <dongju.chae@samsung.com>
  */
 /**
- * @file ne_utils_tests.cpp
+ * @file ne_core_utils_test.cpp
  * @date 30 Jun 2019
  * @brief UnitTests to test functions in utility for NPU Engine
  * @author Dongju Chae <dongju.chae@samsung.com>
@@ -33,7 +33,7 @@ typedef struct _test_elem {
 /**
  * @brief It tests the functionality of a linked list
  */
-TEST (test_ne_utils, linked_list)
+TEST (ne_core_utils_test, linked_list)
 {
   test_elem *elem, *tmp;
   list test_list;
@@ -76,7 +76,7 @@ TEST (test_ne_utils, linked_list)
 /**
  * @brief test functionality of a hash table
  */
-TEST (test_ne_utils, hash_table)
+TEST (ne_core_utils_test, hash_table)
 {
   test_elem *elem, *tmp;
   hash_table test_ht;