-
Notifications
You must be signed in to change notification settings - Fork 778
[SYCL] Throw an exception for unsupported aspect #6989
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] Throw an exception for unsupported aspect #6989
Conversation
The runtime must throw an exception whenever the application attempts to submit a kernel to a device where the kernel uses a feature that is not compatible with the device.
/verify with intel/llvm-test-suite#1314 |
sycl/include/sycl/info/aspects.def
Outdated
__SYCL_ASPECT(usm_shared_allocations, 15, "usm_shared_allocations") | ||
__SYCL_ASPECT(usm_restricted_shared_allocations, 16, "usm_restricted_shared_allocations") | ||
__SYCL_ASPECT(usm_system_allocations, 17, "usm_system_allocations") | ||
__SYCL_SPECIAL_ASPECT(usm_system_allocator __SYCL2020_DEPRECATED("use usm_system_allocations instead"), usm_system_allocations, "usm_system_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.
Can we have or a more precise definition of "special"? Also, I'd probably move deprecation message into a separate macro argument and call it
__SYCL_ASPECT_DEPRECATED(ASPECT, ID, MESSAGE)
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.
- Added the comment to describe this macro, does it look better now?
- Added
__SYCL_ASPECT_DEPRECATED
macro & outlined these aspects into the separate file. 410f00e
#define __SYCL_ASPECT(A, B, C) \ | ||
case aspect::A: \ | ||
return C; | ||
#define __SYCL_SPECIAL_ASPECT(A, B, C) |
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.
Why the deprecated alias isn't allowed here?
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.
It's not allowed because it's "special", not deprecated. Since this only aspect doesn't have own token it will duplicate existing case and lead to compile fail.
continue; | ||
ByteArray Aspects = DeviceBinaryProperty(*It).asByteArray(); | ||
// 8 because we need to skip 64-bits of size of the byte array | ||
auto *AIt = reinterpret_cast<const std::uint32_t *>(&Aspects[8]); |
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.
Why isn't this illegal type-punning?
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.
I see the same case in https://github.com/intel/llvm/blob/sycl/sycl/source/detail/program_manager/program_manager.cpp#L1241. Don't really get what you mean, could you please explain?
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.
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.
I think we can do this because originally these aspects were uint32_t. Maybe @steffenlarsen can add some clarity?
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.
In that case, I don't like how the interface is defined (i.e. we shouldn't be doing this magic here), but that would be outside this PR's scope.
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.
I have an old patch trying to amend the UB: #5537. It is a little stale now though.
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.
I have updated #5537 and added changes for this.
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.
I've uploaded an alternative approach in #7023.
…nsupported-feature
/verify with intel/llvm-test-suite#1314 |
auto KName = std::string_view((*It)->Name); | ||
if (KName != "aspects") | ||
continue; |
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: Not used to the std::string_view
best practices yet, but I'd try to write like this:
auto KName = std::string_view((*It)->Name); | |
if (KName != "aspects") | |
continue; | |
if (It->Name != "aspects"sv) | |
continue; |
I'm also not quite sure about It->Name
vs (*It)->Name
, but I vaguely recall operator->
behavior would enable that. Might be wrong though.
__SYCL_ASPECT_DEPRECATED(int64_base_atomics, 7, "use atomic64 instead") | ||
__SYCL_ASPECT_DEPRECATED(int64_extended_atomics, 8, "use atomic64 instead") | ||
// Special macro for aspects that don't have own token | ||
__SYCL_ASPECT_DEPRECATED_ALIAS(usm_system_allocator, usm_system_allocations, "use usm_system_allocations instead") |
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: I'd personally avoid having two files, but I don't have strong argumentation.
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.
@steffenlarsen , I'm not sure if you're "thumbing up" my "I'd avoid" or "don't have strong argumentation".
I'm approving the PR to unblock @KornevNikita but if you'd prefer to have a single file as well we can ask him to address that :) Both pre-/post-commit would work for me.
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.
Both, really. Having a single file would be a little nicer, but I don't think it's worth sweating over. 😄
#undef __SYCL_ASPECT_DEPRECATED | ||
#undef __SYCL_ASPECT | ||
|
||
for (RTDeviceBinaryImage::PropertyRange::ConstIterator It : ARange) { | ||
auto KName = std::string_view((*It)->Name); | ||
if (KName != "aspects") | ||
if (KName != std::string_view("aspects")) |
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: If done like this, this change is unnecessary.
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.
Can't compile with "aspects"sv
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.
What I mean is that my original suggestion was to eliminate named KName
by using string_view
on the string literal. If you keep string_view
on the LHS, there is no need to transform the string literal.
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.
But, since (*It)->Name
is char*, can't we just drop KName like:
(*It)->Name != "aspects"
?
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.
That wouldn't be the same.
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.
Okay, 51d9eab
@KornevNikita, please follow up on post-commit issues https://github.com/intel/llvm/actions/runs/3223149961 |
Related compiler changes: intel/llvm#6989 and intel/llvm#7419
…llvm-test-suite#1314) Related compiler changes: intel#6989 and intel#7419
The runtime must throw an exception whenever the application attempts to submit
a kernel to a device where the kernel uses a feature that is not compatible
with the device.
Co-authored-by: @AlexeySachkov