Add version information to Makefile, API
authorAjay Jayaraj <ajayj@ti.com>
Tue, 17 Apr 2018 21:12:19 +0000 (16:12 -0500)
committerAjay Jayaraj <ajayj@ti.com>
Tue, 17 Apr 2018 21:12:19 +0000 (16:12 -0500)
* Added version information in tinn_api/Makefile
* Added Executor::GetAPIVersion()

(MCT-962)

examples/test/main.cpp
tinn_api/Makefile
tinn_api/inc/executor.h
tinn_api/src/executor.cpp

index 852cfe0549ec97f7c0554e1f07b496d7625eba78..5805620a5f094dd65c4993b18f3009b37c09c5d4 100644 (file)
@@ -87,6 +87,7 @@ int main(int argc, char *argv[])
         std::cout << "TI DL not supported on this SoC." << std::endl;
         return EXIT_SUCCESS;
     }
+    std::cout << "API Version: " << Executor::GetAPIVersion() << std::endl;
 
     // Process arguments
     std::string config_file;
@@ -401,8 +402,8 @@ void ProcessArgs(int argc, char *argv[], std::string& config_file,
 
 void DisplayHelp()
 {
-    std::cout << "Usage: tidl\n"
-                 "  Will run all available networks if tidl is invoked without"
+    std::cout << "Usage: test_tinn\n"
+                 "  Will run all available networks if invoked without"
                  " any arguments.\n  Use -c to run a single network.\n"
                  "Optional arguments:\n"
                  " -c                   Path to the configuration file\n"
index beadf250410ca8b525ae415a0072b895b712f2f8..82e4871d184d378f78e647c98d745be70b079e01 100644 (file)
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 # THE POSSIBILITY OF SUCH DAMAGE.
 
+MAJOR_VER=0
+MINOR_VER=1
+PATCH_VER=0
+
+ifeq ($(shell git rev-parse --short HEAD 2>&1 1>/dev/null; echo $$?),0)
+BUILD_SHA?=$(shell git rev-parse --short HEAD)
+endif
+
 LIB_NAME = tinn_api.a
 DSP_OUTFILE = dsp/ocl_wrapper.out
 
@@ -45,6 +53,13 @@ HOST_OBJ_FILES = $(addprefix obj/,$(OBJS))
 HEADERS = src/ocl_device.h src/trace.h src/common_defines.h src/util.h
 HEADERS += src/executor_impl.h inc/executor.h inc/configuration.h
 
+.PHONY: $(BUILD_ID)
+BUILD_ID := -D_BUILD_VER=$(shell echo "" | \
+                awk '{ printf ("%02d.%02d.%02d", $(MAJOR_VER), \
+                $(MINOR_VER), $(PATCH_VER)); }') \
+                       -D_BUILD_SHA=$(BUILD_SHA)
+
+
 ifeq ($(BUILD), debug)
        CXXFLAGS += -Og -g -ggdb
 else
@@ -55,6 +70,7 @@ CXXFLAGS += -std=c++11 -Wall -Werror -Wno-error=ignored-attributes
 CXXFLAGS += -I$(TI_OCL_INSTALL)/usr/share/ti/opencl
 CXXFLAGS += -I$(TARGET_ROOTDIR)/usr/share/ti/opencl
 CXXFLAGS += -Isrc -Iinc
+CXXFLAGS += $(BUILD_ID)
 
 obj/%.o: src/%.cpp $(HEADERS)
        @echo Compiling $< ...
@@ -70,6 +86,5 @@ $(LIB_NAME) : obj_dir $(HOST_OBJ_FILES)
 $(DSP_OUTFILE):
        $(MAKE) -C dsp
 
-
 clean::
-       $(RM) -f $(LIB_NAME) $(HOST_OBJ_FILES)
+       $(RM) -f $(LIB_NAME) $(HOST_OBJ_FILES) $(DSP_OUTFILE)
index d8d9f388db543b6e396c04e6b35afed003b43151..118794d857c932a9753fff00b7cefad086fce124 100644 (file)
@@ -101,6 +101,11 @@ class Executor
         //! @return number of devices available
         static uint32_t GetNumDevicesSupportingTIDL(DeviceType device_type);
 
+        //! @brief Returns a string corresponding to the API version
+        //!
+        //! @return <major_ver>.<minor_ver>.<patch_ver>.<git_sha>
+        static std::string GetAPIVersion();
+
         Executor(const Executor&) = delete;
         Executor& operator= (const Executor&) = delete;
 
index fcba2e4ea52838cfc0d509f0324e46c7a32fe64e..f7022cada8b11b145e15862bc0339544ab825457 100644 (file)
@@ -34,6 +34,17 @@ uint32_t Executor::GetNumDevicesSupportingTIDL(DeviceType device_type)
     return Device::GetNumDevicesSupportingTIDL(device_type);
 }
 
+#define STRING(S)  XSTRING(S)
+#define XSTRING(S) #S
+std::string Executor::GetAPIVersion()
+{
+    static std::string version = STRING(_BUILD_VER);
+    version += ".";
+    version += STRING(_BUILD_SHA);
+    return version;
+}
+
+
 ExecutorImpl::ExecutorImpl(DeviceType core_type, const DeviceIds& ids):
     configuration_m(),
     shared_networkparam_heap_m(nullptr, &__free_ddr),
@@ -47,7 +58,6 @@ ExecutorImpl::ExecutorImpl(DeviceType core_type, const DeviceIds& ids):
         name = STRING(SETUP_KERNEL) ";" STRING(INIT_KERNEL) ";" STRING(PROCESS_KERNEL) ";" STRING(CLEANUP_KERNEL);
 
     device_m = Device::Create(core_type_m, ids, name);
-
 }