1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
Fix build with LLVM 23
AMDGPU builtins take ext_vector_type operands (no implicit conversion) since
https://github.com/llvm/llvm-project/pull/176033:
- vanilla LLVM 23 and 24 (main): gfx1250 WMMA operands need casts; the calls
are not dependent, so this fails for every target
- AMD's LLVM fork (therock-10.1, amd-staging): still _Vector, builds without
casts; full reland pending in https://github.com/ROCm/llvm-project/pull/4184
Cast them like https://github.com/ROCm/rocm-libraries/pull/4066 did for the
other specializations.
--- a/library/include/rocwmma/internal/wmma_impl.hpp
+++ b/library/include/rocwmma/internal/wmma_impl.hpp
@@ -795,12 +795,14 @@ namespace rocwmma
ROCWMMA_DEVICE static inline auto
exec(ARegsT const& regsA, BRegsT const& regsB, CRegsT const& regsC) -> DRegsT
{
+ using TypeAB = VecT<float16_t, 16>;
+
DRegsT result;
to_native_vector(result)
= {__builtin_amdgcn_wmma_f32_16x16x32_f16((bool)InputAMod,
- to_native_vector(regsA),
+ to_native_vector(reinterpret_cast<TypeAB const&>(regsA)),
(bool)InputBMod,
- to_native_vector(regsB),
+ to_native_vector(reinterpret_cast<TypeAB const&>(regsB)),
(int16_t)InputCMod,
to_native_vector(regsC),
(bool)ReuseA,
@@ -974,14 +976,17 @@ namespace rocwmma
ROCWMMA_DEVICE static inline auto
exec(ARegsT const& regsA, BRegsT const& regsB, CRegsT const& regsC) -> DRegsT
{
+ using TypeAB = VecT<float16_t, 16>;
+ using TypeAcc = VecT<float16_t, 8>;
+
DRegsT result;
- to_native_vector(result)
+ to_native_vector(reinterpret_cast<TypeAcc&>(result))
= {__builtin_amdgcn_wmma_f16_16x16x32_f16((bool)InputAMod,
- to_native_vector(regsA),
+ to_native_vector(reinterpret_cast<TypeAB const&>(regsA)),
(bool)InputBMod,
- to_native_vector(regsB),
+ to_native_vector(reinterpret_cast<TypeAB const&>(regsB)),
(int16_t)InputCMod,
- to_native_vector(regsC),
+ to_native_vector(reinterpret_cast<TypeAcc const&>(regsC)),
(bool)ReuseA,
(bool)ReuseB)};
return result;
@@ -1148,12 +1153,14 @@ namespace rocwmma
ROCWMMA_DEVICE static inline auto
exec(ARegsT const& regsA, BRegsT const& regsB, CRegsT const& regsC) -> DRegsT
{
+ using TypeAB = __bf16 __attribute__((ext_vector_type(16)));
+
DRegsT result;
to_native_vector(result)
= {__builtin_amdgcn_wmma_f32_16x16x32_bf16((bool)InputAMod,
- to_native_vector(regsA),
+ reinterpret_cast<TypeAB const&>(regsA),
(bool)InputBMod,
- to_native_vector(regsB),
+ reinterpret_cast<TypeAB const&>(regsB),
(int16_t)InputCMod,
to_native_vector(regsC),
(bool)ReuseA,
@@ -1327,14 +1334,17 @@ namespace rocwmma
ROCWMMA_DEVICE static inline auto
exec(ARegsT const& regsA, BRegsT const& regsB, CRegsT const& regsC) -> DRegsT
{
+ using TypeAB = __bf16 __attribute__((ext_vector_type(16)));
+ using TypeAcc = __bf16 __attribute__((ext_vector_type(8)));
+
DRegsT result;
- to_native_vector(result)
+ reinterpret_cast<TypeAcc&>(result)
= {__builtin_amdgcn_wmma_bf16_16x16x32_bf16((bool)InputAMod,
- to_native_vector(regsA),
+ reinterpret_cast<TypeAB const&>(regsA),
(bool)InputBMod,
- to_native_vector(regsB),
+ reinterpret_cast<TypeAB const&>(regsB),
(int16_t)InputCMod,
- to_native_vector(regsC),
+ reinterpret_cast<TypeAcc const&>(regsC),
(bool)ReuseA,
(bool)ReuseB)};
return result;
@@ -1740,12 +1750,14 @@ namespace rocwmma
ROCWMMA_DEVICE static inline auto
exec(ARegsT const& regsA, BRegsT const& regsB, CRegsT const& regsC) -> DRegsT
{
+ using TypeAB = VecT<int, 8>;
+
DRegsT result;
to_native_vector(result)
= {__builtin_amdgcn_wmma_i32_16x16x64_iu8((bool)InputSign,
- to_native_vector(regsA),
+ to_native_vector(reinterpret_cast<TypeAB const&>(regsA)),
(bool)InputSign,
- to_native_vector(regsB),
+ to_native_vector(reinterpret_cast<TypeAB const&>(regsB)),
to_native_vector(regsC),
(bool)ReuseA,
(bool)ReuseB)};
@@ -2070,12 +2082,14 @@ namespace rocwmma
static_assert(sizeof(TypeIn) == sizeof(decay_t<decltype(regsB)>),
"Inconsistent data formats");
+ using TypeAcc = VecT<float16_t, 8>;
+
DRegsT result;
- to_native_vector(result) = {__builtin_amdgcn_wmma_f16_16x16x64_fp8_fp8(
+ to_native_vector(reinterpret_cast<TypeAcc&>(result)) = {__builtin_amdgcn_wmma_f16_16x16x64_fp8_fp8(
to_native_vector(reinterpret_cast<TypeIn const&>(regsA)),
to_native_vector(reinterpret_cast<TypeIn const&>(regsB)),
(int16_t)InputCMod,
- to_native_vector(regsC),
+ to_native_vector(reinterpret_cast<TypeAcc const&>(regsC)),
(bool)ReuseA,
(bool)ReuseB)};
return result;
@@ -2114,12 +2128,14 @@ namespace rocwmma
static_assert(sizeof(TypeIn) == sizeof(decay_t<decltype(regsB)>),
"Inconsistent data formats");
+ using TypeAcc = VecT<float16_t, 8>;
+
DRegsT result;
- to_native_vector(result) = {__builtin_amdgcn_wmma_f16_16x16x128_fp8_fp8(
+ to_native_vector(reinterpret_cast<TypeAcc&>(result)) = {__builtin_amdgcn_wmma_f16_16x16x128_fp8_fp8(
to_native_vector(reinterpret_cast<TypeIn const&>(regsA)),
to_native_vector(reinterpret_cast<TypeIn const&>(regsB)),
(int16_t)InputCMod,
- to_native_vector(regsC),
+ to_native_vector(reinterpret_cast<TypeAcc const&>(regsC)),
(bool)ReuseA,
(bool)ReuseB)};
return result;
@@ -2442,12 +2458,14 @@ namespace rocwmma
static_assert(sizeof(TypeIn) == sizeof(decay_t<decltype(regsB)>),
"Inconsistent data formats");
+ using TypeAcc = VecT<float16_t, 8>;
+
DRegsT result;
- to_native_vector(result) = {__builtin_amdgcn_wmma_f16_16x16x64_bf8_bf8(
+ to_native_vector(reinterpret_cast<TypeAcc&>(result)) = {__builtin_amdgcn_wmma_f16_16x16x64_bf8_bf8(
to_native_vector(reinterpret_cast<TypeIn const&>(regsA)),
to_native_vector(reinterpret_cast<TypeIn const&>(regsB)),
(int16_t)InputCMod,
- to_native_vector(regsC),
+ to_native_vector(reinterpret_cast<TypeAcc const&>(regsC)),
(bool)ReuseA,
(bool)ReuseB)};
return result;
@@ -2486,12 +2504,14 @@ namespace rocwmma
static_assert(sizeof(TypeIn) == sizeof(decay_t<decltype(regsB)>),
"Inconsistent data formats");
+ using TypeAcc = VecT<float16_t, 8>;
+
DRegsT result;
- to_native_vector(result) = {__builtin_amdgcn_wmma_f16_16x16x128_bf8_bf8(
+ to_native_vector(reinterpret_cast<TypeAcc&>(result)) = {__builtin_amdgcn_wmma_f16_16x16x128_bf8_bf8(
to_native_vector(reinterpret_cast<TypeIn const&>(regsA)),
to_native_vector(reinterpret_cast<TypeIn const&>(regsB)),
(int16_t)InputCMod,
- to_native_vector(regsC),
+ to_native_vector(reinterpret_cast<TypeAcc const&>(regsC)),
(bool)ReuseA,
(bool)ReuseB)};
return result;
@@ -2785,12 +2805,14 @@ namespace rocwmma
static_assert(sizeof(TypeIn) == sizeof(decay_t<decltype(regsB)>),
"Inconsistent data formats");
+ using TypeAcc = VecT<float16_t, 8>;
+
DRegsT result;
- to_native_vector(result) = {__builtin_amdgcn_wmma_f16_16x16x64_fp8_bf8(
+ to_native_vector(reinterpret_cast<TypeAcc&>(result)) = {__builtin_amdgcn_wmma_f16_16x16x64_fp8_bf8(
to_native_vector(reinterpret_cast<TypeIn const&>(regsA)),
to_native_vector(reinterpret_cast<TypeIn const&>(regsB)),
(int16_t)InputCMod,
- to_native_vector(regsC),
+ to_native_vector(reinterpret_cast<TypeAcc const&>(regsC)),
(bool)ReuseA,
(bool)ReuseB)};
return result;
@@ -2829,12 +2851,14 @@ namespace rocwmma
static_assert(sizeof(TypeIn) == sizeof(decay_t<decltype(regsB)>),
"Inconsistent data formats");
+ using TypeAcc = VecT<float16_t, 8>;
+
DRegsT result;
- to_native_vector(result) = {__builtin_amdgcn_wmma_f16_16x16x128_fp8_bf8(
+ to_native_vector(reinterpret_cast<TypeAcc&>(result)) = {__builtin_amdgcn_wmma_f16_16x16x128_fp8_bf8(
to_native_vector(reinterpret_cast<TypeIn const&>(regsA)),
to_native_vector(reinterpret_cast<TypeIn const&>(regsB)),
(int16_t)InputCMod,
- to_native_vector(regsC),
+ to_native_vector(reinterpret_cast<TypeAcc const&>(regsC)),
(bool)ReuseA,
(bool)ReuseB)};
return result;
@@ -3127,12 +3151,14 @@ namespace rocwmma
static_assert(sizeof(TypeIn) == sizeof(decay_t<decltype(regsB)>),
"Inconsistent data formats");
+ using TypeAcc = VecT<float16_t, 8>;
+
DRegsT result;
- to_native_vector(result) = {__builtin_amdgcn_wmma_f16_16x16x64_bf8_fp8(
+ to_native_vector(reinterpret_cast<TypeAcc&>(result)) = {__builtin_amdgcn_wmma_f16_16x16x64_bf8_fp8(
to_native_vector(reinterpret_cast<TypeIn const&>(regsA)),
to_native_vector(reinterpret_cast<TypeIn const&>(regsB)),
(int16_t)InputCMod,
- to_native_vector(regsC),
+ to_native_vector(reinterpret_cast<TypeAcc const&>(regsC)),
(bool)ReuseA,
(bool)ReuseB)};
return result;
@@ -3171,12 +3197,14 @@ namespace rocwmma
static_assert(sizeof(TypeIn) == sizeof(decay_t<decltype(regsB)>),
"Inconsistent data formats");
+ using TypeAcc = VecT<float16_t, 8>;
+
DRegsT result;
- to_native_vector(result) = {__builtin_amdgcn_wmma_f16_16x16x128_bf8_fp8(
+ to_native_vector(reinterpret_cast<TypeAcc&>(result)) = {__builtin_amdgcn_wmma_f16_16x16x128_bf8_fp8(
to_native_vector(reinterpret_cast<TypeIn const&>(regsA)),
to_native_vector(reinterpret_cast<TypeIn const&>(regsB)),
(int16_t)InputCMod,
- to_native_vector(regsC),
+ to_native_vector(reinterpret_cast<TypeAcc const&>(regsC)),
(bool)ReuseA,
(bool)ReuseB)};
return result;
|