Skip to content

Commit

Permalink
[6.0.x] Fix for issue #2734: Detect if "-fno-offload-uniform-block" w…
Browse files Browse the repository at this point in the history
…orks in HIP compiler. (#2741)

* fix-issue-2734-rel-6.0 (01) Fix build with -DMIOPEN_USE_COMPOSABLEKERNEL=off for 6.0 release

* fix-issue-2734-rel-6.0 (02) Use "-fno-offload-uniform-block" only if HIP compiler supports it. Resolves #2734.
  • Loading branch information
atamazov authored Feb 14, 2024
1 parent a55aaa0 commit 9110d44
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,17 @@ set_var_to_condition(MIOPEN_USE_HIPRTC_DEFAULT ${MIOPEN_USE_COMGR} AND (${MIOPEN
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)
if(HAS_HIP)
check_cxx_compiler_flag("-x hip -fno-offload-uniform-block" MIOPEN_HIP_COMPILER_HAS_OPTION_OFFLOAD_UNIFORM_BLOCK)
else()
# CXX compiler is not HIP compiler, let's analyze HIP version.
set(MIOPEN_HIP_COMPILER_HAS_OPTION_OFFLOAD_UNIFORM_BLOCK Off)
if(${MIOPEN_hip_VERSION_FLAT} GREATER_EQUAL 500723302)
set(MIOPEN_HIP_COMPILER_HAS_OPTION_OFFLOAD_UNIFORM_BLOCK On)
endif()
message(STATUS "MIOPEN_HIP_COMPILER_HAS_OPTION_OFFLOAD_UNIFORM_BLOCK: ${MIOPEN_HIP_COMPILER_HAS_OPTION_OFFLOAD_UNIFORM_BLOCK}")
endif()
if(MIOPEN_HIP_COMPILER_HAS_OPTION_OFFLOAD_UNIFORM_BLOCK)
string(APPEND HIP_COMPILER_FLAGS " -fno-offload-uniform-block ")
endif()

Expand Down
1 change: 1 addition & 0 deletions include/miopen/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#cmakedefine01 MIOPEN_USE_COMPOSABLEKERNEL
#cmakedefine01 MIOPEN_ENABLE_AI_IMMED_MODE_FALLBACK
#cmakedefine01 MIOPEN_ENABLE_AI_KERNEL_TUNING
#cmakedefine01 MIOPEN_HIP_COMPILER_HAS_OPTION_OFFLOAD_UNIFORM_BLOCK

// "_PACKAGE_" to avoid name contentions: the macros like
// HIP_VERSION_MAJOR are defined in hip_version.h.
Expand Down
2 changes: 1 addition & 1 deletion src/comgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ 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
#if WORKAROUND_SWDEV_413293 && MIOPEN_HIP_COMPILER_HAS_OPTION_OFFLOAD_UNIFORM_BLOCK
opts.push_back("-fno-offload-uniform-block");
#endif
if(std::none_of(opts.begin(), opts.end(), [](const std::string& s) {
Expand Down
4 changes: 3 additions & 1 deletion src/solver/batchnorm/backward_ck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ bool BnCKBwdBackward::IsApplicable(const ExecutionContext& context,
{
#if !MIOPEN_BACKEND_HIP || !MIOPEN_USE_COMPOSABLEKERNEL
std::ignore = context;
std::ignore = fdesc_problem;
std::ignore = bn_problem;
return false;
#else
if(miopen::IsDisabled(MIOPEN_DEBUG_CONV_CK_BN_BACK{}))
Expand Down Expand Up @@ -191,6 +191,7 @@ bool BnCKBwdBackward::IsApplicable(const ExecutionContext& context,
#endif
}

#if MIOPEN_BACKEND_HIP && MIOPEN_USE_COMPOSABLEKERNEL
template <typename XDataType,
typename DxDataType,
typename DyDataType,
Expand Down Expand Up @@ -220,6 +221,7 @@ ConvSolution MakeAnyInvokerFactory(const miopen::batchnorm::ProblemDescription&
CKArgsBNormBwd,
miopen::batchnorm::BwdInvokeParams>(bn_problem, kernel_id);
}
#endif

ConvSolution BnCKBwdBackward::GetSolution(
[[maybe_unused]] const ExecutionContext& context,
Expand Down
4 changes: 3 additions & 1 deletion src/solver/batchnorm/forward_training_ck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ bool BnCKFwdTraining::IsApplicable(const ExecutionContext& context,
{
#if !MIOPEN_BACKEND_HIP || !MIOPEN_USE_COMPOSABLEKERNEL
std::ignore = context;
std::ignore = fdesc_problem;
std::ignore = bn_problem;
return false;
#else
if(miopen::IsDisabled(MIOPEN_DEBUG_CONV_CK_BN_FWD_TRAINING{}))
Expand All @@ -183,6 +183,7 @@ bool BnCKFwdTraining::IsApplicable(const ExecutionContext& context,
#endif
}

#if MIOPEN_BACKEND_HIP && MIOPEN_USE_COMPOSABLEKERNEL
template <typename XDataType,
typename YDataType,
typename AccDataType,
Expand All @@ -209,6 +210,7 @@ ConvSolution MakeAnyInvokerFactory(const miopen::batchnorm::ProblemDescription&
CKArgsBNormFwdTraining,
miopen::batchnorm::InvokeParams>(bn_problem, kernel_id);
}
#endif

ConvSolution BnCKFwdTraining::GetSolution(
[[maybe_unused]] const ExecutionContext& context,
Expand Down

0 comments on commit 9110d44

Please sign in to comment.