-
Notifications
You must be signed in to change notification settings - Fork 122
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
ImmutableView support #542
Comments
@CsabaStupak thanks a lot for your feature request. I think that this feature is also related to #415 and #463. We were also thinking about a separate API for |
I don't mind if the kernel will have to explicitly transfer the variables from GPU memory to GPU constant memory - similarly as I do today when I transfer data to GPU cache. The key point here is to somehow get data from CPU or GPU memory to GPU constant memory which is AFAIK much faster (even faster than GPU cache?). I can even speedup my kernels since I can use GPU cache for something different than const values. The static approach is not the best way since my "const" arrays are changed between kernel calls but they do not change during the kernel call. So even today I have these arrays in GPU memory. Moreover for multi-thread case - when I create two accelerators, I have problem with static ImmutableArray approach. |
This could potentially be split into two parts. The first part is adding support for |
My vote is for automatic handling. Today if I call a kernel method I provide its arguments - view and even other non-view/const values. I guess ILGPU automatically move these values to GPU const memory or to GPU registers. I suppose that I can't move the GPU memory content to the GPU const memory inside the kernel since it should be const during the kernel call. However I do not see the whole picture here :-). I also hope that I will be able to use |
@CsabaStupak We have internally discussed adding support for var immutableSubView = data.SubView(...).AsImmutable();
// Avoid potential read-write dependency issues from here on
int myReadOnlyData = immutableSubView[...];
... In addition, we plan to add support for automatically moving array data (accessed read-only within the kernel) to sections in constant memory to improve performance. We are closing this issue for now and will provide PRs when ready. Thanks again for your feature request 👍. |
Hi guys, I love the progress on the library. I wonder if there is any update on this? Many thanks! :-) |
@m4rs-mt what did you want to do with this feature request? what should we try to implement? |
It would be great to have a way to specify that my Array should go to GPU cont memory. AFAIK the kernel function non-array arguments (mostly primitives int, float, etc.) and ImmutableArray go to cont memory. This have a big limitation when I have an array which is changed by one kernel and in another kernel it is not changed at all (read-only). Maybe the solution is to extend the kernel configuration where I specify the kernel dimension and allocate the shared memory. Here we could allocate the general read/write shared memory and also could allocate the read-only (const) shared memory which would utilize the GPU const memory. In the kernel function then I could access the allocated read/write shared memory and transfer the data from array/view to this memory as I do it today. But I could also access the read-only/const shared memory and transfer array/view content to this memory. So it looks like that we do not need the ImmutableArray at all. Only exception is when such array is automatically copied to GPU const memory before the kernel function is called. I guess this is what happens today. However the above kernel config approach could give more freedom. I could use any array/view to transfer its content to GPU const memory in the kernel. |
@CsabaStupak Have you tried using a If you used a |
I know that there is a support for ImmutableArray which content is copied to GPU const memory. However it must be a static variable what is not the best solution at least for my library. At least I was not able to set such ImmutableArray as kernel parameter - when I call LoadAutoGroupedStreamKernel it throws exception:
Not supported kernel-parameter type 'System.Collections.Immutable.ImmutableArray`1[System.Single]'
It would be much better if I could use ImmutableArray as input parameter to the kernel. Or maybe much better to have something like ImmutableView. Its content would be automatically copied to GPU const memory on kernel function call and from the kernel function it could be accessed as other View types.
The text was updated successfully, but these errors were encountered: