Skip to content

Conversation

slawekptak
Copy link
Contributor

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.

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.
Copy link
Contributor

@mmichel11 mmichel11 left a 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

Copy link
Contributor

@reble reble left a 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.

Copy link
Contributor

@aelovikov-intel aelovikov-intel left a 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.

Comment on lines +580 to +582
// No need to copy/move the kernel function, so we set
// the function pointer to the original function
KData.setKernelFunc(HostKernel.getPtr());
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

@vinser52 vinser52 Oct 17, 2025

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

Copy link
Contributor

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.

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants