[VD/NPUMGR] Add tizen-npumanager dependency
authorDongju Chae <dongju.chae@samsung.com>
Fri, 11 Jun 2021 05:33:28 +0000 (14:33 +0900)
committer채동주/On-Device Lab(SR)/Staff Engineer/삼성전자 <dongju.chae@samsung.com>
Mon, 14 Jun 2021 01:25:03 +0000 (10:25 +0900)
This patch adds tizen-npumanager dependency.

It's used only when 'vd_npumgr' option is provided.
Otherwise, dummy npumgr module is used.

Signed-off-by: Dongju Chae <dongju.chae@samsung.com>
13 files changed:
meson_options.txt
packaging/npu-engine.spec
tests/apptests/npumgr/dummy/meson.build [new file with mode: 0644]
tests/apptests/npumgr/dummy/npumgr.cc [moved from tests/apptests/npumgr/npumgr.cc with 100% similarity]
tests/apptests/npumgr/dummy/npumgr_api.cc [moved from tests/apptests/npumgr/npumgr_api.cc with 99% similarity]
tests/apptests/npumgr/dummy/npumgr_api.h [moved from tests/apptests/npumgr/npumgr_api.h with 100% similarity]
tests/apptests/npumgr/dummy/npumgr_device.cc [moved from tests/apptests/npumgr/npumgr_device.cc with 100% similarity]
tests/apptests/npumgr/dummy/npumgr_device.h [moved from tests/apptests/npumgr/npumgr_device.h with 100% similarity]
tests/apptests/npumgr/dummy/npumgr_triv2.cc [moved from tests/apptests/npumgr/npumgr_triv2.cc with 100% similarity]
tests/apptests/npumgr/dummy/npumgr_triv2.h [moved from tests/apptests/npumgr/npumgr_triv2.h with 100% similarity]
tests/apptests/npumgr/dummy/sr.odl.NPUManager.conf [moved from tests/apptests/npumgr/sr.odl.NPUManager.conf with 100% similarity]
tests/apptests/npumgr/meson.build
tests/apptests/npumgr/npumgr_test.cc

