-
Notifications
You must be signed in to change notification settings - Fork 116
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
Add bounds checking for enqueue operations to the validation layer. #1093
Add bounds checking for enqueue operations to the validation layer. #1093
Conversation
044423a
to
8a548cd
Compare
@pbalcer I'd be interested if you had any feedback about this approach. The implementation does work but it isn't very elegant. I especially hate this https://github.com/oneapi-src/unified-runtime/pull/1093/files#diff-6ccceeaee484ce2a4014958578efbcd7732574d1bf5002a94ed76d992d5367adR1309 but I'm struggling to come up with a better alternative. |
The other major issue with this is signposting it so that if anyone ever adds a new enqueue operation that could utilize bounds checking it's obvious that they should come and update this mechanism to account for it. |
8a548cd
to
049d107
Compare
What's there now is marginally nicer but I'm still not thrilled about it. |
Maybe move the list of checks to the spec? So for memcpy, it could look like this:
Based on that, you can figure out in the validation layer that this is a pointer (so needs to use usm bounds check), and iterate over the rest of arguments to retrieve the context/queue or whatever other object might be needed. Alternatively, it might also make sense to align to how the rest of the validation layer is defined and put this information in the returns section:
This is more explicit, but also moves the definition of constrains on a type further away from the type definition itself. Both solutions have merit. |
If you go with the first approach, another thought I just had is that all the checks have similar arguments:
Since we are checking if the pDst fits inside of the 0<>size bounds. Having a consistent interface would make it easier to use in other parts of the spec. |
049d107
to
59ffdb5
Compare
I've implemented the parameter tagging approach, it makes it nice and visible for anyone looking to implement a new entry point with bounds checking and it should generalize to stuff outside enqueue without script modification (up to a point). Thanks for the suggestions. Just looking to see if there's a nicer way to propagate the errors from the GetInfo calls we'll be doing and this should be good to go |
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.
please add documentation to YaML.md
.
59ffdb5
to
9e205c5
Compare
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.
this is much neater than the first version.
9e205c5
to
c0d9107
Compare
c0d9107
to
e0099d6
Compare
@oneapi-src/unified-runtime-hip-write by a stroke of luck this change fixes a CI breakage we've had since friday, could I ask somebody to take a look? |
This is accomplished with the various size queries for buffers, images and USM allocations. Since not all adapters have these queries implemented the bounds checking isn't entirely comprehensive on all platforms just yet.
e0099d6
to
4b7f70f
Compare
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## adapters #1093 +/- ##
============================================
- Coverage 15.79% 15.73% -0.06%
============================================
Files 223 223
Lines 31351 31459 +108
Branches 3511 3542 +31
============================================
Hits 4951 4951
- Misses 26349 26457 +108
Partials 51 51 ☔ View full report in Codecov by Sentry. |
This is accomplished with the various size queries for buffers, images and USM allocations. Since not all adapters have these queries implemented the bounds checking isn't entirely comprehensive on all platforms just yet.
Aims to address issues discussed in #926