-
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
raise exception in malloc when device does not supports usm #10348
raise exception in malloc when device does not supports usm #10348
Conversation
Ideally, should also check
|
sycl/source/detail/usm/usm_impl.cpp
Outdated
@@ -232,6 +232,11 @@ void *alignedAllocInternal(size_t Alignment, size_t Size, | |||
void *alignedAlloc(size_t Alignment, size_t Size, const context &Ctxt, | |||
const device &Dev, alloc Kind, const property_list &PropList, | |||
const detail::code_location &CodeLoc) { | |||
if (Dev.has(sycl::aspect::usm_device_allocations) == false) { |
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.
Depending on Kind
, we should check either usm_device_allocations
or usm_shared_allocations
. I doubt there are relevant devices with one but not the other, but the spec says what the spec says.
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.
@al42and Thanks for that!
All your remarks I just applied in newest commit.
Please take a look
// feature_not_supported exception | ||
bool raiseUsmException = true; | ||
for (auto device : Ctxt.get_devices()) { | ||
if (device.has(sycl::aspect::usm_device_allocations)) { |
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.
if (device.has(sycl::aspect::usm_device_allocations)) { | |
if (device.has(sycl::aspect::usm_host_allocations)) { |
Also, I think it might be slightly more concise if std::any_of
/ std::none_of
is used, but that's a matter of taste?
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.
+1 for std::none_of
; it gets rid of the extra auxiliary variable
// if no device in context has spect::usm_host_allocations then raise | ||
// feature_not_supported exception | ||
bool raiseUsmException = true; | ||
for (auto device : Ctxt.get_devices()) { |
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.
Nit:
for (auto device : Ctxt.get_devices()) { | |
for (const auto& device : Ctxt.get_devices()) { |
sycl::make_error_code(sycl::errc::feature_not_supported), | ||
"usm not supported"); | ||
} else if (Kind == alloc::host && | ||
Dev.has(sycl::aspect::usm_host_allocations) == false) { |
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.
Dev.has(sycl::aspect::usm_host_allocations) == false) { | |
!Dev.has(sycl::aspect::usm_host_allocations)) { |
sycl::make_error_code(sycl::errc::feature_not_supported), | ||
"usm not supported"); | ||
} else if (Kind == alloc::shared && | ||
Dev.has(sycl::aspect::usm_shared_allocations) == false) { |
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.
Dev.has(sycl::aspect::usm_shared_allocations) == false) { | |
!Dev.has(sycl::aspect::usm_shared_allocations)) { |
@@ -232,6 +246,23 @@ void *alignedAllocInternal(size_t Alignment, size_t Size, | |||
void *alignedAlloc(size_t Alignment, size_t Size, const context &Ctxt, | |||
const device &Dev, alloc Kind, const property_list &PropList, | |||
const detail::code_location &CodeLoc) { | |||
if (Kind == alloc::device && | |||
Dev.has(sycl::aspect::usm_device_allocations) == false) { |
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.
Dev.has(sycl::aspect::usm_device_allocations) == false) { | |
!Dev.has(sycl::aspect::usm_device_allocations)) { |
raiseUsmException = false; | ||
} | ||
} | ||
if (raiseUsmException == true) { |
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.
if (raiseUsmException == true) { | |
if (raiseUsmException) { |
@@ -41,6 +41,20 @@ namespace usm { | |||
void *alignedAllocHost(size_t Alignment, size_t Size, const context &Ctxt, | |||
alloc Kind, const property_list &PropList, | |||
const detail::code_location &CodeLoc) { | |||
// if no device in context has spect::usm_host_allocations then raise | |||
// feature_not_supported exception | |||
bool raiseUsmException = true; |
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.
The variable names introduced are not consistent with the surrounding convention
// feature_not_supported exception | ||
bool raiseUsmException = true; | ||
for (auto device : Ctxt.get_devices()) { | ||
if (device.has(sycl::aspect::usm_device_allocations)) { |
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.
+1 for std::none_of
; it gets rid of the extra auxiliary variable
This pull request is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be automatically closed in 30 days. |
This pull request was closed because it has been stalled for 30 days with no activity. |
Due to issue #9513
I made changes where alignedAlloc method throws exception when device does not supports usm