[SYCL] remove free function definition from host object file - #22890
[SYCL] remove free function definition from host object file#22890dklochkov-emb wants to merge 5 commits into
Conversation
|
@intel/dpcpp-cfe-reviewers can you please review today? This is in MFL. |
| if (SemaSYCLRef.SemaRef.getLangOpts().SYCLIsDevice) { | ||
| CompoundStmt *KernelBody = createFreeFunctionKernelBody(); | ||
| DeclCreator.setBody(KernelBody); | ||
| } |
There was a problem hiding this comment.
Does this change affect the ability to call the kernel function on the host as a regular host function? For example, does this work:
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((syclexp::nd_range_kernel<1>))
void func() {/*...*/}
int main() {
func(); // Called as regular host function
}
I ask only because the spec says that this is allowed:
A function decorated with one of these properties can still be called as a normal function in either host or device code. The property has no effect in such cases.
If necessary, I think we could change the spec. However, we should update the spec if this no longer works.
| ~FreeFunctionKernelBodyCreator() { | ||
| CompoundStmt *KernelBody = createFreeFunctionKernelBody(); | ||
| DeclCreator.setBody(KernelBody); | ||
| // For host compilation, skip creating the wrapper body to reduce object |
There was a problem hiding this comment.
I am confused by this. The processing of free functions is already gated for SYCLIsDevice. The code in this PR seems redundant. Am I missing something? See SemaDecl.cpp
// Handle free functions.
if (LangOpts.SYCLIsDevice && Body && !FD->isDependentContext())
SYCL().ProcessFreeFunction(FD);
There was a problem hiding this comment.
I see constructFreeFunctionKernel is also called in handleSYCLRegisteredKernels but there is gating for SYCLIsDevice here as well.
It was found that host object file contains free function definition which is no needed there. This PR fixes that.