Skip to content

Commit 94660ed

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web' (#3)
2 parents 3ccc691 + 1040b94 commit 94660ed

File tree

11 files changed

+524
-92
lines changed

11 files changed

+524
-92
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11197,7 +11197,7 @@ def err_sycl_function_attribute_mismatch : Error<
1119711197
"SYCL kernel without %0 attribute can't call a function with this attribute">;
1119811198
def err_sycl_x_y_z_arguments_must_be_one : Error<
1119911199
"%0 X-, Y- and Z- sizes must be 1 when %1 attribute is used with value 0">;
11200-
def err_sycl_attibute_cannot_be_applied_here
11200+
def err_sycl_attribute_internal_function
1120111201
: Error<"%0 attribute cannot be applied to a "
1120211202
"static function or function in an anonymous namespace">;
1120311203
def err_sycl_compiletime_property_duplication : Error<

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4833,7 +4833,7 @@ static void handleOptimizeNoneAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
48334833
static void handleSYCLDeviceAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
48344834
auto *FD = cast<FunctionDecl>(D);
48354835
if (!FD->isExternallyVisible()) {
4836-
S.Diag(AL.getLoc(), diag::err_sycl_attibute_cannot_be_applied_here) << AL;
4836+
S.Diag(AL.getLoc(), diag::err_sycl_attribute_internal_function) << AL;
48374837
return;
48384838
}
48394839

