Closed Sarbojit2019 closed 8 months ago
We should follow HIPAMD in runtime version calculation I agree @linehill
@Sarbojit2019 I have no idea where that linting error comes from - I'll take a look
Completely agree with @linehill as macro is efficient approach. In chipStar I did not find CHIPSTAR_MAJOR/MINOR/PATCH macros hence thought of mimicking what AMD has in the API itself. Anyway I have made the change as suggested let me know your thoughts.
Here is a patch that should fix the version issue and additionally eliminates an atoi
call.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b25b9cdf..15f2e8b8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,7 +37,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
set(CHIPSTAR_MAJOR_VERSION 1)
set(CHIPSTAR_MINOR_VERSION 1)
set(CHIPSTAR_PATCH_VERSION 0)
-math(EXPR CHIPSTAR_VERSION "${CHIPSTAR_MAJOR_VERSION}*10000000+${CHIPSTAR_MINOR_VERSION}*100000+${CHIPSTAR_PATCH_VERSION}" OUTPUT_FORMAT DECIMAL)
+set(CHIPSTAR_VERSION "${CHIPSTAR_MAJOR_VERSION}.${CHIPSTAR_MINOR_VERSION}.${CHIPSTAR_PATCH_VERSION}")
+math(EXPR CHIPSTAR_VERSION_INT "${CHIPSTAR_MAJOR_VERSION}*10000000+${CHIPSTAR_MINOR_VERSION}*100000+${CHIPSTAR_PATCH_VERSION}" OUTPUT_FORMAT DECIMAL)
project(chipStar
VERSION ${CHIPSTAR_VERSION}
diff --git a/chipStarConfig.hh.in b/chipStarConfig.hh.in
index 60415060..2f3c90ac 100644
--- a/chipStarConfig.hh.in
+++ b/chipStarConfig.hh.in
@@ -24,6 +24,7 @@
#define CHIP_CONFIG_H
#cmakedefine CHIPSTAR_VERSION "@CHIPSTAR_VERSION@"
+#cmakedefine CHIPSTAR_VERSION_INT @CHIPSTAR_VERSION_INT@
// not implemented yet
#undef OCML_BASIC_ROUNDED_OPERATIONS
diff --git a/src/CHIPBindings.cc b/src/CHIPBindings.cc
index 2d974936..c4f6224e 100644
--- a/src/CHIPBindings.cc
+++ b/src/CHIPBindings.cc
@@ -1863,7 +1863,8 @@ hipError_t hipRuntimeGetVersion(int *RuntimeVersion) {
NULLCHECK(RuntimeVersion);
if (RuntimeVersion) {
- *RuntimeVersion = atoi(CHIPSTAR_VERSION);
+ static_assert(CHIPSTAR_VERSION_INT > 0, "Invalid version!");
+ *RuntimeVersion = CHIPSTAR_VERSION_INT;
RETURN(hipSuccess);
} else
RETURN(hipErrorInvalidValue);
@pvelesko, can you please take a look at the test failure observed in "cpp-linter". From error message it looks like environmental failure hence the ask.