Skip to content

[SYCL] Free function host compilation bugfix #19541

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

Merged
merged 19 commits into from
Aug 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
34a11ca
Provide supports for decomposable structs
lbushi25 May 28, 2025
edec2b4
Merge branch 'sycl' of https://github.com/lbushi25/llvm into sycl
lbushi25 May 28, 2025
c9680a2
Revert "Provide supports for decomposable structs"
lbushi25 Jun 3, 2025
b932fe6
Merge branch 'sycl' of https://github.com/lbushi25/llvm into sycl
lbushi25 Jun 3, 2025
6b6da56
Merge branch 'sycl' of https://github.com/lbushi25/llvm into sycl
lbushi25 Jun 10, 2025
ceaabfd
Merge branch 'sycl' of https://github.com/lbushi25/llvm into sycl
lbushi25 Jun 23, 2025
714839e
Merge branch 'sycl' of https://github.com/lbushi25/llvm into sycl
lbushi25 Jul 22, 2025
e7adeb3
Add sanity test
lbushi25 Jul 22, 2025
b453f78
Bugfix
lbushi25 Jul 22, 2025
68679af
Update free_function_int_header_rtc_mode.cpp
lbushi25 Jul 22, 2025
73c7651
Move test to sycl/test and fix precommit failures
lbushi25 Jul 22, 2025
e9ddfea
Fix conflict
lbushi25 Jul 22, 2025
2c2ff65
Update free_function_host_compiler.cpp
lbushi25 Jul 22, 2025
80a475b
Update free_function_host_compiler.cpp
lbushi25 Jul 22, 2025
41daa24
Fix pre-commit failures
lbushi25 Jul 22, 2025
0d6ea81
Merge branch 'free_function_host_compilation_bugfix' of https://githu…
lbushi25 Jul 22, 2025
90c9541
Improve tests by adding cases with unnamed lambda extension disabled
lbushi25 Jul 28, 2025
9f904f6
Improve tests by adding cases with unnamed lambda extension disabled
lbushi25 Jul 28, 2025
3adcd2a
Update sycl/test/extensions/free_function_kernels/free_function_host_…
lbushi25 Jul 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6947,6 +6947,10 @@ void SYCLIntegrationHeader::emit(raw_ostream &O) {

for (const KernelDesc &K : KernelDescs) {
const size_t N = K.Params.size();
if (S.isFreeFunction(K.SyclKernel)) {
CurStart += N;
continue;
}
PresumedLoc PLoc = S.getASTContext().getSourceManager().getPresumedLoc(
S.getASTContext()
.getSourceManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ int main(){
// CHECK-NEXT: "{{.*}}__sycl_kernel_free_function_nd_rangePiii",
// CHECK-NEXT: "{{.*}}Kernel_Function",


// CHECK: static constexpr const char* getName() { return "{{.*}}__sycl_kernel_free_function_singlePiii"; }
// CHECK: static constexpr const char* getName() { return "{{.*}}__sycl_kernel_free_function_nd_rangePiii"; }
// CHECK: static constexpr const char* getName() { return "{{.*}}Kernel_Function"; }
// CHECK: _Z34__sycl_kernel_free_function_singlePiii
// CHECK: _Z36__sycl_kernel_free_function_nd_rangePiii
// CHECK: _ZTSZ4mainE15Kernel_Function

// CHECK-RTC-NOT: free_function_single_kernel
// CHECK-RTC-NOT: free_function_nd_range
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// RUN: %clangxx -fsycl %s
// RUN: %clangxx -fsycl -fno-sycl-unnamed-lambda %s
// RUN: %clangxx -fsycl -fsycl-host-compiler=g++ %s
// REQUIRES: linux

// This test serves as a sanity check that compilation succeeds
// for a simple free function kernel when using the host compiler
// flag with unnamed lambda extension enabled(default) and disabled.

#include <sycl/detail/core.hpp>
#include <sycl/ext/oneapi/experimental/free_function_traits.hpp>
#include <sycl/kernel_bundle.hpp>

SYCL_EXT_ONEAPI_FUNCTION_PROPERTY(
(sycl::ext::oneapi::experimental::nd_range_kernel<1>))
void kernel() {}

int main() {
sycl::queue q;

sycl::kernel_bundle bundle =
sycl::get_kernel_bundle<sycl::bundle_state::executable>(q.get_context());
sycl::kernel_id kID =
sycl::ext::oneapi::experimental::get_kernel_id<kernel>();
sycl::kernel krn = bundle.get_kernel(kID);

q.submit([&](sycl::handler &cgh) {
sycl::nd_range<1> ndr;
cgh.parallel_for(ndr, krn);
});
return 0;
}