Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@

from .Architectures import SUPPORTED_ISA

from rocisa import getGitVersion

# Force version check here
def verifyRocisaVersion():
import subprocess
def getGitVersionPython():
return subprocess.check_output(
['git', 'rev-parse', '--short', 'HEAD']
).decode('ascii').strip()
cppVersion = getGitVersion()
pyVersion = getGitVersionPython()
if cppVersion != pyVersion:
raise RuntimeError(f"rocisa version mismatch: C++ version {cppVersion} != Python version {pyVersion}. Please rebuild rocisa.")
print(f"rocisa version {cppVersion} (git commit hash) is same as Python version {pyVersion}")

verifyRocisaVersion()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ellosel Is there a place that is good for running this code and make sure all entrance (Tensile, TensileCreateLibrary, etc.) will trigger the check?

Copy link
Copy Markdown
Contributor

@davidd-amd davidd-amd Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it belongs in an init. I think that would prevent it from running multiple times.

Copy link
Copy Markdown
Contributor Author

@KKyang KKyang Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find a proper function to run this. Any recommendations?

Comment on lines +33 to +45
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this function be in rocisa?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we need both. The hash from rocisa and the hash from the generator. Then we compare.


################################################################################
# Enumerate Valid Solution Parameters
################################################################################
Expand Down
8 changes: 8 additions & 0 deletions projects/hipblaslt/tensilelite/rocisa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE ROCISA_GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
add_compile_definitions(ROCISA_GIT_COMMIT_HASH="${ROCISA_GIT_COMMIT_HASH}")

Comment on lines +29 to +36
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to do this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To get the commit hash when compiling, so we can compare with the generator to make sure they are using the same commit.

if(DEFINED Python_EXECUTABLE AND Python_EXECUTABLE)
message(STATUS "Manually set Python_EXECUTABLE to ${Python_EXECUTABLE}")
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ namespace nb = nanobind;

namespace rocisa
{
std::string getGitVersion();

struct KernelInfo
{
IsaVersion isaVersion;
Expand Down
6 changes: 6 additions & 0 deletions projects/hipblaslt/tensilelite/rocisa/rocisa/src/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ namespace nb = nanobind;

namespace rocisa
{
std::string getGitVersion()
{
return ROCISA_GIT_COMMIT_HASH;
}

std::string isaToGfx(const nb::tuple& arch)
{
return getGfxNameTuple(
Expand Down Expand Up @@ -58,6 +63,7 @@ namespace rocisa

void init_base(nb::module_ m)
{
m.def("getGitVersion", &rocisa::getGitVersion, "Get git commit hash of rocisa.");
m.def("isaToGfx", nb::overload_cast<const nb::tuple&>(&rocisa::isaToGfx));
m.def("isaToGfx", nb::overload_cast<const IsaVersion&>(&rocisa::isaToGfx));
m.def("getGlcBitName", &rocisa::getGlcBitName);
Expand Down