@@ -4844,7 +4844,7 @@ static void handleSYCLDeviceIndirectlyCallableAttr(Sema &S, Decl *D,
48444844
const ParsedAttr &AL) {
48454845
auto *FD = cast<FunctionDecl>(D);
48464846
if (!FD->isExternallyVisible()) {
4847-
S.Diag(AL.getLoc(), diag::err_sycl_attibute_cannot_be_applied_here) << AL;
4847+
S.Diag(AL.getLoc(), diag::err_sycl_attribute_internal_function) << AL;
48484848
return;
48494849
}
48504850

@@ -4854,11 +4854,6 @@ static void handleSYCLDeviceIndirectlyCallableAttr(Sema &S, Decl *D,
48544854

48554855
static void handleSYCLRegisterNumAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
48564856
auto *VD = cast<VarDecl>(D);
4857-
if (!VD->hasGlobalStorage()) {
4858-
S.Diag(AL.getLoc(), diag::err_sycl_attibute_cannot_be_applied_here)
4859-
<< AL << 0;
4860-
return;
4861-
}
48624857
if (!checkAttributeNumArgs(S, AL, 1))
48634858
return;
48644859
uint32_t RegNo = 0;

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,20 +178,8 @@ static bool IsSyclMathFunc(unsigned BuiltinID) {
178178
case Builtin::BI__builtin_truncl:
179179
case Builtin::BIlroundl:
180180
case Builtin::BI__builtin_lroundl:
181-
case Builtin::BIfmax:
182-
case Builtin::BI__builtin_fmax:
183-
case Builtin::BIfmin:
184-
case Builtin::BI__builtin_fmin:
185-
case Builtin::BIfmaxf:
186-
case Builtin::BI__builtin_fmaxf:
187-
case Builtin::BIfminf:
188-
case Builtin::BI__builtin_fminf:
189181
case Builtin::BIlroundf:
190182
case Builtin::BI__builtin_lroundf:
191-
case Builtin::BI__builtin_fpclassify:
192-
case Builtin::BI__builtin_isfinite:
193-
case Builtin::BI__builtin_isinf:
194-
case Builtin::BI__builtin_isnormal:
195183
return false;
196184
default:
197185
break;
Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsyntax-only -Wno-sycl-strict -verify %s
2+
// expected-no-diagnostics
23
extern "C" float sinf(float);
34
extern "C" float cosf(float);
45
extern "C" float floorf(float);
@@ -8,6 +9,8 @@ extern "C" float rintf(float);
89
extern "C" float roundf(float);
910
extern "C" float truncf(float);
1011
extern "C" float copysignf(float, float);
12+
extern "C" float fminf(float, float);
13+
extern "C" float fmaxf(float, float);
1114
extern "C" double sin(double);
1215
extern "C" double cos(double);
1316
extern "C" double floor(double);
@@ -17,6 +20,8 @@ extern "C" double rint(double);
1720
extern "C" double round(double);
1821
extern "C" double trunc(double);
1922
extern "C" double copysign(double, double);
23+
extern "C" double fmin(double, double);
24+
extern "C" double fmax(double, double);
2025
template <typename name, typename Func>
2126
__attribute__((sycl_kernel)) void kernel(const Func &kernelFunc) {
2227
kernelFunc();
@@ -26,39 +31,51 @@ int main() {
2631
kernel<class kernel_function>([=]() {
2732
int acc[1] = {5};
2833
acc[0] *= 2;
29-
acc[0] += (int)truncf(1.0f); // expected-no-diagnostics
30-
acc[0] += (int)trunc(1.0); // expected-no-diagnostics
31-
acc[0] += (int)roundf(1.0f); // expected-no-diagnostics
32-
acc[0] += (int)round(1.0); // expected-no-diagnostics
33-
acc[0] += (int)rintf(1.0f); // expected-no-diagnostics
34-
acc[0] += (int)rint(1.0); // expected-no-diagnostics
35-
acc[0] += (int)nearbyintf(0.5f); // expected-no-diagnostics
36-
acc[0] += (int)nearbyint(0.5); // expected-no-diagnostics
37-
acc[0] += (int)floorf(0.5f); // expected-no-diagnostics
38-
acc[0] += (int)floor(0.5); // expected-no-diagnostics
39-
acc[0] += (int)copysignf(1.0f, -0.5f); // expected-no-diagnostics
40-
acc[0] += (int)copysign(1.0, -0.5); // expected-no-diagnostics
41-
acc[0] += (int)sinf(1.0f); // expected-no-diagnostics
42-
acc[0] += (int)sin(1.0); // expected-no-diagnostics
43-
acc[0] += (int)__builtin_sinf(1.0f); // expected-no-diagnostics
44-
acc[0] += (int)__builtin_sin(1.0); // expected-no-diagnostics
45-
acc[0] += (int)cosf(1.0f); // expected-no-diagnostics
46-
acc[0] += (int)cos(1.0); // expected-no-diagnostics
47-
acc[0] += (int)__builtin_cosf(1.0f); // expected-no-diagnostics
48-
acc[0] += (int)__builtin_cos(1.0); // expected-no-diagnostics
49-
acc[0] += (int)logf(1.0f); // expected-no-diagnostics
50-
acc[0] += (int)log(1.0); // expected-no-diagnostics
51-
acc[0] += (int)__builtin_truncf(1.0f); // expected-no-diagnostics
52-
acc[0] += (int)__builtin_trunc(1.0); // expected-no-diagnostics
53-
acc[0] += (int)__builtin_rintf(1.0f); // expected-no-diagnostics
54-
acc[0] += (int)__builtin_rint(1.0); // expected-no-diagnostics
55-
acc[0] += (int)__builtin_nearbyintf(0.5f); // expected-no-diagnostics
56-
acc[0] += (int)__builtin_nearbyint(0.5); // expected-no-diagnostics
57-
acc[0] += (int)__builtin_floorf(0.5f); // expected-no-diagnostics
58-
acc[0] += (int)__builtin_floor(0.5); // expected-no-diagnostics
59-
acc[0] += (int)__builtin_copysignf(1.0f, -0.5f); // expected-no-diagnostics
60-
acc[0] += (int)__builtin_logf(1.0f); // expected-no-diagnostics
61-
acc[0] += (int)__builtin_log(1.0); // expected-no-diagnostics
34+
acc[0] += (int)truncf(1.0f);
35+
acc[0] += (int)trunc(1.0);
36+
acc[0] += (int)roundf(1.0f);
37+
acc[0] += (int)round(1.0);
38+
acc[0] += (int)rintf(1.0f);
39+
acc[0] += (int)rint(1.0);
40+
acc[0] += (int)nearbyintf(0.5f);
41+
acc[0] += (int)nearbyint(0.5);
42+
acc[0] += (int)floorf(0.5f);
43+
acc[0] += (int)floor(0.5);
44+
acc[0] += (int)copysignf(1.0f, -0.5f);
45+
acc[0] += (int)copysign(1.0, -0.5);
46+
acc[0] += (int)fminf(1.5f, 0.5f);
47+
acc[0] += (int)fmin(1.5, 0.5);
48+
acc[0] += (int)fmaxf(1.5f, 0.5f);
49+
acc[0] += (int)fmax(1.5, 0.5);
50+
acc[0] += (int)sinf(1.0f);
51+
acc[0] += (int)sin(1.0);
52+
acc[0] += (int)__builtin_sinf(1.0f);
53+
acc[0] += (int)__builtin_sin(1.0);
54+
acc[0] += (int)cosf(1.0f);
55+
acc[0] += (int)cos(1.0);
56+
acc[0] += (int)__builtin_cosf(1.0f);
57+
acc[0] += (int)__builtin_cos(1.0);
58+
acc[0] += (int)logf(1.0f);
59+
acc[0] += (int)log(1.0);
60+
acc[0] += (int)__builtin_truncf(1.0f);
61+
acc[0] += (int)__builtin_trunc(1.0);
62+
acc[0] += (int)__builtin_rintf(1.0f);
63+
acc[0] += (int)__builtin_rint(1.0);
64+
acc[0] += (int)__builtin_nearbyintf(0.5f);
65+
acc[0] += (int)__builtin_nearbyint(0.5);
66+
acc[0] += (int)__builtin_floorf(0.5f);
67+
acc[0] += (int)__builtin_floor(0.5);
68+
acc[0] += (int)__builtin_copysignf(1.0f, -0.5f);
69+
acc[0] += (int)__builtin_fminf(1.5f, 0.5f);
70+
acc[0] += (int)__builtin_fmin(1.5, 0.5);
71+
acc[0] += (int)__builtin_fmaxf(1.5f, 0.5f);
72+
acc[0] += (int)__builtin_fmax(1.5, 0.5);
73+
acc[0] += (int)__builtin_logf(1.0f);
74+
acc[0] += (int)__builtin_log(1.0);
75+
acc[0] += __builtin_isinf(1.0);
76+
acc[0] += __builtin_isfinite(1.0);
77+
acc[0] += __builtin_isnormal(1.0);
78+
acc[0] += __builtin_fpclassify(0, 1, 4, 3, 2, 1.0);
6279
});
6380
return 0;
6481
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
; RUN: sycl-post-link --ir-output-only -split=auto -S %s -o %t.ll
2+
; RUN: FileCheck %s -input-file=%t.ll
3+
4+
; This test checks that the --ir-output-only option writes a LLVM IR
5+
; file instead of a table. In comparison with other tests, this one
6+
; checks that the option works OK with -split=auto.
7+
8+
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
9+
target triple = "spir64-unknown-linux-sycldevice"
10+
11+
declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
12+
13+
define dso_local spir_kernel void @kernel1() #0 {
14+
entry:
15+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
16+
ret void
17+
}
18+
19+
define dso_local spir_kernel void @kernel2() #0 {
20+
entry:
21+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
22+
ret void
23+
}
24+
25+
attributes #0 = { "sycl-module-id"="a.cpp" }
26+
27+
!llvm.module.flags = !{!0}
28+
!opencl.spir.version = !{!1}
29+
!spirv.Source = !{!2}
30+
31+
!0 = !{i32 1, !"wchar_size", i32 4}
32+
!1 = !{i32 1, i32 2}
33+
!2 = !{i32 0, i32 100000}
34+
35+
; CHECK: define dso_local spir_kernel void @kernel1()
36+
; CHECK: define dso_local spir_kernel void @kernel2()
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
; RUN: sycl-post-link -split-esimd -S %s -o %t.table
2+
; RUN: FileCheck %s -input-file=%t.table
3+
; RUN: FileCheck %s -input-file=%t_0.ll --check-prefixes CHECK-SYCL-IR
4+
; RUN: FileCheck %s -input-file=%t_esimd_0.ll --check-prefixes CHECK-ESIMD-IR
5+
6+
; This is basic test of splitting SYCL and ESIMD kernels into separate
7+
; modules.
8+
9+
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
10+
target triple = "spir64-unknown-linux-sycldevice"
11+
12+
declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
13+
14+
define dso_local spir_kernel void @ESIMD_kernel() #0 !sycl_explicit_simd !3{
15+
entry:
16+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
17+
ret void
18+
}
19+
20+
define dso_local spir_kernel void @SYCL_kernel() #0 {
21+
entry:
22+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
23+
ret void
24+
}
25+
26+
attributes #0 = { "sycl-module-id"="a.cpp" }
27+
28+
!llvm.module.flags = !{!0}
29+
!opencl.spir.version = !{!1}
30+
!spirv.Source = !{!2}
31+
32+
!0 = !{i32 1, !"wchar_size", i32 4}
33+
!1 = !{i32 1, i32 2}
34+
!2 = !{i32 0, i32 100000}
35+
!3 = !{}
36+
37+
; CHECK: [Code|Properties]
38+
; CHECK: {{.*}}_0.ll|{{.*}}_0.prop
39+
; CHECK: {{.*}}_esimd_0.ll|{{.*}}_esimd_0.prop
40+
41+
; CHECK-SYCL-IR-DAG: define dso_local spir_kernel void @SYCL_kernel()
42+
; CHECK-SYCL-IR-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
43+
44+
; CHECK-ESIMD-IR-DAG: define dso_local spir_kernel void @ESIMD_kernel()
45+
; CHECK-ESIMD-IR-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
; RUN: sycl-post-link -split=source -S %s -o %t.table
2+
; RUN: FileCheck %s -input-file=%t.table
3+
; RUN: FileCheck %s -input-file=%t_0.ll --check-prefixes CHECK-IR-0
4+
; RUN: FileCheck %s -input-file=%t_1.ll --check-prefixes CHECK-IR-1
5+
6+
; This test checks that if no '-split-esimd' provided, ther is no
7+
; splitting of SYCL and ESIMD kernels into separate modules.
8+
; However, the rest of the splitting still happens according to
9+
; the '-split=' option.
10+
11+
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
12+
target triple = "spir64-unknown-linux-sycldevice"
13+
14+
declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
15+
16+
define dso_local spir_kernel void @ESIMD_kernel() #0 !sycl_explicit_simd !3{
17+
entry:
18+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
19+
ret void
20+
}
21+
22+
define dso_local spir_kernel void @SYCL_kernel1() #0 {
23+
entry:
24+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
25+
ret void
26+
}
27+
28+
define dso_local spir_kernel void @SYCL_kernel2() #1 {
29+
entry:
30+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
31+
ret void
32+
}
33+
34+
attributes #0 = { "sycl-module-id"="a.cpp" }
35+
attributes #1 = { "sycl-module-id"="b.cpp" }
36+
37+
!llvm.module.flags = !{!0}
38+
!opencl.spir.version = !{!1}
39+
!spirv.Source = !{!2}
40+
41+
!0 = !{i32 1, !"wchar_size", i32 4}
42+
!1 = !{i32 1, i32 2}
43+
!2 = !{i32 0, i32 100000}
44+
!3 = !{}
45+
46+
; CHECK: [Code|Properties]
47+
; CHECK: {{.*}}_0.ll|{{.*}}_0.prop
48+
; CHECK: {{.*}}_1.ll|{{.*}}_1.prop
49+
50+
; CHECK-IR-0-DAG: define dso_local spir_kernel void @SYCL_kernel1()
51+
; CHECK-IR-0-DAG: define dso_local spir_kernel void @ESIMD_kernel()
52+
; CHECK-IR-0-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
53+
54+
; CHECK-IR-1-DAG: define dso_local spir_kernel void @SYCL_kernel2()
55+
; CHECK-IR-1-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
; RUN: sycl-post-link -split-esimd -split=kernel -S %s -o %t.table
2+
; RUN: FileCheck %s -input-file=%t.table
3+
; RUN: FileCheck %s -input-file=%t_0.ll --check-prefixes CHECK-SYCL-IR-0
4+
; RUN: FileCheck %s -input-file=%t_1.ll --check-prefixes CHECK-SYCL-IR-1
5+
; RUN: FileCheck %s -input-file=%t_esimd_0.ll --check-prefixes CHECK-ESIMD-IR-0
6+
; RUN: FileCheck %s -input-file=%t_esimd_1.ll --check-prefixes CHECK-ESIMD-IR-1
7+
8+
; This test checks that after we split SYCL and ESIMD kernels into
9+
; separate modules, we split those two modules further according to
10+
; -split option. In this case we have 2 SYCL and 2 ESIMD kernels, which
11+
; are split into a total of 4 separate modules.
12+
13+
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
14+
target triple = "spir64-unknown-linux-sycldevice"
15+
16+
declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
17+
18+
define dso_local spir_kernel void @ESIMD_kernel1() #0 !sycl_explicit_simd !3{
19+
entry:
20+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
21+
ret void
22+
}
23+
24+
define dso_local spir_kernel void @ESIMD_kernel2() #0 !sycl_explicit_simd !3{
25+
entry:
26+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
27+
ret void
28+
}
29+
30+
define dso_local spir_kernel void @SYCL_kernel1() #1 {
31+
entry:
32+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
33+
ret void
34+
}
35+
36+
define dso_local spir_kernel void @SYCL_kernel2() #1 {
37+
entry:
38+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
39+
ret void
40+
}
41+
42+
attributes #0 = { "sycl-module-id"="a.cpp" }
43+
attributes #1 = { "sycl-module-id"="a.cpp" }
44+
45+
!llvm.module.flags = !{!0}
46+
!opencl.spir.version = !{!1}
47+
!spirv.Source = !{!2}
48+
49+
!0 = !{i32 1, !"wchar_size", i32 4}
50+
!1 = !{i32 1, i32 2}
51+
!2 = !{i32 0, i32 100000}
52+
!3 = !{}
53+
54+
; CHECK: [Code|Properties]
55+
; CHECK: {{.*}}_0.ll|{{.*}}_0.prop
56+
; CHECK: {{.*}}_1.ll|{{.*}}_1.prop
57+
; CHECK: {{.*}}_esimd_0.ll|{{.*}}_esimd_0.prop
58+
; CHECK: {{.*}}_esimd_1.ll|{{.*}}_esimd_1.prop
59+
60+
; CHECK-SYCL-IR-0-DAG: define dso_local spir_kernel void @SYCL_kernel1()
61+
; CHECK-SYCL-IR-0-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
62+
63+
; CHECK-SYCL-IR-1-DAG: define dso_local spir_kernel void @SYCL_kernel2()
64+
; CHECK-SYCL-IR-1-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
65+
66+
; CHECK-ESIMD-IR-0-DAG: define dso_local spir_kernel void @ESIMD_kernel1()
67+
; CHECK-ESIMD-IR-0-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
68+
69+
; CHECK-ESIMD-IR-1-DAG: define dso_local spir_kernel void @ESIMD_kernel2()
70+
; CHECK-ESIMD-IR-1-DAG: declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()

0 commit comments

Comments
 (0)