-
Notifications
You must be signed in to change notification settings - Fork 33
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
A sycl::local_accessor-like API for numba-dpex kernel #1331
Conversation
e49d728
to
3fea523
Compare
3fea523
to
05678be
Compare
|
||
return self._data[idx_obj] | ||
|
||
def __setitem__(self, idx_obj, val): |
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 do you need this?
Any attempt to read/write to local memory on host should result in exception.
Or I misunderstands something?
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.
Sorry, I missed your comment.
This class is basically a simulator in pure Python for prototyping and testing. Borrowing idea's for numba-mlir's simulator.
The usage is a LocalAccessor
will need to be is created in pure Python and passed as a kernel argument. In simulator mode it is just a NumPy array so works as expected. In compiled mode it will be an actual local array. What do you think?
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.
Since there is no examples I'm not sure how it should work, but I assume, that user need to create instance of this class in order to use local memory inside of kernel. Something like that:
loc_mem = LocalAccessor(...)
kernel(..., loc_mem, ...)
If that's assumption is correct, then user may try to access local memory outside of kernel:
loc_mem = LocalAccessor(...)
loc_mem[0] = 10
kernel(..., loc_mem, ...)
And in this case an exception must be thrown.
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 then introduce LocalAccessorMock
with those methods implemented and when we call kapi.call_kernel
convert LocalAccessor
arguments to LocalAccessorMock
. This will prevent use of __getitem__
and __setitem__
from use outside of kernel. We still need to raise exception in LocalAccessor
. Something like "getting item from outside kernel is prohibited on LocalAccessor".
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 made these changes. Can you please review again?
05678be
to
bee7ba3
Compare
0437184
to
f4dc617
Compare
@ZzEeKkAa please review once again. I have added all changes and tests. I will add an example and update the kernel programming guide in a separate PR. |
37566f0
to
e44e8ed
Compare
57100c1
to
ae0a1b9
Compare
ae0a1b9
to
b12c1a3
Compare
102747e
to
d9d33b3
Compare
d9d33b3
to
52c3a56
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.
LGMT! Thank you!
52c3a56
to
2200c3c
Compare
A sycl::local_accessor-like API for numba-dpex kernel 68b1f39
…al_accessors A sycl::local_accessor-like API for numba-dpex kernel 68b1f39
The PR adds a
sycl::local_accessor
like API to numba-dpex's kernel API.TODOs