[Packaging] Remove the libnpuvision dependency for release mode
authorDongju Chae <dongju.chae@samsung.com>
Tue, 19 Nov 2019 07:24:19 +0000 (16:24 +0900)
committer송욱/On-Device Lab(SR)/Staff Engineer/삼성전자 <wook16.song@samsung.com>
Fri, 22 Nov 2019 07:24:14 +0000 (16:24 +0900)
This commit removes the libnpuvision dependency for release mode.

Signed-off-by: Dongju Chae <dongju.chae@samsung.com>
debian/rules
meson.build
meson_options.txt
packaging/npu-engine.spec
src/core/npu/NPUemul.cpp
src/core/npu/meson.build

index 872c851..4467aee 100755 (executable)
@@ -24,7 +24,7 @@ override_dh_auto_clean:
        rm -rf build
 
 override_dh_auto_configure:
-       PKG_CONFIG_PATH=${NPU_TRINITY_INSTALL_PREFIX}/lib/pkgconfig meson --buildtype=plain --prefix=$(NPU_TRINITY_INSTALL_PREFIX) --sysconfdir=/etc --libdir=lib --bindir=bin --includedir=include build -Dbuild_test_only_mode=true
+       PKG_CONFIG_PATH=${NPU_TRINITY_INSTALL_PREFIX}/lib/pkgconfig meson --buildtype=plain --prefix=$(NPU_TRINITY_INSTALL_PREFIX) --sysconfdir=/etc --libdir=lib --bindir=bin --includedir=include build -Denable_npu_emul=true
 
 override_dh_auto_build:
        ninja -C build
index a0e91bd..dcb8839 100644 (file)
@@ -48,13 +48,14 @@ 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
-npuvision_dep = dependency('libnpuvision') # npuvision library
 
-if get_option('build_test_only_mode')
+if get_option('enable_npu_emul')
+  npuvision_dep = dependency('libnpuvision') # npuvision library
+
   add_project_arguments('-I/opt/trinity/include', language: 'c')
   add_project_arguments('-I/opt/trinity/include', language: 'cpp')
-  add_project_arguments('-DTEST_ONLY_MODE', language: 'c')
-  add_project_arguments('-DTEST_ONLY_MODE', language: 'cpp')
+  add_project_arguments('-DENABLE_EMUL', language: 'c')
+  add_project_arguments('-DENABLE_EMUL', language: 'cpp')
 endif
 
 subdir('src')
@@ -72,7 +73,7 @@ ne_install_conf.set('INCLUDE_INSTALL_DIR', ne_includedir)
 ne_install_conf.set('RESV_MEM_SIZE', get_option('resv_mem_size'))
 ne_install_conf.set('WORKING_DIR', get_option('working_dir'))
 ne_install_conf.set('LOG_DIR', get_option('log_dir'))
-if get_option('build_test_only_mode')
+if get_option('enable_npu_emul')
   ne_install_conf.set('TEST_MODE', true)
 else
   ne_install_conf.set('TEST_MODE', get_option('enable_test_mode'))
index a81b12f..c23c9f6 100644 (file)
@@ -3,4 +3,4 @@ option('resv_mem_size', type : 'string', value : '0')
 option('working_dir', type : 'string', value : '/tmp/')
 option('log_dir', type : 'string', value : '/tmp/')
 option('enable_test_mode', type : 'boolean', value : true)
-option('build_test_only_mode', type : 'boolean', value : false)
+option('enable_npu_emul', type : 'boolean', value : false)
index 287214f..2d604a0 100644 (file)
@@ -25,14 +25,17 @@ BuildRequires:      pkgconfig(iniparser)
 # gtest
 BuildRequires:  gtest-devel
 
-BuildRequires:  libnpuvision-devel
-
+# test coverage dependency
 %if 0%{?test_coverage}
 BuildRequires:  lcov
 BuildRequires:  python
 %endif
 
-# valgrind (used in unit tests only for x86_64)
+# NPU emulation dependency (used in unittests only)
+%if 0%{?unit_test}
+BuildRequires:  libnpuvision-devel
+
+# enable valgrind only for x86_64
 %ifarch x86_64
 %if 0%{?use_valgrind}
 BuildRequires:  valgrind
@@ -40,6 +43,8 @@ BuildRequires:  glibc-debuginfo
 %endif
 %endif
 
+%endif
+
 %global debug_package %{nil}
 %global __debug_install_post %{nil}
 
index 218f9f2..83a907e 100644 (file)
 #include <NPUemul.h>
 #include <npubinfmt.h>
 
+#if defined(ENABLE_EMUL)
 #include <TrinityCore.h>
 #include <DataGen.h>
+#endif
 
 #include <sys/mman.h>
 #include <sys/ioctl.h>
@@ -32,6 +34,7 @@
 #define PAGE_SIZE 4096
 
 using namespace std;
+#if defined(ENABLE_EMUL)
 using namespace trinity_vision;
 
 /** @brief NPU Emulation using TrinityCore */
@@ -494,6 +497,7 @@ class NPUCoreEmul : public TrinityCore<64>, public DataGen {
 };
 
 static NPUCoreEmul emul;
+#endif
 
 /**
  * @brief npu ioctl emulation
@@ -526,17 +530,23 @@ int npu_ioctl_emul (int fd, unsigned long cmd, void *arg)
       }
     case SRNPU_IOCTL_SET_MODEL:
       {
+#if defined(ENABLE_EMUL)
         npu_model_config * model_config;
         model_config = static_cast<npu_model_config *>(arg);
         emul.set_model(model_config);
         return 0;
+#endif
       }
     case SRNPU_IOCTL_RUN_INPUT:
       {
+#if defined(ENABLE_EMUL)
         npu_input_config * input_config;
         input_config = static_cast<npu_input_config *>(arg);
         emul.set_input(input_config);
         return emul.run();
+#else
+        return 0;
+#endif
       }
     default:
       return -EINVAL;
index 31bb9a8..6dc57b3 100644 (file)
@@ -1,8 +1,13 @@
 add_languages('cpp')
 
+npu_dependencies = [ne_core_utils_dep]
+if get_option('enable_npu_emul')
+  npu_dependencies += [ne_core_gem_dep, npuvision_dep]
+endif
+
 ne_core_npu_inc = include_directories('.')
 ne_core_npu_src = ['NPUdrvAPI.c', 'NPUemul.cpp']
 ne_core_npu_dep = declare_dependency(
   sources : ne_core_npu_src,
-  dependencies : [ne_core_utils_dep, ne_core_gem_dep, npuvision_dep],
+  dependencies : npu_dependencies,
   include_directories : [ne_common_inc, ne_core_npu_inc])