From 41ee2ee6890685b24d432820511516d276bb464d Mon Sep 17 00:00:00 2001 From: Vikram Date: Tue, 2 May 2023 01:28:59 -0400 Subject: [PATCH] SWDEV-378651 - add proper wavefrontsize link time option to hipRTC, in accordance with env variable GPU_ENABLE_WAVE32_MODE This is a copy of http://gerrit-git.amd.com/c/compute/ec/hipamd/+/841299 Raising this here again since hipamd repo is frozen. Change-Id: I8722ef55f78a9176e131fd5766fb11101b51f1b5 [ROCm/clr commit: cec579c0068d48c11598169636067d687cc6bb46] --- projects/clr/hipamd/src/CMakeLists.txt | 1 + projects/clr/hipamd/src/hiprtc/CMakeLists.txt | 2 ++ .../clr/hipamd/src/hiprtc/hiprtcInternal.cpp | 21 +++++++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/projects/clr/hipamd/src/CMakeLists.txt b/projects/clr/hipamd/src/CMakeLists.txt index 8fe1c4523f..b1707bde55 100644 --- a/projects/clr/hipamd/src/CMakeLists.txt +++ b/projects/clr/hipamd/src/CMakeLists.txt @@ -188,6 +188,7 @@ endif() set(HIPRTC_OBJECTS) # Add hiprtc +set(FIXME_DIR ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/amdhip64.dir) add_subdirectory(hiprtc) if(NOT WIN32) diff --git a/projects/clr/hipamd/src/hiprtc/CMakeLists.txt b/projects/clr/hipamd/src/hiprtc/CMakeLists.txt index 37ef8796fa..d2e500733a 100644 --- a/projects/clr/hipamd/src/hiprtc/CMakeLists.txt +++ b/projects/clr/hipamd/src/hiprtc/CMakeLists.txt @@ -96,6 +96,8 @@ if(BUILD_SHARED_LIBS) endif() if(WIN32) + target_link_libraries(hiprtc PRIVATE ${FIXME_DIR}/fixme.cpp${CMAKE_CXX_OUTPUT_EXTENSION}) + add_dependencies(hiprtc amdhip64) target_link_libraries(hiprtc PRIVATE Dbghelp.lib) endif() diff --git a/projects/clr/hipamd/src/hiprtc/hiprtcInternal.cpp b/projects/clr/hipamd/src/hiprtc/hiprtcInternal.cpp index 08eba0a3a1..0d23a1c697 100644 --- a/projects/clr/hipamd/src/hiprtc/hiprtcInternal.cpp +++ b/projects/clr/hipamd/src/hiprtc/hiprtcInternal.cpp @@ -133,8 +133,6 @@ RTCCompileProgram::RTCCompileProgram(std::string name_) : RTCProgram(name_), fgp if (GPU_ENABLE_WGP_MODE) compile_options_.push_back("-mcumode"); - if (!GPU_ENABLE_WAVE32_MODE) compile_options_.push_back("-mwavefrontsize64"); - compile_options_.push_back(hipVerOpt); compile_options_.push_back(hipVerMajor); compile_options_.push_back(hipVerMinor); @@ -261,6 +259,14 @@ bool RTCCompileProgram::transformOptions(std::vector& compile_optio return findIsa(); } +static inline uint getArchMajorVersion(std::string &isa) { + if (const amd::Isa *isaIter = amd::Isa::findIsa(isa.data())) { + return isaIter->versionMajor(); + } + + return static_cast(-1); +} + amd::Monitor RTCProgram::lock_("HIPRTC Program", true); bool RTCCompileProgram::compile(const std::vector& options, bool fgpu_rdc) { @@ -286,6 +292,17 @@ bool RTCCompileProgram::compile(const std::vector& options, bool fg return false; } + // Decide whether to enable wave64 compilation + auto majorVer = getArchMajorVersion(isa_); + if (majorVer <= 9 || !GPU_ENABLE_WAVE32_MODE) { + if (majorVer > 9) { + LogWarning("Wavefront size 64 is experimental for gfx10 and above. Warp " + "functions may not work"); + } + compileOpts.push_back("-mwavefrontsize64"); + link_options_.push_back("wavefrontsize64"); + } + if (!compileToBitCode(compile_input_, isa_, compileOpts, build_log_, LLVMBitcode_)) { LogError("Error in hiprtc: unable to compile source to bitcode"); return false;