Skip to content

Commit a063dd2

Browse files
committed
fix error
1 parent dd7daf7 commit a063dd2

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

sycl/include/sycl/ext/oneapi/experimental/annotated_usm/alloc_base.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,9 @@ aligned_alloc_annotated(size_t alignment, size_t count,
109109
"Unknown USM allocation kind was specified.");
110110

111111
size_t combinedAlign = combine_align(alignment, alignFromPropList);
112-
void *rawPtr =
113-
sycl::aligned_alloc(std::max(sizeof(T), combinedAlign), count * sizeof(T),
114-
syclDevice, syclContext, kind, usmPropList);
115-
return annotated_ptr<T, propertyListB>(static_cast<T *>(rawPtr));
112+
T *rawPtr = sycl::aligned_alloc<T>(combinedAlign, count, syclDevice,
113+
syclContext, kind, usmPropList);
114+
return annotated_ptr<T, propertyListB>(rawPtr);
116115
}
117116

118117
template <typename propertyListA = detail::empty_properties_t,

sycl/test-e2e/Annotated_usm/annotated_usm_align.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,10 @@ template <typename T> void testAlign(sycl::queue &q, unsigned align) {
375375
// 2),
376376
// nullptr is returned
377377
,
378-
[&]() { return TDevice(q, properties{alignment<5>}); },
379-
[&]() { return TDevice(dev, Ctx, properties{alignment<10>}); },
380-
[&]() { return THost(q, properties{alignment<25>}); },
381-
[&]() { return THost(Ctx, properties{alignment<50>}); },
378+
[&]() { return TDevice(q, properties{alignment<75>}); },
379+
[&]() { return TDevice(dev, Ctx, properties{alignment<100>}); },
380+
[&]() { return THost(q, properties{alignment<205>}); },
381+
[&]() { return THost(Ctx, properties{alignment<500>}); },
382382
[&]() {
383383
return TAnnotated(q, alloc::device, properties{alignment<127>});
384384
},
@@ -405,18 +405,23 @@ template <typename T> void testAlign(sycl::queue &q, unsigned align) {
405405
// alignment
406406
// argument is not a power of 2, the result is nullptr
407407
,
408-
[&]() { return ATDevice(3, q); },
409-
[&]() { return ATDevice(7, dev, Ctx); },
410-
[&]() { return ATHost(7, q); },
411-
[&]() { return ATHost(9, Ctx); },
412-
[&]() { return ATAnnotated(15, q, alloc::device); },
413-
[&]() { return ATAnnotated(17, dev, Ctx, alloc::host); }});
408+
[&]() { return ATDevice(65, q); },
409+
[&]() { return ATDevice(70, dev, Ctx); },
410+
[&]() { return ATHost(174, q); },
411+
[&]() { return ATHost(299, Ctx); },
412+
[&]() { return ATAnnotated(550, q, alloc::device); },
413+
[&]() { return ATAnnotated(1700, dev, Ctx, alloc::host); }});
414414
}
415415

416+
struct alignas(64) MyStruct {
417+
int x;
418+
};
419+
416420
int main() {
417421
sycl::queue q;
418422
testAlign<char>(q, 4);
419423
testAlign<int>(q, 128);
420424
testAlign<std::complex<double>>(q, 4);
425+
testAlign<MyStruct>(q, 4);
421426
return 0;
422427
}

0 commit comments

Comments
 (0)