Skip to content
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

[ESIMD] Fix sampler/stream parameter handling for ESIMD kernels #5165

Merged
merged 11 commits into from
Jan 21, 2022
4 changes: 3 additions & 1 deletion clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2253,7 +2253,9 @@ class SyclKernelArgsSizeChecker : public SyclKernelFieldHandler {
const CXXRecordDecl *RecordDecl = FieldTy->getAsCXXRecordDecl();
assert(RecordDecl && "The type must be a RecordDecl");
llvm::StringLiteral MethodName =
IsSIMD ? InitESIMDMethodName : InitMethodName;
(IsSIMD && Util::isSyclType(FieldTy, "accessor", true /*Tmp*/))
Fznamznon marked this conversation as resolved.
Show resolved Hide resolved
? InitESIMDMethodName
: InitMethodName;
CXXMethodDecl *InitMethod = getMethodByName(RecordDecl, MethodName);
assert(InitMethod && "The type must have the __init method");
for (const ParmVarDecl *Param : InitMethod->parameters())
Expand Down
23 changes: 23 additions & 0 deletions clang/test/CodeGenSYCL/esimd-special-class.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// RUN: %clang_cc1 -fsycl-is-device \
// RUN: -internal-isystem %S/Inputs -triple spir64-unknown-unknown \
// RUN: -disable-llvm-passes -emit-llvm %s -o - %s | FileCheck --enable-var-scope %s

smanna12 marked this conversation as resolved.
Show resolved Hide resolved
#include "sycl.hpp"
using namespace cl::sycl;
void test() {

queue q;

q.submit([&](handler &h) {
cl::sycl::sampler smplr;
cl::sycl::stream Stream(1024, 128, h);

// CHECK: define {{.*}}spir_kernel void @{{.*}}esimd_kernel({{.*}}) #0 !kernel_arg_addr_space ![[NUM:[0-9]+]] !kernel_arg_access_qual ![[NUM1:[0-9]+]] !kernel_arg_type ![[NUM2:[0-9]+]] !kernel_arg_base_type ![[NUM2:[0-9]+]] !kernel_arg_type_qual ![[NUM3:[0-9]+]] !kernel_arg_accessor_ptr ![[NUM4:[0-9]+]] !sycl_explicit_simd ![[NUM5:[0-9]+]] !intel_reqd_sub_group_size ![[NUM6:[0-9]+]]
h.single_task<class esimd_kernel>(
[=]() [[intel::sycl_explicit_simd]] { smplr.use(); });
Fznamznon marked this conversation as resolved.
Show resolved Hide resolved
// CHECK: define {{.*}}spir_kernel void @{{.*}}StreamTester({{.*}}) #0 !kernel_arg_addr_space ![[NUM:[0-9]+]] !kernel_arg_access_qual ![[NUM1:[0-9]+]] !kernel_arg_type ![[NUM2:[0-9]+]] !kernel_arg_base_type ![[NUM2:[0-9]+]] !kernel_arg_type_qual ![[NUM3:[0-9]+]] !kernel_arg_accessor_ptr ![[NUM4:[0-9]+]] !sycl_explicit_simd ![[NUM5:[0-9]+]] !intel_reqd_sub_group_size ![[NUM6:[0-9]+]]
h.single_task<class StreamTester>([=]()
[[intel::sycl_explicit_simd]] { Stream << "one"
<< "two"; });
});
}