-
Notifications
You must be signed in to change notification settings - Fork 68
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
Clarify "is_compatible" #381
Merged
keryell
merged 1 commit into
KhronosGroup:SYCL-2020/master
from
gmlueck:gmlueck/is-compatible
May 4, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is_compatible
doesn't really sound like "was this kernel compiled for this device?". With this change, users won't have an easy way to understand whether or not all optional features used in a kernel are supported by the device, becauseis_compatible
could returnfalse
for other reasons.Would it be better to instead expand definition of
has_kernel_bundle
to say that it may returnfalse
if compilation environment doesn't support the device?Kernel definition/properties, i.e. list of aspects used by it should not change depending on compilation environment, because it is encoded in the source code. Content of kernel bundle and list of available device images, however, is not defined by the source code alone and can also be heavily dependent on compilation environment.
Tagging @rolandschulz
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 the intent of
is_compatible
was that you can use it to determine whether a kernel can be submitted to a device. If we think that was the intent, then I believe this clarification makes sense.I agree that an application could have some kernel K that uses features that are compatible with some device D, but due to the compilation environment K cannot be run on device D. This change to the spec makes it impossible for the application to test that K would be compatible with device D if the application was compiled with some other set of options. However, I'm not sure that such a query is useful. It seems like the thing the application cares about is whether K can be run on D, not some hypothetical question about whether K could be run on D if the application was compiled differently.
Note that it's less convenient to use
has_kernel_bundle
because the application need to create a kernel bundle in order to use that API. It's much more convenient to useis_compatible
because you only need the kernel's type-name.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.
Let's say you provide a library which is AOT-compiled for a certain list of devices. You may want to improve user experience of the library users by emitting a better error saying that they need to re-compile the library with different flags to make it work on that device; instead of having some unspecified exception at runtime.
However, I agree that it is kind of an artificial case, because as a library author you could somehow configure your compilation environment to ensure that there are some fallback paths for non-target devices; or simply have clear documentation about device requirements.
You don't need a kernel bundle to query if a kernel bundle exists.
has_kernel_bundle
accepts context, vector ofkernel_id
and optionally list of 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.
I think both queries are useful. It is only hypothetical for run decision, but not for error reporting. An application might want to report "This kernel could run on the device you have available. But I was compiled without proper support. Please recompile me for best performance.".
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 I agree that since there are a few different reasons for why
is_compatible
may return false, it would be useful to have a way to expose the reason, I'm not sure how useful it would be as a mechanism for dispatching different kernels, but it could at least be a useful debug feature, to be able to identify exactly why the kernel couldn't be run on a certain device. Saying that, if we were to do this, I think that could be a different PR that doesn't need to hold up this one.