llvm icon indicating copy to clipboard operation
llvm copied to clipboard

[SYCL] Disable warning for attributes applied to non-kernel functors

Open dyniols opened this issue 1 year ago • 5 comments

The reason for this change is to avoid confusing when diagnostic is issued for functors that are defined but not used.

dyniols avatar Oct 02 '24 16:10 dyniols

How is this different from raising the warning on functions which are never called from a kernel? Should be be raising this warning on only those functions which are called from the kernel so you don't have random warnings generated for functions never even called?

Free functions are not usable as kernels and these warnings should be issues when applying the attribute to anything that is not recognizably a kernel function. The problem with functors are that they could be defined in common headers, while only actually being used in some source files, which means for all other source files they would issue a warning, even if they are not being used in those source files.

Free functions are not usable as kernels ...

That is not completely true, but we may want to refine once we know how we apply these attributes to free functions in the extensions allowing these. Tag @AlexeySachkov for comment.

steffenlarsen avatar Oct 08 '24 07:10 steffenlarsen

The problem with functors are that they could be defined in common headers, while only actually being used in some source files, which means for all other source files they would issue a warning, even if they are not being used in those source files.

With this new change, a non-kernel functor with this attribute invoked inside the kernel will not generate this warning and I am pretty certain nested lambdas will have the same issue. The more I think about it, I think it makes sense to only generate this warning only on functions called within the kernel. Why does it matter if the attribute is used on functions if there are never invoked in the kernel. It also would keep the behavior consistent between functions and lambdas and functors instead of diverging this way.

elizabethandrews avatar Oct 09 '24 21:10 elizabethandrews

With this new change, a non-kernel functor with this attribute invoked inside the kernel will not generate this warning and I am pretty certain nested lambdas will have the same issue. The more I think about it, I think it makes sense to only generate this warning only on functions called within the kernel. Why does it matter if the attribute is used on functions if there are never invoked in the kernel. It also would keep the behavior consistent between functions and lambdas and functors instead of diverging this way.

Sure, I can change implementation. I assume you mean to issue warnings only in the device-code path?

dyniols avatar Oct 15 '24 13:10 dyniols

With this new change, a non-kernel functor with this attribute invoked inside the kernel will not generate this warning and I am pretty certain nested lambdas will have the same issue. The more I think about it, I think it makes sense to only generate this warning only on functions called within the kernel. Why does it matter if the attribute is used on functions if there are never invoked in the kernel. It also would keep the behavior consistent between functions and lambdas and functors instead of diverging this way.

Sure, I can change implementation. I assume you mean to issue warnings only in the device-code path?

Yes I think that makes more sense here unless @steffenlarsen disagrees.

elizabethandrews avatar Oct 17 '24 20:10 elizabethandrews

Yes I think that makes more sense here unless @steffenlarsen disagrees.

It does change the intention of the warning slightly, but I agree that with the exclusions we have to make to avoid user confusion it makes perfect sense to make it just a device-code path check.

steffenlarsen avatar Oct 18 '24 05:10 steffenlarsen

This pull request is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be automatically closed in 30 days.

github-actions[bot] avatar Apr 17 '25 02:04 github-actions[bot]