@@ -158,7 +158,8 @@ T *malloc_device(
158
158
const property_list &PropList = {},
159
159
const detail::code_location CodeLoc = detail::code_location::current()) {
160
160
return static_cast <T *>(
161
- malloc_device (Count * sizeof (T), Dev, Ctxt, PropList, CodeLoc));
161
+ aligned_alloc_device (std::max (alignof (T), alignof (std::max_align_t )),
162
+ Count * sizeof (T), Dev, Ctxt, PropList, CodeLoc));
162
163
}
163
164
164
165
template <typename T>
@@ -174,8 +175,9 @@ T *aligned_alloc_device(
174
175
size_t Alignment, size_t Count, const device &Dev, const context &Ctxt,
175
176
const property_list &PropList = {},
176
177
const detail::code_location CodeLoc = detail::code_location::current()) {
177
- return static_cast <T *>(aligned_alloc_device (Alignment, Count * sizeof (T),
178
- Dev, Ctxt, PropList, CodeLoc));
178
+ return static_cast <T *>(aligned_alloc_device (std::max (Alignment, alignof (T)),
179
+ Count * sizeof (T), Dev, Ctxt,
180
+ PropList, CodeLoc));
179
181
}
180
182
181
183
template <typename T>
@@ -192,7 +194,8 @@ T *malloc_host(
192
194
size_t Count, const context &Ctxt, const property_list &PropList = {},
193
195
const detail::code_location CodeLoc = detail::code_location::current()) {
194
196
return static_cast <T *>(
195
- malloc_host (Count * sizeof (T), Ctxt, PropList, CodeLoc));
197
+ aligned_alloc_host (std::max (alignof (T), alignof (std::max_align_t )),
198
+ Count * sizeof (T), Ctxt, PropList, CodeLoc));
196
199
}
197
200
198
201
template <typename T>
@@ -208,7 +211,8 @@ T *malloc_shared(
208
211
const property_list &PropList = {},
209
212
const detail::code_location CodeLoc = detail::code_location::current()) {
210
213
return static_cast <T *>(
211
- malloc_shared (Count * sizeof (T), Dev, Ctxt, PropList, CodeLoc));
214
+ aligned_alloc_shared (std::max (alignof (T), alignof (std::max_align_t )),
215
+ Count * sizeof (T), Dev, Ctxt, PropList, CodeLoc));
212
216
}
213
217
214
218
template <typename T>
@@ -224,8 +228,9 @@ T *aligned_alloc_host(
224
228
size_t Alignment, size_t Count, const context &Ctxt,
225
229
const property_list &PropList = {},
226
230
const detail::code_location CodeLoc = detail::code_location::current()) {
227
- return static_cast <T *>(aligned_alloc_host (Alignment, Count * sizeof (T), Ctxt,
228
- PropList, CodeLoc));
231
+ return static_cast <T *>(aligned_alloc_host (std ::max (Alignment, alignof (T)),
232
+ Count * sizeof (T), Ctxt, PropList,
233
+ CodeLoc));
229
234
}
230
235
231
236
template <typename T>
@@ -242,8 +247,9 @@ T *aligned_alloc_shared(
242
247
size_t Alignment, size_t Count, const device &Dev, const context &Ctxt,
243
248
const property_list &PropList = {},
244
249
const detail::code_location CodeLoc = detail::code_location::current()) {
245
- return static_cast <T *>(aligned_alloc_shared (Alignment, Count * sizeof (T),
246
- Dev, Ctxt, PropList, CodeLoc));
250
+ return static_cast <T *>(aligned_alloc_shared (std::max (Alignment, alignof (T)),
251
+ Count * sizeof (T), Dev, Ctxt,
252
+ PropList, CodeLoc));
247
253
}
248
254
249
255
template <typename T>
@@ -261,7 +267,8 @@ T *malloc(
261
267
const property_list &PropList = {},
262
268
const detail::code_location CodeLoc = detail::code_location::current()) {
263
269
return static_cast <T *>(
264
- malloc (Count * sizeof (T), Dev, Ctxt, Kind, PropList, CodeLoc));
270
+ aligned_alloc (std::max (alignof (T), alignof (std::max_align_t )),
271
+ Count * sizeof (T), Dev, Ctxt, Kind, PropList, CodeLoc));
265
272
}
266
273
267
274
template <typename T>
@@ -278,8 +285,9 @@ T *aligned_alloc(
278
285
size_t Alignment, size_t Count, const device &Dev, const context &Ctxt,
279
286
usm::alloc Kind, const property_list &PropList = {},
280
287
const detail::code_location CodeLoc = detail::code_location::current()) {
281
- return static_cast <T *>(aligned_alloc (Alignment, Count * sizeof (T), Dev, Ctxt,
282
- Kind, PropList, CodeLoc));
288
+ return static_cast <T *>(aligned_alloc (std::max (Alignment, alignof (T)),
289
+ Count * sizeof (T), Dev, Ctxt, Kind,
290
+ PropList, CodeLoc));
283
291
}
284
292
285
293
template <typename T>
0 commit comments