forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge from 'sycl' to 'sycl-web' (intel#5)
- Loading branch information
Showing
10 changed files
with
199 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// RUN: %clang %s -S -emit-llvm --sycl -o - | FileCheck %s | ||
|
||
#include "CL/sycl.hpp" | ||
|
||
constexpr auto sycl_read_write = cl::sycl::access::mode::read_write; | ||
constexpr auto sycl_global_buffer = cl::sycl::access::target::global_buffer; | ||
|
||
template <typename Acc1Ty, typename Acc2Ty> | ||
struct foostr { | ||
Acc1Ty A; | ||
Acc2Ty B; | ||
foostr(Acc1Ty A, Acc2Ty B): A(A), B(B) {} | ||
[[intel::kernel_args_restrict]] | ||
void operator()() { | ||
A[0] = B[0]; | ||
} | ||
}; | ||
|
||
int foo(int X) { | ||
int A[] = { 42 }; | ||
int B[] = { 0 }; | ||
{ | ||
cl::sycl::queue Q; | ||
cl::sycl::buffer<int, 1> BufA(A, 1); | ||
cl::sycl::buffer<int, 1> BufB(B, 1); | ||
|
||
// CHECK: define {{.*}} spir_kernel {{.*}}kernel_norestrict{{.*}}(i32 addrspace(1)* %{{.*}} i32 addrspace(1)* %{{.*}} | ||
|
||
Q.submit([&](cl::sycl::handler& cgh) { | ||
auto AccA = BufA.get_access<sycl_read_write, sycl_global_buffer>(cgh); | ||
auto AccB = BufB.get_access<sycl_read_write, sycl_global_buffer>(cgh); | ||
cgh.single_task<class kernel_norestrict>( | ||
[=]() { | ||
AccB[0] = AccA[0]; | ||
}); | ||
}); | ||
|
||
// CHECK: define {{.*}} spir_kernel {{.*}}kernel_restrict{{.*}}(i32 addrspace(1)* noalias %{{.*}} i32 addrspace(1)* noalias %{{.*}} | ||
Q.submit([&](cl::sycl::handler& cgh) { | ||
auto AccA = BufA.get_access<sycl_read_write, sycl_global_buffer>(cgh); | ||
auto AccB = BufB.get_access<sycl_read_write, sycl_global_buffer>(cgh); | ||
cgh.single_task<class kernel_restrict>( | ||
[=]() [[intel::kernel_args_restrict]] { | ||
AccB[0] = AccA[0]; | ||
}); | ||
}); | ||
|
||
// CHECK: define {{.*}} spir_kernel {{.*}}kernel_restrict_struct{{.*}}(i32 addrspace(1)* noalias %{{.*}} i32 addrspace(1)* noalias %{{.*}} | ||
Q.submit([&](cl::sycl::handler& cgh) { | ||
auto AccA = BufA.get_access<sycl_read_write, sycl_global_buffer>(cgh); | ||
auto AccB = BufB.get_access<sycl_read_write, sycl_global_buffer>(cgh); | ||
foostr<decltype(AccA), decltype(AccB)> f(AccA, AccB); | ||
cgh.single_task<class kernel_restrict_struct>(f); | ||
}); | ||
|
||
// CHECK: define {{.*}} spir_kernel {{.*}}kernel_restrict_other_params{{.*}}(i32 addrspace(1)* noalias %{{.*}} i32 addrspace(1)* noalias %{{.*}}, i32 %_arg_9) | ||
int num = 42; | ||
Q.submit([&](cl::sycl::handler& cgh) { | ||
auto AccA = BufA.get_access<sycl_read_write, sycl_global_buffer>(cgh); | ||
auto AccB = BufB.get_access<sycl_read_write, sycl_global_buffer>(cgh); | ||
cgh.single_task<class kernel_restrict_other_params>( | ||
[=]() [[intel::kernel_args_restrict]] { | ||
AccB[0] = AccA[0] = num; | ||
}); | ||
}); | ||
} | ||
return B[0]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// RUN: %clang %s -fsyntax-only --sycl -DCHECKDIAG -Xclang -verify | ||
// RUN: %clang %s -fsyntax-only -Xclang -ast-dump --sycl | FileCheck %s | ||
|
||
[[intel::kernel_args_restrict]] // expected-warning{{'kernel_args_restrict' attribute ignored}} | ||
void func_ignore() {} | ||
|
||
struct FuncObj { | ||
[[intel::kernel_args_restrict]] | ||
void operator()() {} | ||
}; | ||
|
||
template <typename name, typename Func> | ||
__attribute__((sycl_kernel)) void kernel(Func kernelFunc) { | ||
kernelFunc(); | ||
#ifdef CHECKDIAG | ||
[[intel::kernel_args_restrict]] int invalid = 42; // expected-error{{'kernel_args_restrict' attribute only applies to functions}} | ||
#endif | ||
} | ||
|
||
int main() { | ||
// CHECK-LABEL: FunctionDecl {{.*}} _ZTSZ4mainE12test_kernel1 | ||
// CHECK: SYCLIntelKernelArgsRestrictAttr | ||
kernel<class test_kernel1>( | ||
FuncObj()); | ||
|
||
// CHECK-LABEL: FunctionDecl {{.*}} _ZTSZ4mainE12test_kernel2 | ||
// CHECK: SYCLIntelKernelArgsRestrictAttr | ||
kernel<class test_kernel2>( | ||
[]() [[intel::kernel_args_restrict]] {}); | ||
|
||
// CHECK-LABEL: FunctionDecl {{.*}} _ZTSZ4mainE12test_kernel3 | ||
// CHECK-NOT: SYCLIntelKernelArgsRestrictAttr | ||
kernel<class test_kernel3>( | ||
[]() {func_ignore();}); | ||
} |