index 10e1713..d496c97 100644 (file)
@@ -9,4 +9,5 @@ option('target_platform', type : 'combo', choices : ['debian', 'tizen', 'fpga'],
 option('enable_npu_emul', type : 'boolean', value : false)
 option('enable_data_manip', type : 'boolean', value : false)
 option('enable_buffering', type : 'boolean', value : false)
+option('enable_vd_npumgr', type : 'boolean', value : false)
 option('kernel_hdr_dir', type : 'string', value : '')
index c1e8e46..179d65d 100644 (file)
@@ -39,6 +39,13 @@ BuildRequires:  libmrpsim-devel
 %define enable_npu_emul -Denable_npu_emul=false
 %endif
 
+%if 0%{?vd_npumgr}
+BuildRequires:  tizen-npumanager-devel
+%define enable_vd_npumgr -Denable_vd_npumgr=true
+%else
+%define enable_vd_npumgr -Denable_vd_npumgr=false
+%endif
+
 %global debug_package %{nil}
 %global __debug_install_post %{nil}
 
@@ -53,7 +60,8 @@ cp %{SOURCE1001} .
 meson --buildtype=plain --bindir=%{neexampledir} --prefix=%{_prefix} \
       --libdir=%{_libdir} --includedir=%{_includedir} \
       --datadir=%{_datadir} --sysconfdir=%{_sysconfdir} \
-      -Dtarget_platform=tizen -Denable_data_manip=true %{enable_npu_emul} \
+      -Dtarget_platform=tizen -Denable_data_manip=true \
+      %{enable_npu_emul} %{enable_vd_npumgr} \
       build
 ninja -C build %{?_smp_mflags}
 
diff --git a/tests/apptests/npumgr/dummy/meson.build b/tests/apptests/npumgr/dummy/meson.build
new file mode 100644 (file)
index 0000000..acad147
--- /dev/null
@@ -0,0 +1,49 @@
+# Note that VD NPU Manager is a gdbus-based thread application
+gmodule_dep = dependency('gmodule-2.0', required: false)
+giounix_dep = dependency('gio-unix-2.0', required: false)
+if gmodule_dep.found() and giounix_dep.found()
+  npumgr_deps = [
+    glib_dep,
+    gmodule_dep,
+    giounix_dep
+  ]
+
+  if target_platform == 'tizen'
+    npumgr_deps += dependency('dlog')
+  endif
+
+  npumgr_lib = shared_library ('npumgr',
+    'npumgr_api.cc',
+    dependencies: npumgr_deps,
+    build_rpath : ne_libdir,
+    install : true,
+    install_rpath : ne_libdir,
+    install_dir : ne_libdir
+  )
+  npumgr_dep = declare_dependency (link_with : npumgr_lib,
+    include_directories : include_directories('.')
+  )
+
+  npumgr_triv2_lib = shared_library ('npumgr_triv2',
+    ['npumgr_triv2.cc', 'npumgr_device.cc'],
+    include_directories : [ne_common_inc, ne_host_inc],
+    dependencies: npumgr_deps,
+    link_with : ne_library_shared,
+    build_rpath : ne_libdir,
+    install : true,
+    install_rpath : ne_libdir,
+    install_dir : ne_libdir
+  )
+
+  executable ('dummy_npumgr',
+    ['npumgr.cc', 'npumgr_device.cc'],
+    dependencies: npumgr_deps,
+    install : true,
+    install_rpath : ne_libdir,
+    install_dir : join_paths(ne_bindir, 'apptests', 'npumgr')
+  )
+
+  install_data ('sr.odl.NPUManager.conf',
+    install_dir: join_paths(get_option('datadir'), 'dbus-1', 'system.d')
+  )
+endif
similarity index 99%
rename from tests/apptests/npumgr/npumgr_api.cc
rename to tests/apptests/npumgr/dummy/npumgr_api.cc
index 61eb2cc..a37d139 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 #include "npumgr_api.h"
-#include "npumgr_common.h"
+#include "../npumgr_common.h"
 
 #include <stdio.h>
 #include <stdlib.h>
index fa2340b..b97ad88 100644 (file)
@@ -1,56 +1,19 @@
-# Note that VD NPU Manager is a gdbus-based thread application
 glib_dep = dependency('glib-2.0', required: false)
-gmodule_dep = dependency('gmodule-2.0', required: false)
-giounix_dep = dependency('gio-unix-2.0', required: false)
-if glib_dep.found() and giounix_dep.found()
-  npumgr_deps = [
-    glib_dep,
-    gmodule_dep,
-    giounix_dep
-  ]
-
-  if target_platform == 'tizen'
-    npumgr_deps += dependency('dlog')
+if glib_dep.found()
+  if get_option('enable_vd_npumgr')
+    # vd npu manager
+    npumgr_dep = dependency('tizen-npumanager')
+  else
+    # dummy npu manager
+    subdir('dummy')
   endif
 
-  npumgr_lib = shared_library ('npumgr',
-    'npumgr_api.cc',
-    dependencies: npumgr_deps,
-    build_rpath : ne_libdir,
-    install : true,
-    install_rpath : ne_libdir,
-    install_dir : ne_libdir
-  )
-
-  npumgr_triv2_lib = shared_library ('npumgr_triv2',
-    ['npumgr_triv2.cc', 'npumgr_device.cc'],
-    include_directories : [ne_common_inc, ne_host_inc],
-    dependencies: npumgr_deps,
-    link_with : ne_library_shared,
-    build_rpath : ne_libdir,
-    install : true,
-    install_rpath : ne_libdir,
-    install_dir : ne_libdir
-  )
-
+  # npu manager test program
   executable ('apptest_npumgr',
     'npumgr_test.cc',
-    dependencies : [glib_dep, ne_test_utils_common_dep],
-    link_with : npumgr_lib,
-    install : true,
-    install_rpath : ne_libdir,
-    install_dir : join_paths(ne_bindir, 'apptests', 'npumgr')
-  )
-
-  executable ('dummy_npumgr',
-    ['npumgr.cc', 'npumgr_device.cc'],
-    dependencies: npumgr_deps,
+    dependencies : [glib_dep, ne_test_utils_common_dep, npumgr_dep],
     install : true,
     install_rpath : ne_libdir,
     install_dir : join_paths(ne_bindir, 'apptests', 'npumgr')
   )
-
-  install_data ('sr.odl.NPUManager.conf',
-    install_dir: join_paths(get_option('datadir'), 'dbus-1', 'system.d')
-  )
 endif
index ab68896..8b7ddbd 100644 (file)
@@ -19,7 +19,7 @@
 #include <glib.h>
 #include <ne_test_utils_common.h>
 
-#include "npumgr_api.h"
+#include <npumgr_api.h>
 #include "npumgr_common.h"
 
 using namespace std;