Skip to content

Commit

Permalink
HIP kernels may launch with non-uniform block size for backward compa…
Browse files Browse the repository at this point in the history
…tibility (#2307)

* [ROCm 5.7] HIP kernels may launch with non-uniform block size for backward compatibility

* Fix hipRTC build options for hip kernels

* fix issue with auto-format

* pinpoint effective hip version more precisely

* GREATER_EQUAL is available from CMake 3.7

* Update CMakeLists.txt

Co-authored-by: Artem Tamazov <artem.tamazov@gmail.com>

---------

Co-authored-by: Artem Tamazov <artem.tamazov@gmail.com>
  • Loading branch information
junliume and atamazov authored Aug 28, 2023
1 parent f810e2a commit 0ca134d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ math(EXPR MIOPEN_hip_VERSION_FLAT "(${MIOPEN_hip_VERSION_MAJOR} * 1000 + ${MIOPE
set_var_to_condition(MIOPEN_USE_HIPRTC_DEFAULT ${MIOPEN_USE_COMGR} AND (${MIOPEN_hip_VERSION_FLAT} GREATER 500000000))
option(MIOPEN_USE_HIPRTC "Use HIPRTC to build HIP kernels instead of COMGR" ${MIOPEN_USE_HIPRTC_DEFAULT})

# WORKAROUND_SWDEV_413293
if(${MIOPEN_hip_VERSION_FLAT} GREATER_EQUAL 500723302)
string(APPEND HIP_COMPILER_FLAGS " -fno-offload-uniform-block ")
endif()

message(STATUS "Hip compiler flags: ${HIP_COMPILER_FLAGS}")

add_definitions("-DHIP_COMPILER_FLAGS=${HIP_COMPILER_FLAGS}")
Expand Down
6 changes: 6 additions & 0 deletions src/comgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,9 @@ void BuildAsm(const std::string& name,

#define WORKAROUND_ISSUE_HIPRTC_HIPRTC_HEADER_H 1 // See SWDEV-307838, issue #1648.
#define WORKAROUND_ISSUE_1674 (HIP_PACKAGE_VERSION_FLAT >= 5003022305ULL)
/// No assumption that HIP kernels are launched with uniform block size for backward compatibility
/// SWDEV-413293 and https://reviews.llvm.org/D155213 effective HIP_FLAT_VERSION 500723302
#define WORKAROUND_SWDEV_413293 (HIP_PACKAGE_VERSION_FLAT >= 5007023302ULL)

namespace hiprtc {

Expand Down Expand Up @@ -1314,6 +1317,9 @@ void BuildHip(const std::string& name,
opts.push_back("-Wno-cuda-compat");
opts.push_back("-fno-gpu-rdc");
opts.push_back("-O3");
#if WORKAROUND_SWDEV_413293
opts.push_back("-fno-offload-uniform-block");
#endif
if(std::none_of(opts.begin(), opts.end(), [](const std::string& s) {
return StartsWith(s, "--std=") || StartsWith(s, "-std=");
}))
Expand Down

0 comments on commit 0ca134d

Please sign in to comment.