Skip to content

Commit 273aaba

Browse files
atamazovjunliume
andauthored
[HOTFIX] Adapt to changes in HIP Mainline 417 (possibly future 6.1 RC) (#2652)
* fix-rocm61rc417(01) Disable new kernel build warnings. [NFC] Sort headers properly. * fix-rocm61rc417(02) [ROCm 6.1][HIPRTC] Use custom implementations instead of standard <limits>. This fixes build issues with ROCm 6.1. * fix-rocm61rc417(03) [ROCm 6.1][HIPRTC][Bugfix] Fixed issue in miopen_limits.h that prevented the use of custom implementations. * fix-rocm61rc417(04) [ROCm 6.1 RC][HIPRTC] Disable some of the custom implementations from <type_traits> (like `integral_constant`) for HIP mainline 417. This fixes some build issues. * fix-rocm61rc417(05) [ROCm 6.1 RC][offline compiler] Removed "-mcpu" from build options. This resolves kernel build issues with HIP mainline 417 (offline compiler). Improved diagnostic messages output onto console after offline build failures. * fix-rocm61rc417(06) [tests] Disable some testcase from handle_test as #2600 still persists in Hip Mainline 417. --------- Co-authored-by: Jun Liu <[email protected]>
1 parent 487b870 commit 273aaba

File tree

6 files changed

+41
-17
lines changed

6 files changed

+41
-17
lines changed

src/comgr.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,10 +1302,9 @@ void BuildHip(const std::string& name,
13021302
#endif
13031303
opts.push_back("-DHIP_PACKAGE_VERSION_FLAT=" + std::to_string(HIP_PACKAGE_VERSION_FLAT));
13041304
opts.push_back("-DMIOPEN_DONT_USE_HIP_RUNTIME_HEADERS");
1305-
/// For now, use only standard <limits> to avoid possibility of
1306-
/// correctnes or performance regressions.
1307-
/// \todo Test and enable "custom" local implementation.
1305+
#if HIP_PACKAGE_VERSION_FLAT < 6001024000ULL
13081306
opts.push_back("-DWORKAROUND_DONT_USE_CUSTOM_LIMITS=1");
1307+
#endif
13091308
#if WORKAROUND_ISSUE_1431
13101309
if((StartsWith(target.Name(), "gfx10") || StartsWith(target.Name(), "gfx11")) &&
13111310
!miopen::comgr::IsWave64Enforced(opts))

src/hip/hip_build_utils.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,20 @@ static boost::filesystem::path HipBuildImpl(boost::optional<TmpDir>& tmp_dir,
7575
if(params.find("-std=") == std::string::npos)
7676
params += " --std=c++17";
7777

78+
#if HIP_PACKAGE_VERSION_FLAT >= 6001024000ULL
79+
size_t pos = 0;
80+
while((pos = params.find("-mcpu=", pos)) != std::string::npos)
81+
{
82+
size_t endpos = params.find(' ', pos);
83+
if(endpos == std::string::npos)
84+
{
85+
params.erase(pos, std::string::npos);
86+
break;
87+
}
88+
params.erase(pos, endpos - pos);
89+
}
90+
#endif
91+
7892
#if HIP_PACKAGE_VERSION_FLAT < 4001000000ULL
7993
params += " --cuda-gpu-arch=" + lots.device;
8094
#else
@@ -110,11 +124,14 @@ static boost::filesystem::path HipBuildImpl(boost::optional<TmpDir>& tmp_dir,
110124
auto bin_file = tmp_dir->path / (filename + ".o");
111125

112126
// compile
113-
const std::string redirector = testing_mode ? " 1>/dev/null 2>&1" : "";
114-
tmp_dir->Execute(env + std::string(" ") + MIOPEN_HIP_COMPILER,
115-
params + filename + " -o " + bin_file.string() + redirector);
116-
if(!boost::filesystem::exists(bin_file))
117-
MIOPEN_THROW(filename + " failed to compile");
127+
{
128+
const std::string redirector = testing_mode ? " 1>/dev/null 2>&1" : "";
129+
const std::string cmd = env + std::string(" ") + MIOPEN_HIP_COMPILER;
130+
const std::string args = params + filename + " -o " + bin_file.string() + redirector;
131+
tmp_dir->Execute(cmd, args);
132+
if(!boost::filesystem::exists(bin_file))
133+
MIOPEN_THROW("Failed cmd: '" + cmd + "', args: '" + args + '\'');
134+
}
118135

119136
#if defined(MIOPEN_OFFLOADBUNDLER_BIN) && !MIOPEN_BACKEND_HIP
120137
// Unbundling is not required for HIP runtime && hip-clang

src/kernel_warnings.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323
* SOFTWARE.
2424
*
2525
*******************************************************************************/
26-
#include <iterator>
2726
#include <miopen/config.h>
2827
#include <miopen/kernel_warnings.hpp>
2928
#include <miopen/stringutils.hpp>
29+
30+
#include <iterator>
3031
#include <numeric>
3132
#include <sstream>
3233

@@ -48,6 +49,9 @@ static std::vector<std::string> OclKernelWarnings()
4849
"-Wno-shorten-64-to-32",
4950
"-Wno-sign-compare",
5051
"-Wno-sign-conversion",
52+
#if HIP_PACKAGE_VERSION_FLAT >= 6001024000ULL
53+
"-Wno-unsafe-buffer-usage",
54+
#endif
5155
"-Wno-unused-function",
5256
"-Wno-unused-macros",
5357
"-Wno-declaration-after-statement", // W/A for SWDEV-337356
@@ -58,7 +62,7 @@ static std::vector<std::string> OclKernelWarnings()
5862

5963
static std::vector<std::string> HipKernelWarnings()
6064
{
61-
return {
65+
std::vector<std::string> rv = {
6266
"-Weverything",
6367
"-Wno-c++98-compat",
6468
"-Wno-c++98-compat-pedantic",
@@ -83,7 +87,12 @@ static std::vector<std::string> HipKernelWarnings()
8387
"-Wno-covered-switch-default",
8488
"-Wno-disabled-macro-expansion",
8589
"-Wno-undefined-reinterpret-cast",
90+
#if HIP_PACKAGE_VERSION_FLAT >= 6001024000ULL
91+
"-Wno-unsafe-buffer-usage",
92+
#endif
8693
};
94+
95+
return rv;
8796
}
8897

8998
static std::string MakeKernelWarningsString(const std::vector<std::string>& kernel_warnings,

src/kernels/miopen_limits.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
*******************************************************************************/
2626
#pragma once
2727

28-
#ifndef WORKAROUND_DO_NOT_USE_CUSTOM_LIMITS
29-
#define WORKAROUND_DO_NOT_USE_CUSTOM_LIMITS 0
28+
#ifndef WORKAROUND_DONT_USE_CUSTOM_LIMITS
29+
#define WORKAROUND_DONT_USE_CUSTOM_LIMITS 0
3030
#endif
3131

3232
#if defined(MIOPEN_DONT_USE_HIP_RUNTIME_HEADERS) && !WORKAROUND_DONT_USE_CUSTOM_LIMITS

src/kernels/miopen_type_traits.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct remove_cv
7676
typedef typename remove_volatile<typename remove_const<T>::type>::type type;
7777
};
7878

79-
#if HIP_PACKAGE_VERSION_FLAT >= 6000024000ULL
79+
#if HIP_PACKAGE_VERSION_FLAT >= 6001000000ULL && HIP_PACKAGE_VERSION_FLAT < 6001024000ULL
8080
template <class T, T v>
8181
struct integral_constant
8282
{

test/handle_test.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@
2929
#define WORKAROUND_SWDEV_257056_PCH_MISSING_MACROS 1
3030

3131
// https://gerrit-git.amd.com/c/compute/ec/clr/+/972441
32-
// "HIP_PACKAGE_VERSION_FLAT == 6001000000ULL" is for ROCm 6.1 RC where issue #2600 is not
33-
// yet fixed in the compiler. In order to test such release candidates, we have to
34-
// override HIP version to 6.1.0.
32+
// Issue #2600 is not fixed in 6.0 and still persists in 6.1 release candidates.
33+
// We are expecting it to be fixed in 6.1 RC after week 4 in 2024.
3534
#define WORKAROUND_ISSUE_2600 \
3635
((HIP_PACKAGE_VERSION_FLAT >= 6000000000ULL && HIP_PACKAGE_VERSION_FLAT <= 6000999999ULL) || \
37-
HIP_PACKAGE_VERSION_FLAT == 6001000000ULL)
36+
(HIP_PACKAGE_VERSION_FLAT >= 6001000000ULL && HIP_PACKAGE_VERSION_FLAT <= 6001024049ULL))
3837

3938
#include <miopen/config.h>
4039
#include <miopen/handle.hpp>

0 commit comments

Comments
 (0)