Skip to content

Commit 3cc32a7

Browse files
authored
[ROCm 6.1][hipRTC] Fix build failures. [quality] Reorg standard includes in HIP sources. (#2637)
1 parent 1cc63e2 commit 3cc32a7

29 files changed

+435
-359
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ if(MIOPEN_USE_HIPRTC)
383383
message(FATAL_ERROR "HIPRTC can be used only together with COMGR")
384384
endif()
385385
find_package(hiprtc REQUIRED)
386-
message(STATUS "Build with HIPRTC")
386+
message(STATUS "Build with HIPRTC ${hiprtc_VERSION}")
387387
endif()
388388

389389
option(Boost_USE_STATIC_LIBS "Use boost static libraries" ON)

driver/random.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ inline T gen_subnorm()
109109
if constexpr(!std::is_integral_v<T> && !std::is_same_v<T, double> &&
110110
details::has_digits<T>::value)
111111
{
112-
using BitType = std::conditional_t<sizeof(T) == 2, uint16_t, uint32_t>;
112+
using BitType = std::conditional_t<sizeof(T) == 1,
113+
uint8_t,
114+
std::conditional_t<sizeof(T) == 2, uint16_t, uint32_t>>;
113115
static_assert(sizeof(T) == sizeof(BitType));
114116

115117
// -1 because ::digits counts the first implicit digit

src/CMakeLists.txt

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -381,23 +381,27 @@ if( MIOPEN_BACKEND MATCHES "OpenCL" OR MIOPEN_BACKEND STREQUAL "HIPOC" OR MIOPEN
381381
kernels/Conv_Winograd_v30_3_1_gfx11_fp32_f3x2_stride1.inc
382382
kernels/Conv_Winograd_v30_3_1_gfx11_fp32_f3x2_stride2.inc
383383
kernels/Conv_Winograd_v30_3_1_metadata.inc
384-
kernels/xform_bidirect_winograd_code.inc
385-
kernels/rocm_version.inc
386-
kernels/inst_wrappers.inc
384+
kernels/bfloat16_dev.hpp
387385
kernels/conv_common.inc
388-
kernels/utilities.inc
389-
kernels/xform_data_filter.inc
390-
kernels/xform_kd_cov2.inc
391-
kernels/xform_metadata.inc
392-
kernels/neuron.inc
393386
kernels/conv_sizes.inc
394-
kernels/gpr_alloc.inc
395-
kernels/bfloat16_dev.hpp
396387
kernels/float_types.h
397-
kernels/workaround_issue_1431.hpp
388+
kernels/gpr_alloc.inc
398389
kernels/hip_f8_impl.hpp
399390
kernels/hip_float8.hpp
391+
kernels/inst_wrappers.inc
392+
kernels/miopen_cstdint.hpp
393+
kernels/miopen_limits.hpp
394+
kernels/miopen_type_traits.hpp
395+
kernels/miopen_utility.hpp
396+
kernels/neuron.inc
397+
kernels/rocm_version.inc
400398
kernels/stride_array.hpp
399+
kernels/utilities.inc
400+
kernels/workaround_issue_1431.hpp
401+
kernels/xform_bidirect_winograd_code.inc
402+
kernels/xform_data_filter.inc
403+
kernels/xform_kd_cov2.inc
404+
kernels/xform_metadata.inc
401405
)
402406

403407
set(MIOPEN_KERNELS

src/comgr.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,8 +1292,7 @@ void BuildHip(const std::string& name,
12921292
auto opts =
12931293
miopen::SplitSpaceSeparated(options, miopen::comgr::compiler::lc::GetOptionsNoSplit());
12941294
compiler::lc::RemoveOptionsUnwanted(opts);
1295-
opts.push_back("-DWORKAROUND_ISSUE_HIPRTC_TRUE_TYPE"); // Workaround for SWDEV-308073
1296-
#if HIP_PACKAGE_VERSION_FLAT < 6000023494ULL
1295+
#if HIP_PACKAGE_VERSION_MAJOR < 6
12971296
opts.push_back("-D__HIP_PLATFORM_HCC__=1"); // Workaround?
12981297
#endif
12991298
opts.push_back("-D__HIP_PLATFORM_AMD__=1"); // Workaround?
@@ -1302,7 +1301,11 @@ void BuildHip(const std::string& name,
13021301
opts.push_back("-DCK_AMD_BUFFER_ATOMIC_FADD_RETURNS_FLOAT=1");
13031302
#endif
13041303
opts.push_back("-DHIP_PACKAGE_VERSION_FLAT=" + std::to_string(HIP_PACKAGE_VERSION_FLAT));
1305-
opts.push_back("-DMIOPEN_DONT_USE_HIP_RUNTIME_HEADERS=1");
1304+
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.
1308+
opts.push_back("-DWORKAROUND_DONT_USE_CUSTOM_LIMITS=1");
13061309
#if WORKAROUND_ISSUE_1431
13071310
if((StartsWith(target.Name(), "gfx10") || StartsWith(target.Name(), "gfx11")) &&
13081311
!miopen::comgr::IsWave64Enforced(opts))

src/composable_kernel/composable_kernel/include/utility/array.hpp

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,7 @@
44
#include "functional2.hpp"
55
#include "sequence.hpp"
66

7-
#ifdef __HIPCC_RTC__
8-
#ifdef WORKAROUND_ISSUE_HIPRTC_TRUE_TYPE
9-
/// We need <utility> for std::forward. In some cases, it includes <type_traits>
10-
/// (this is against the Standard, but it doesn't matter in this case).
11-
/// But <type_traits> also defines std::true_type, per Standard.
12-
/// However the latter definition conflicts with
13-
/// /opt/rocm/include/hip/amd_detail/amd_hip_vector_types.h,
14-
/// which defines std::true_type as well (which is wrong).
15-
16-
namespace std {
17-
18-
template <typename T>
19-
constexpr T&& forward(typename remove_reference<T>::type& t_) noexcept
20-
{
21-
return static_cast<T&&>(t_);
22-
}
23-
24-
template <typename T>
25-
constexpr T&& forward(typename remove_reference<T>::type&& t_) noexcept
26-
{
27-
return static_cast<T&&>(t_);
28-
}
29-
30-
} // namespace std
31-
#else
32-
#include <utility> // std::forward
33-
#endif
34-
#endif // __HIPCC_RTC__
7+
#include "miopen_utility.hpp" // std::forward
358

369
namespace ck {
3710

src/composable_kernel/composable_kernel/include/utility/config.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "hip/hip_fp16.h"
77
#endif
88
#include "bfloat16_dev.hpp"
9+
#include "miopen_cstdint.hpp"
910

1011
// "Constant" address space for kernel parameter
1112
#define CONSTANT __attribute__((address_space(4)))

src/composable_kernel/composable_kernel/include/utility/data_type.hpp

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,8 @@
33

44
#include "statically_indexed_array.hpp"
55

6-
#ifdef __HIPCC_RTC__
7-
#ifdef WORKAROUND_ISSUE_HIPRTC_TRUE_TYPE
8-
/// Definitions from <cstdint>, <cmath> conflict with
9-
/// /opt/rocm/include/hip/amd_detail/amd_hip_vector_types.h.
10-
11-
typedef signed char int8_t;
12-
typedef signed short int16_t;
13-
typedef float float_t;
14-
#include <limits> // std::numeric_limits
15-
16-
#else
17-
#include <cstdint> // int8_t, int16_t
18-
#include <cmath> // float_t
19-
#endif
20-
#endif // __HIPCC_RTC__
6+
#include "miopen_cstdint.hpp"
7+
#include "miopen_limits.hpp"
218

229
namespace ck {
2310

@@ -978,7 +965,7 @@ struct inner_product_with_conversion
978965
return acc;
979966
}
980967

981-
__device__ T operator()(float_t a, float_t b) const { return convert(a) * convert(b); }
968+
__device__ T operator()(float a, float b) const { return convert(a) * convert(b); }
982969

983970
__device__ T operator()(int8x4_t a, int8x4_t b) const
984971
{

src/composable_kernel/composable_kernel/include/utility/enable_if.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef CK_ENABLE_IF_HPP
22
#define CK_ENABLE_IF_HPP
33

4+
#include "miopen_type_traits.hpp"
5+
46
namespace ck {
57

68
template <bool B, typename T = void>

src/composable_kernel/composable_kernel/include/utility/magic_division.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "number.hpp"
77
#include "type.hpp"
88
#include "tuple.hpp"
9+
#include "miopen_cstdint.hpp"
910

1011
namespace ck {
1112

src/composable_kernel/composable_kernel/include/utility/type.hpp

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -3,84 +3,7 @@
33

44
#include "integral_constant.hpp"
55
#include "enable_if.hpp"
6-
7-
#ifdef __HIPCC_RTC__
8-
#ifdef WORKAROUND_ISSUE_HIPRTC_TRUE_TYPE
9-
/// We need <type_traits> for std::remove_reference and std::remove_cv.
10-
/// But <type_traits> also defines std::true_type, per Standard.
11-
/// However the latter definition conflicts with
12-
/// /opt/rocm/include/hip/amd_detail/amd_hip_vector_types.h,
13-
/// which defines std::true_type as well (which is wrong).
14-
15-
namespace std {
16-
17-
template <class T>
18-
struct remove_reference
19-
{
20-
typedef T type;
21-
};
22-
template <class T>
23-
struct remove_reference<T&>
24-
{
25-
typedef T type;
26-
};
27-
template <class T>
28-
struct remove_reference<T&&>
29-
{
30-
typedef T type;
31-
};
32-
33-
template <class T>
34-
using remove_reference_t = typename remove_reference<T>::type;
35-
36-
template <class T>
37-
struct remove_const
38-
{
39-
typedef T type;
40-
};
41-
template <class T>
42-
struct remove_const<const T>
43-
{
44-
typedef T type;
45-
};
46-
47-
template <class T>
48-
struct remove_volatile
49-
{
50-
typedef T type;
51-
};
52-
template <class T>
53-
struct remove_volatile<volatile T>
54-
{
55-
typedef T type;
56-
};
57-
58-
template <class T>
59-
struct remove_cv
60-
{
61-
typedef typename remove_volatile<typename remove_const<T>::type>::type type;
62-
};
63-
64-
template <class T>
65-
struct is_pointer_helper : std::false_type
66-
{
67-
};
68-
69-
template <class T>
70-
struct is_pointer_helper<T*> : std::true_type
71-
{
72-
};
73-
74-
template <class T>
75-
struct is_pointer : is_pointer_helper<typename std::remove_cv<T>::type>
76-
{
77-
};
78-
79-
} // namespace std
80-
#else
81-
#include <type_traits> // std::remove_reference, std::remove_cv, is_pointer
82-
#endif
83-
#endif // __HIPCC_RTC__
6+
#include "miopen_type_traits.hpp"
847

858
namespace ck {
869

0 commit comments

Comments
 (0)