[Build] revise meson files to make a single project
authorParichay Kapoor <pk.kapoor@samsung.com>
Fri, 26 Jul 2019 06:04:16 +0000 (15:04 +0900)
committer채동주/On-Device Lab(SR)/Staff Engineer/삼성전자 <dongju.chae@samsung.com>
Mon, 29 Jul 2019 06:29:03 +0000 (15:29 +0900)
merge core and host into a single project
npu-engine final .so with interface of libnpuhost.h in ip comm mode only
libnpuhost.h and npu-engine interface to be done by N11 (plugin-ip-comm.c)
npu-engine exe build only in fast model mode
include common dir for header properly

Working on issue #114

Signed-off-by: Parichay Kapoor <pk.kapoor@samsung.com>
12 files changed:
core/libnpu-core/meson.build
core/meson.build
core/meson_options.txt [deleted file]
core/npu-engine/src/ip/meson.build
core/npu-engine/src/ip/plugin-ip-comm.c [new file with mode: 0644]
core/npu-engine/src/meson.build
core/npu-engine/src/usb/README.md [deleted file]
host/libnpuhost/include/libnpuhost.h
host/libnpuhost/meson.build
host/meson.build
meson.build [new file with mode: 0644]
meson_options.txt [new file with mode: 0644]

index 347d633..731b883 100644 (file)
@@ -1,4 +1,7 @@
-libnpu_inc = include_directories('include')
+libnpu_inc = [
+  ne_includedir,
+  include_directories('include'),
+]
 libnpu_sources = ['src/NPUdrvAPI.c']
 
 # Build library (static)
index e0366ad..5073779 100644 (file)
@@ -1,51 +1,4 @@
-# Do NOT enable C in core
-# C++ is only allowed inside test directory for gtest.
-
-project('npu-engine', 'c',
-  version: '0.0.1',
-  license: ['Proprietary'],
-  meson_version: '>=0.42.0',
-  default_options: [
-    'werror=true',
-    'warning_level=1',
-    'c_std=gnu89',
-  ]
-)
-
-add_project_arguments('-DVERSION="' + meson.project_version() + '"', language: ['c'])
-
-cc = meson.get_compiler('c')
-
-warning_c_flags = [
-  '-Wmissing-declarations',
-  '-Wmissing-prototypes',
-  '-Wnested-externs',
-  '-Waggregate-return',
-  '-Wold-style-definition',
-  '-Wdeclaration-after-statement'
-]
-
-foreach extra_arg : warning_c_flags
-  if cc.has_argument (extra_arg)
-    add_project_arguments([extra_arg], language: 'c')
-  endif
-endforeach
-
-# Install Paths
-ne_prefix = get_option('prefix')
-ne_libdir = join_paths(ne_prefix, get_option('libdir'))
-ne_bindir = join_paths(ne_prefix, get_option('bindir'))
-ne_includedir = join_paths(ne_prefix, get_option('includedir'))
-ne_inidir = get_option('sysconfdir')
-
-libdl_dep = cc.find_library('dl') # DL library
-libm_dep = cc.find_library('m') # math library
-libdrm_dep = dependency('libdrm') # libdrm library
-thread_dep = dependency('threads') # pthread library
-iniparser_dep = dependency('iniparser') # iniparser library
-
 subdir('libgem-core')
 subdir('libnpu-core')
 subdir('npu-engine')
-
 subdir('test')
diff --git a/core/meson_options.txt b/core/meson_options.txt
deleted file mode 100644 (file)
index 78ae76f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-option('comm_opt', type : 'combo', choices : ['usb', 'ip', 'fm'], value : 'fm')
index 6607342..e01e2ee 100644 (file)
@@ -1 +1,16 @@
-# DO NOTHING, YET
+plugin_ip_inc = [
+  ne_includedir,
+  npu_host_inc,
+]
+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: plugin_ip_inc)
diff --git a/core/npu-engine/src/ip/plugin-ip-comm.c b/core/npu-engine/src/ip/plugin-ip-comm.c
new file mode 100644 (file)
index 0000000..5f2053c
--- /dev/null
@@ -0,0 +1,19 @@
+/**
+ * Proprietary
+ * Copyright (C) 2019 Samsung Electronics
+ * Copyright (C) 2019 MyungJoo Ham <myungjoo.ham@samsung.com>
+ * Copyright (C) 2019 Parichay Kapoor <pk.kapoor@samsung.com>
+ */
+/**
+ * @file plugin-ip-comm.c
+ * @date 26 Jul 2019
+ * @brief Implement API to access NPU from Host
+ * @see http://suprem.sec.samsung.net/confluence/display/ODLC/Software+Stack
+ * @author MyungJoo Ham <myungjoo.ham@samsung.com>
+ * @author Parichay Kapoor <pk.kapoor@samsung.com>
+ * @bug No known bugs except for NYI items
+ *
+ * To packagers: this is exported to HOST PROGRAMMERS as a devel package.
+ */
+
+#include <libnpuhost.h>
index 2b1ed9f..c0f42f4 100644 (file)
@@ -1,4 +1,7 @@
-npu_engine_inc = include_directories('.', '../../../common/include')
+npu_engine_inc = [
+  ne_includedir,
+  include_directories('.'),
+]
 npu_engine_sources = []
 
 # Dependencies
