1
1
#ifndef CK_DYNAMIC_BUFFER_HPP
2
2
#define CK_DYNAMIC_BUFFER_HPP
3
3
4
- namespace ck {
5
-
6
4
#include " amd_buffer_addressing.hpp"
5
+ #include " c_style_pointer_cast.hpp"
6
+
7
+ namespace ck {
7
8
8
9
template <AddressSpaceEnum_t BufferAddressSpace, typename T, typename ElementSpaceSize>
9
10
struct DynamicBuffer
@@ -44,20 +45,20 @@ struct DynamicBuffer
44
45
static_assert (scalar_per_x_vector % scalar_per_t_vector == 0 ,
45
46
" wrong! X need to be multiple T" );
46
47
47
- constexpr index_t t_per_x = scalar_per_x_vector / scalar_per_t_vector;
48
-
49
48
if constexpr (GetAddressSpace () == AddressSpaceEnum_t::Global)
50
49
{
51
50
#if CK_USE_AMD_BUFFER_ADDRESSING
51
+ constexpr index_t t_per_x = scalar_per_x_vector / scalar_per_t_vector;
52
+
52
53
return amd_buffer_load_v2<remove_cv_t <remove_reference_t <T>>, t_per_x>(
53
54
p_data_, i, is_valid_offset, element_space_size_);
54
55
#else
55
- return is_valid_offset ? *reinterpret_cast <const X*>(&p_data_[i]) : X{0 };
56
+ return is_valid_offset ? *c_style_pointer_cast <const X*>(&p_data_[i]) : X{0 };
56
57
#endif
57
58
}
58
59
else
59
60
{
60
- return is_valid_offset ? *reinterpret_cast <const X*>(&p_data_[i]) : X{0 };
61
+ return is_valid_offset ? *c_style_pointer_cast <const X*>(&p_data_[i]) : X{0 };
61
62
}
62
63
}
63
64
@@ -78,17 +79,17 @@ struct DynamicBuffer
78
79
static_assert (scalar_per_x_vector % scalar_per_t_vector == 0 ,
79
80
" wrong! X need to be multiple T" );
80
81
81
- constexpr index_t t_per_x = scalar_per_x_vector / scalar_per_t_vector;
82
-
83
82
if constexpr (GetAddressSpace () == AddressSpaceEnum_t::Global)
84
83
{
85
84
#if CK_USE_AMD_BUFFER_ADDRESSING
85
+ constexpr index_t t_per_x = scalar_per_x_vector / scalar_per_t_vector;
86
+
86
87
amd_buffer_store_v2<remove_cv_t <remove_reference_t <T>>, t_per_x>(
87
88
x, p_data_, i, is_valid_offset, element_space_size_);
88
89
#else
89
90
if (is_valid_offset)
90
91
{
91
- *reinterpret_cast <X*>(&p_data_[i]) = x;
92
+ *c_style_pointer_cast <X*>(&p_data_[i]) = x;
92
93
}
93
94
#endif
94
95
}
@@ -97,7 +98,7 @@ struct DynamicBuffer
97
98
if (is_valid_offset)
98
99
{
99
100
#if !CK_WORKAROUND_SWDEV_XXXXXX_INT8_DS_WRITE_ISSUE
100
- *reinterpret_cast <X*>(&p_data_[i]) = x;
101
+ *c_style_pointer_cast <X*>(&p_data_[i]) = x;
101
102
#else
102
103
// HACK: compiler would lower IR "store<i8, 16> address_space(3)" into
103
104
// inefficient
@@ -128,56 +129,56 @@ struct DynamicBuffer
128
129
{
129
130
// HACK: cast pointer of x is bad
130
131
// TODO: remove this after compiler fix
131
- *reinterpret_cast <int8_t *>(&p_data_[i]) =
132
- *reinterpret_cast <const int8_t *>(&x);
132
+ *c_style_pointer_cast <int8_t *>(&p_data_[i]) =
133
+ *c_style_pointer_cast <const int8_t *>(&x);
133
134
}
134
135
else if constexpr (is_same<remove_cv_t <remove_reference_t <T>>, int8_t >::value &&
135
136
is_same<remove_cv_t <remove_reference_t <X>>, int8x2_t >::value)
136
137
{
137
138
// HACK: cast pointer of x is bad
138
139
// TODO: remove this after compiler fix
139
- *reinterpret_cast <int16_t *>(&p_data_[i]) =
140
- *reinterpret_cast <const int16_t *>(&x);
140
+ *c_style_pointer_cast <int16_t *>(&p_data_[i]) =
141
+ *c_style_pointer_cast <const int16_t *>(&x);
141
142
}
142
143
else if constexpr (is_same<remove_cv_t <remove_reference_t <T>>, int8_t >::value &&
143
144
is_same<remove_cv_t <remove_reference_t <X>>, int8x4_t >::value)
144
145
{
145
146
// HACK: cast pointer of x is bad
146
147
// TODO: remove this after compiler fix
147
- *reinterpret_cast <int32_t *>(&p_data_[i]) =
148
- *reinterpret_cast <const int32_t *>(&x);
148
+ *c_style_pointer_cast <int32_t *>(&p_data_[i]) =
149
+ *c_style_pointer_cast <const int32_t *>(&x);
149
150
}
150
151
else if constexpr (is_same<remove_cv_t <remove_reference_t <T>>,
151
152
int8x4_t >::value &&
152
153
is_same<remove_cv_t <remove_reference_t <X>>, int8x4_t >::value)
153
154
{
154
155
// HACK: cast pointer of x is bad
155
156
// TODO: remove this after compiler fix
156
- *reinterpret_cast <int32_t *>(&p_data_[i]) =
157
- *reinterpret_cast <const int32_t *>(&x);
157
+ *c_style_pointer_cast <int32_t *>(&p_data_[i]) =
158
+ *c_style_pointer_cast <const int32_t *>(&x);
158
159
}
159
160
else if constexpr (is_same<remove_cv_t <remove_reference_t <T>>,
160
161
int8x8_t >::value &&
161
162
is_same<remove_cv_t <remove_reference_t <X>>, int8x8_t >::value)
162
163
{
163
164
// HACK: cast pointer of x is bad
164
165
// TODO: remove this after compiler fix
165
- *reinterpret_cast <int32x2_t *>(&p_data_[i]) =
166
- *reinterpret_cast <const int32x2_t *>(&x);
166
+ *c_style_pointer_cast <int32x2_t *>(&p_data_[i]) =
167
+ *c_style_pointer_cast <const int32x2_t *>(&x);
167
168
}
168
169
else if constexpr (is_same<remove_cv_t <remove_reference_t <T>>,
169
170
int8x16_t >::value &&
170
171
is_same<remove_cv_t <remove_reference_t <X>>, int8x16_t >::value)
171
172
{
172
173
// HACK: cast pointer of x is bad
173
174
// TODO: remove this after compiler fix
174
- *reinterpret_cast <int32x4_t *>(&p_data_[i]) =
175
- *reinterpret_cast <const int32x4_t *>(&x);
175
+ *c_style_pointer_cast <int32x4_t *>(&p_data_[i]) =
176
+ *c_style_pointer_cast <const int32x4_t *>(&x);
176
177
}
177
178
}
178
179
else
179
180
{
180
- *reinterpret_cast <X*>(&p_data_[i]) = x;
181
+ *c_style_pointer_cast <X*>(&p_data_[i]) = x;
181
182
}
182
183
#endif
183
184
}
@@ -186,7 +187,7 @@ struct DynamicBuffer
186
187
{
187
188
if (is_valid_offset)
188
189
{
189
- *reinterpret_cast <X*>(&p_data_[i]) = x;
190
+ *c_style_pointer_cast <X*>(&p_data_[i]) = x;
190
191
}
191
192
}
192
193
}
0 commit comments