From 6a4a5f7c712be2ba2de99dd58fade457b4fd26f5 Mon Sep 17 00:00:00 2001 From: Hari Thangirala Date: Mon, 11 Apr 2016 15:03:06 -0500 Subject: [PATCH] ROCR Build ID support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build system/Package maintainer: - BUILDID is specified at cmake. - USAGE: cmake -DBUILDID= ../src For developer builds the who typically don�t provide BUILDID, cmake will: - Determine the last git commit when this tree was syncd - Deteremine the build date - Check if tree is clean when built The idea of this embedded string is that later when you get a ROCR build, you can get some idea on the build origination by using: strings libhsa-runtime.so.1 | grep �ROCR BUILD ID� For eg: - If it�s a Jenkins build 25, it returns: �ROCR BUILD ID: 25� - If it�s a developer build sync'd @ 06f5f2a with modifications, it returns: �ROCR BUILD ID: 06f5f2a-2016-04-11-0" [git-p4: depot-paths = "//depot/stg/hsa/drivers/hsa/runtime/": change = 1256588] [ROCm/ROCR-Runtime commit: a148fd0b6868aa435badb93a9cdb4d5c0bcd843a] --- .../runtime/hsa-runtime/core/CMakeLists.txt | 14 ++++++++++++++ .../runtime/hsa-runtime/core/hsacore.so.def | 1 + .../runtime/hsa-runtime/core/runtime/runtime.cpp | 2 ++ 3 files changed, 17 insertions(+) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/CMakeLists.txt b/projects/rocr-runtime/runtime/hsa-runtime/core/CMakeLists.txt index 7c59dbab4c..a7f4495203 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/CMakeLists.txt +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/CMakeLists.txt @@ -97,6 +97,20 @@ add_definitions ( -DHSA_EXPORT=1 ) add_definitions ( -DHSA_EXPORT_FINALIZER=1 ) add_definitions ( -DHSA_EXPORT_IMAGES=1 ) +if ( DEFINED BUILDID ) + add_definitions ( -DROCR_BUILD_ID=${BUILDID}) +else ( NOT DEFINED BUILDID) + ## get date information based on UTC - full date + execute_process(COMMAND date --utc +%F WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE ROCR_BUILD_TIME OUTPUT_STRIP_TRAILING_WHITESPACE) + ## get commit information + execute_process(COMMAND git rev-parse --short HEAD WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE ROCR_BUILD_COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE) + ## check dirty tree status + execute_process(COMMAND "git diff --shortstat 2> /dev/null|grep \"0 files changed\"|wc -l" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE ROCR_CLEAN_TREE OUTPUT_STRIP_TRAILING_WHITESPACE) + set ( BUILD_ID "${ROCR_BUILD_COMMIT}.${ROCR_BUILD_TIME}.${ROCR_CLEAN_TREE}") + add_definitions ( -DROCR_BUILD_ID=${BUILD_ID}) +endif () + + ## ------------------------- Linux Compiler and Linker options ------------------------- set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fexceptions -fno-rtti -fvisibility=hidden -Wno-error=sign-compare -Wno-sign-compare -Wno-write-strings -Wno-deprecated-declarations -Wno-conversion-null -fno-math-errno -fno-threadsafe-statics -fmerge-all-constants -fms-extensions -Wno-error=comment -Wno-comment -Wno-error=pointer-arith -Wno-pointer-arith -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=unused-function" ) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/hsacore.so.def b/projects/rocr-runtime/runtime/hsa-runtime/core/hsacore.so.def index 769809dc96..4e04a8e2a1 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/hsacore.so.def +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/hsacore.so.def @@ -1,3 +1,4 @@ +ROCR_1 { global: hsa_init; diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp index 4ae87718e8..bccd952145 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp @@ -64,6 +64,8 @@ #define HSA_VERSION_MAJOR 1 #define HSA_VERSION_MINOR 0 +const char rocrbuildid[] = "ROCR BUILD ID: " STRING(ROCR_BUILD_ID); + namespace core { bool g_use_interrupt_wait = true;