- Notifications
You must be signed in to change notification settings - Fork 792
[SYCL] Update the kernel function pointer on function copy/move #20389
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
base: sycl
Are you sure you want to change the base?
[SYCL] Update the kernel function pointer on function copy/move #20389
Conversation
The kernel function pointer, used to extract the kernel arguments, needs to point to the user provided function, or a function copy, if the copy/move is needed.
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.
LGTM, I verified this fix resolves observed issues of kernel argument capture with graph recording
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.
@mmichel11 We should also add your regression test, can do as a follow-up PR.
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.
Test is needed in this PR.
// No need to copy/move the kernel function, so we set | ||
// the function pointer to the original function | ||
KData.setKernelFunc(HostKernel.getPtr()); |
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 not just update decltype(KData)
to use HostKernelBase &
instead of a raw pointer?
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 is void handler::setKernelInfo
left for compatibility, which sets the pointer. Wouldn't this be an issue?
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 assumed that KData
is of type recently added by @vinser52 that hasn't made its way into any official release and we can freely modify it. Isn't that the case?
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's true, but the function pointer was moved into it, and now both new and old code uses it to store the pointer. Also, KernelData
only needs the pointer, so why do you think storing HostKernelBase
is better?
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.
@aelovikov-intel I believe @slawekptak is talking about ABI entry point (handler::setKernelInfo
). My idea was that when ABI window is opened we can cleanup this part. Today in a hadler path, the user functor is set two times inside StoreLambda
functions:
void StoreLambda(...) { // first time MHostKernel.reset(new detail::HostKernel<KernelType, LambdaArgType, Dims>( std::forward<KernelTypeUniversalRef>(KernelFunc))); // second time setDeviceKernelInfo<KernelName>((void *)MHostKernel->getPtr()); }
It should be fixed
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.
Also, KernelData only needs the pointer, so why do you think storing HostKernelBase is better?
Because function pointer can go stale, HostKernelBase
can't.
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 the case of handler path, we are storing the HostKernelBase
anyway (as I wrote above). So I agree with @aelovikov-intel.
The kernel function pointer, used to extract the kernel arguments, needs to point to the user provided function, or a function copy, if the copy/move is needed.