Skip to content

Commit

Permalink
[SYCL] Excluding cases with Alignment=0 from nullptr-returning scenario
Browse files Browse the repository at this point in the history
Signed-off-by: Hu, Peisen <peisen.hu@intel.com>
  • Loading branch information
HPS-1 committed Feb 1, 2024
1 parent 943f97d commit 40171c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions sycl/include/sycl/usm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ T *aligned_alloc_device(
size_t Alignment, size_t Count, const device &Dev, const context &Ctxt,
const property_list &PropList = {},
const detail::code_location &CodeLoc = detail::code_location::current()) {
if (Alignment && !(Alignment & (Alignment - 1))) {
if (!(Alignment & (Alignment - 1))) {
return static_cast<T *>(aligned_alloc_device(max(Alignment, alignof(T)),
Count * sizeof(T), Dev, Ctxt,
PropList, CodeLoc));
Expand All @@ -193,7 +193,7 @@ T *aligned_alloc_device(
size_t Alignment, size_t Count, const queue &Q,
const property_list &PropList = {},
const detail::code_location &CodeLoc = detail::code_location::current()) {
if (Alignment && !(Alignment & (Alignment - 1))) {
if (!(Alignment & (Alignment - 1))) {
return aligned_alloc_device<T>(Alignment, Count, Q.get_device(),
Q.get_context(), PropList, CodeLoc);
} else {
Expand Down Expand Up @@ -238,7 +238,7 @@ T *aligned_alloc_host(
size_t Alignment, size_t Count, const context &Ctxt,
const property_list &PropList = {},
const detail::code_location &CodeLoc = detail::code_location::current()) {
if (Alignment && !(Alignment & (Alignment - 1))) {
if (!(Alignment & (Alignment - 1))) {
return static_cast<T *>(aligned_alloc_host(std ::max(Alignment, alignof(T)),
Count * sizeof(T), Ctxt,
PropList, CodeLoc));
Expand All @@ -252,7 +252,7 @@ T *aligned_alloc_host(
size_t Alignment, size_t Count, const queue &Q,
const property_list &PropList = {},
const detail::code_location &CodeLoc = detail::code_location::current()) {
if (Alignment && !(Alignment & (Alignment - 1))) {
if (!(Alignment & (Alignment - 1))) {
return aligned_alloc_host<T>(Alignment, Count, Q.get_context(), PropList,
CodeLoc);
} else {
Expand All @@ -265,7 +265,7 @@ T *aligned_alloc_shared(
size_t Alignment, size_t Count, const device &Dev, const context &Ctxt,
const property_list &PropList = {},
const detail::code_location &CodeLoc = detail::code_location::current()) {
if (Alignment && !(Alignment & (Alignment - 1))) {
if (!(Alignment & (Alignment - 1))) {
return static_cast<T *>(aligned_alloc_shared(max(Alignment, alignof(T)),
Count * sizeof(T), Dev, Ctxt,
PropList, CodeLoc));
Expand All @@ -279,7 +279,7 @@ T *aligned_alloc_shared(
size_t Alignment, size_t Count, const queue &Q,
const property_list &PropList = {},
const detail::code_location &CodeLoc = detail::code_location::current()) {
if (Alignment && !(Alignment & (Alignment - 1))) {
if (!(Alignment & (Alignment - 1))) {
return aligned_alloc_shared<T>(Alignment, Count, Q.get_device(),
Q.get_context(), PropList, CodeLoc);
} else {
Expand Down Expand Up @@ -310,7 +310,7 @@ T *aligned_alloc(
size_t Alignment, size_t Count, const device &Dev, const context &Ctxt,
usm::alloc Kind, const property_list &PropList = {},
const detail::code_location &CodeLoc = detail::code_location::current()) {
if (Alignment && !(Alignment & (Alignment - 1))) {
if (!(Alignment & (Alignment - 1))) {
return static_cast<T *>(aligned_alloc(max(Alignment, alignof(T)),
Count * sizeof(T), Dev, Ctxt, Kind,
PropList, CodeLoc));
Expand All @@ -324,7 +324,7 @@ T *aligned_alloc(
size_t Alignment, size_t Count, const queue &Q, usm::alloc Kind,
const property_list &PropList = {},
const detail::code_location &CodeLoc = detail::code_location::current()) {
if (Alignment && !(Alignment & (Alignment - 1))) {
if (!(Alignment & (Alignment - 1))) {
return aligned_alloc<T>(Alignment, Count, Q.get_device(), Q.get_context(),
Kind, PropList, CodeLoc);
} else {
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/USM/align.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ template <typename T> void testAlign(sycl::queue &q, unsigned align) {
[&]() { return ATDevice(3, q); }, [&]() { return ATDevice(5, dev, Ctx); },
[&]() { return ATHost(7, q); }, [&]() { return ATHost(9, Ctx); },
[&]() { return ATShared(1919, q); },
[&]() { return ATShared(0, dev, Ctx); },
[&]() { return ATShared(11, dev, Ctx); },
[&]() { return ATAnnotated(15, q, alloc::device); },
[&]() { return ATAnnotated(17, dev, Ctx, alloc::host); }});

Expand Down

0 comments on commit 40171c6

Please sign in to comment.