-
Notifications
You must be signed in to change notification settings - Fork 738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SYCL] Return nullptr when allocation size is zero in usm allocator #12765
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// RUN: %{build} -o %t.out | ||
// RUN: %{run} %t.out | ||
|
||
#include <sycl/sycl.hpp> | ||
|
||
using namespace sycl; | ||
#define ALLOC_SIZE 0 | ||
|
||
int main() { | ||
queue q; | ||
auto dev = q.get_device(); | ||
auto ctxt = q.get_context(); | ||
|
||
if (dev.get_info<info::device::usm_host_allocations>()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we only test "host" here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how adding more allocation types will increase the test coverage of this change. Nevertheless, I've expanded the test to also check for zero-sized shared allocations. usm::alloc::device is not supported by usm_allocator so, I've skipped that.
uditagarwal97 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sycl::usm_allocator<int, sycl::usm::alloc::host> ua{ctxt, dev}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we have another overload that accepts There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
int *p = ua.allocate(ALLOC_SIZE); | ||
|
||
assert(!p && "usm_allocator should return a null pointer when allocation " | ||
"size is zero."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd reword as "our implementation is expected to ...". |
||
|
||
ua.deallocate(p, ALLOC_SIZE); | ||
} | ||
|
||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just inline it...