@@ -28,8 +31,7 @@ endforeach
 # Plugins
 npu_engine_plugins = [
   'ip',
-  'usb',
-  'fm'
+# 'fm',
 ]
 
 foreach p : npu_engine_plugins
@@ -37,23 +39,28 @@ foreach p : npu_engine_plugins
 endforeach
 
 comm_opt = get_option('comm_opt')
-if comm_opt == 'usb'
-  npu_engine_dependencies += plugin_usb_dep
-elif comm_opt == 'ip'
-  npu_engine_dependencies += plugin_ip_dep
-else # fastmodel
-  npu_engine_dependencies += plugin_fm_dep
-endif
-
-# Declare dependency
-npu_engine_dep = declare_dependency(
-  sources : npu_engine_common_sources,
-  dependencies: npu_engine_dependencies,
-  include_directories: npu_engine_inc)
 
 # Build executable
-npu_engine_executable = executable('npu-engine',
-  join_paths(meson.current_source_dir(), 'main.c'),
-  dependencies: npu_engine_dep,
-  include_directories: npu_engine_inc,
-)
+if comm_opt == 'fm'
+  # Declare dependency
+  npu_engine_dep = declare_dependency(
+      sources : npu_engine_common_sources,
+      dependencies: npu_engine_dependencies,
+      include_directories: npu_engine_inc)
+# npu_engine_dependencies += plugin_fm_dep
+
+  npu_engine_executable = executable('npu-engine-test',
+    sources : join_paths(meson.current_source_dir(), 'main.c'),
+    dependencies : npu_engine_dep,
+    include_directories: npu_engine_inc)
+else # ip comm
+  npu_engine_build = static_library('npu-engine-common',
+    npu_engine_sources,
+    include_directories : npu_engine_inc,
+    dependencies : npu_engine_dependencies,
+    install : false)
+
+  # Declare dependency for other modules
+  npu_engine_dep = declare_dependency(link_with : npu_engine_build,
+    include_directories: npu_engine_inc)
+endif
diff --git a/core/npu-engine/src/usb/README.md b/core/npu-engine/src/usb/README.md
deleted file mode 100644 (file)
index e69de29..0000000
index 53b216b..20a74e2 100644 (file)
@@ -22,7 +22,7 @@
 #define __NPU_HOST_LIBNPUHOST_H__
 
 #include <stdint.h>
-#include "../../../common/include/typedef.h"
+#include <typedef.h>
 
 /* NNstreamer/GStreamer supports up to 16 bufs */
 #define NPU_TENSOR_CARDINALITY_MAX     (16)
@@ -58,7 +58,7 @@ typedef void *npudev_h;
  * @return @c The number of NPU devices.
  * @retval 0 if no NPU devices available. if positive (number of NPUs) if NPU devices available. otherwise, a negative error value.
  */
-int getnumNPUdevice();
+int getnumNPUdevice(void);
 
 /**
  * @brief Returns the handle of the chosen NPU devices.
@@ -178,9 +178,8 @@ int runNPU_sync(npudev_h dev, uint32_t modelid, const input_buffers *input,
  *         Approach 2: thread pooling for callback invocation.
  *         Approach 3: 1 + 2.
  */
-typedef void (*callback) (output_buffer *output, uint64_t sequence,
-    void *data)
-    npuOutputNotify;
+typedef void (*npuOutputNotify) (output_buffer *output, uint64_t sequence,
+    void *data);
 
 /**
  * @brief Let NPU accept input frames from its internal source continuously
@@ -214,14 +213,14 @@ typedef enum {
  * @param[in] mode Configures how this operation works.
  * @return @c 0 if no error. otherwise a negative error value
  */
-int runNPU_async(npudev_h dev, uint32_t modelid, const npu_tensors *input,
+int runNPU_async(npudev_h dev, uint32_t modelid, const input_buffers *input,
     npuOutputNotify *cb, uint64_t *sequence, void *data,
     npu_async_mode mode);
 
 /** Optional Features. May be left unimplemented until later versions */
 /** @todo func prototype TBD. This does not use callback. */
-int runNPU_async_noalloc(npudev_h dev, uint32_t modelid, const npu_tensors *input,
-    npu_tensors *output, uint64_t *sequence, npu_async_mode mode);
+int runNPU_async_noalloc(npudev_h dev, uint32_t modelid, const input_buffers *input,
+    output_buffer *output, uint64_t *sequence, npu_async_mode mode);
 
 /** @todo func prototype TBD */
 int getRegisteredNPUmodels(npudev_h dev, uint32_t **modelids, uint32_t *nummodels);
index 6607342..15882a5 100644 (file)
@@ -1 +1 @@
-# DO NOTHING, YET
+npu_host_inc = include_directories('include')
index e8237ff..1f28b91 100644 (file)
@@ -1,40 +1,2 @@
-project('npu-host', 'c',
-  version: '0.0.1',
-  license: ['Proprietary'],
-  meson_version: '>=0.42.0',
-  default_options: [
-    'werror=true',
-    'warning_level=1',
-    'c_std=gnu89',
-  ]
-)
-
-add_project_arguments('-DVERSION="' + meson.project_version() + '"', language: ['c'])
-
-cc = meson.get_compiler('c')
-
-warning_c_flags = [
-  '-Wmissing-declarations',
-  '-Wmissing-prototypes',
-  '-Wnested-externs',
-  '-Waggregate-return',
-  '-Wold-style-definition',
-  '-Wdeclaration-after-statement'
-]
-
-foreach extra_arg : warning_c_flags
-  if cc.has_argument (extra_arg)
-    add_project_arguments([extra_arg], language: 'c')
-  endif
-endforeach
-
-# Install Paths
-nh_prefix = get_option('prefix')
-nh_libdir = join_paths(nh_prefix, get_option('libdir'))
-nh_bindir = join_paths(nh_prefix, get_option('bindir'))
-nh_includedir = join_paths(nh_prefix, get_option('includedir'))
-nh_inidir = get_option('sysconfdir')
-
 subdir('libnpuhost')
-
 subdir('test')
diff --git a/meson.build b/meson.build
new file mode 100644 (file)
index 0000000..a1669f2
--- /dev/null
@@ -0,0 +1,65 @@
+# Do NOT enable C in core
+# C++ is only allowed inside test directory for gtest.
+
+project('npu-engine', 'c',
+  version: '0.0.1',
+  license: ['Proprietary'],
+  meson_version: '>=0.42.0',
+  default_options: [
+    'werror=true',
+    'warning_level=1',
+    'c_std=gnu89',
+  ]
+)
+
+add_project_arguments('-DVERSION="' + meson.project_version() + '"', language: ['c'])
+
+cc = meson.get_compiler('c')
+
+warning_c_flags = [
+  '-Wmissing-declarations',
+  '-Wmissing-prototypes',
+  '-Wnested-externs',
+  '-Waggregate-return',
+  '-Wold-style-definition',
+  '-Wdeclaration-after-statement'
+]
+
+foreach extra_arg : warning_c_flags
+  if cc.has_argument (extra_arg)
+    add_project_arguments([extra_arg], language: 'c')
+  endif
+endforeach
+
+# Install Paths
+ne_prefix = get_option('prefix')
+ne_libdir = join_paths(ne_prefix, get_option('libdir'))
+ne_bindir = join_paths(ne_prefix, get_option('bindir'))
+ne_includedir = [
+  join_paths(ne_prefix, get_option('includedir')),
+  include_directories('common/include')
+]
+ne_inidir = get_option('sysconfdir')
+
+libdl_dep = cc.find_library('dl') # DL library
+libm_dep = cc.find_library('m') # math library
+libdrm_dep = dependency('libdrm') # libdrm library
+thread_dep = dependency('threads') # pthread library
+iniparser_dep = dependency('iniparser') # iniparser library
+
+subdir('host')
+subdir('core')
+
+comm_opt = get_option('comm_opt')
+
+if comm_opt == 'ip'
+  ne_dependencies = [
+    npu_engine_dep,
+    plugin_ip_src_dep
+  ]
+
+  # Build final exported so
+  plugin_ip_executable = shared_library('npu-engine',
+    dependencies: ne_dependencies,
+    install : false)
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644 (file)
index 0000000..69e82b8
--- /dev/null
@@ -0,0 +1 @@
+option('comm_opt', type : 'combo', choices : ['ip', 'fm'], value : 'ip')