Skip to content

Commit 147eb5f

Browse files
[sycl-post-link] Split SYCL and ESIMD kernels into separate modules
For now this change doesn't have any effect on existing programs since we don't allow mixing SYCL and ESIMD kernels in one source or in one program. But this is an essential step towards this goal since ESIMD kernels require specific processing as opposed to usual SYCL kernels.
1 parent 0fde11d commit 147eb5f

File tree

6 files changed

+375
-22
lines changed

6 files changed

+375
-22
lines changed
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: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
; RUN: sycl-post-link -split=auto -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() #1 {
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+
attributes #1 = { "sycl-module-id"="a.cpp" }
28+
29+
!llvm.module.flags = !{!0}
30+
!opencl.spir.version = !{!1}
31+
!spirv.Source = !{!2}
32+
33+
!0 = !{i32 1, !"wchar_size", i32 4}
34+
!1 = !{i32 1, i32 2}
35+
!2 = !{i32 0, i32 100000}
36+
!3 = !{}
37+
38+
; CHECK: [Code|Properties]
39+
; CHECK: {{.*}}_0.ll|{{.*}}_0.prop
40+
; CHECK: {{.*}}_esimd_0.ll|{{.*}}_esimd_0.prop
41+
42+
; CHECK-SYCL-IR: define dso_local spir_kernel void @SYCL_kernel()
43+
44+
; CHECK-ESIMD-IR: define dso_local spir_kernel void @ESIMD_kernel()
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
; RUN: sycl-post-link -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: define dso_local spir_kernel void @SYCL_kernel1()
61+
; CHECK-SYCL-IR-1: define dso_local spir_kernel void @SYCL_kernel2()
62+
63+
; CHECK-ESIMD-IR-0: define dso_local spir_kernel void @ESIMD_kernel1()
64+
; CHECK-ESIMD-IR-1: define dso_local spir_kernel void @ESIMD_kernel2()
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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-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:
11+
; - 3 SYCL kernels: 2 in a.cpp, 1 in b.cpp
12+
; - 3 ESIMD kernels: 2 in a.cpp, 1 in b.cpp
13+
; The module will be split into a total of 4 separate modules.
14+
15+
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
16+
target triple = "spir64-unknown-linux-sycldevice"
17+
18+
declare dso_local spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
19+
20+
define dso_local spir_kernel void @ESIMD_kernel1() #0 !sycl_explicit_simd !3{
21+
entry:
22+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
23+
ret void
24+
}
25+
26+
define dso_local spir_kernel void @ESIMD_kernel2() #0 !sycl_explicit_simd !3{
27+
entry:
28+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
29+
ret void
30+
}
31+
32+
define dso_local spir_kernel void @ESIMD_kernel3() #1 !sycl_explicit_simd !3{
33+
entry:
34+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
35+
ret void
36+
}
37+
38+
define dso_local spir_kernel void @SYCL_kernel1() #0 {
39+
entry:
40+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
41+
ret void
42+
}
43+
44+
define dso_local spir_kernel void @SYCL_kernel2() #0 {
45+
entry:
46+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
47+
ret void
48+
}
49+
50+
define dso_local spir_kernel void @SYCL_kernel3() #1 {
51+
entry:
52+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
53+
ret void
54+
}
55+
56+
attributes #0 = { "sycl-module-id"="a.cpp" }
57+
attributes #1 = { "sycl-module-id"="b.cpp" }
58+
59+
!llvm.module.flags = !{!0}
60+
!opencl.spir.version = !{!1}
61+
!spirv.Source = !{!2}
62+
63+
!0 = !{i32 1, !"wchar_size", i32 4}
64+
!1 = !{i32 1, i32 2}
65+
!2 = !{i32 0, i32 100000}
66+
!3 = !{}
67+
68+
; CHECK: [Code|Properties]
69+
; CHECK: {{.*}}_0.ll|{{.*}}_0.prop
70+
; CHECK: {{.*}}_1.ll|{{.*}}_1.prop
71+
; CHECK: {{.*}}_esimd_0.ll|{{.*}}_esimd_0.prop
72+
; CHECK: {{.*}}_esimd_1.ll|{{.*}}_esimd_1.prop
73+
74+
; CHECK-SYCL-IR-0: define dso_local spir_kernel void @SYCL_kernel1()
75+
; CHECK-SYCL-IR-0: define dso_local spir_kernel void @SYCL_kernel2()
76+
; CHECK-SYCL-IR-1: define dso_local spir_kernel void @SYCL_kernel3()
77+
78+
; CHECK-ESIMD-IR-0: define dso_local spir_kernel void @ESIMD_kernel1()
79+
; CHECK-ESIMD-IR-0: define dso_local spir_kernel void @ESIMD_kernel2()
80+
; CHECK-ESIMD-IR-1: define dso_local spir_kernel void @ESIMD_kernel3()
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
; RUN: sycl-post-link -symbols -S %s -o %t.table
2+
; RUN: FileCheck %s -input-file=%t.table
3+
; RUN: FileCheck %s -input-file=%t_0.sym --check-prefixes CHECK-SYCL-SYM
4+
; RUN: FileCheck %s -input-file=%t_esimd_0.sym --check-prefixes CHECK-ESIMD-SYM
5+
6+
; This test checks symbols generation when we split SYCL and ESIMD kernels into
7+
; separate 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_kernel1() #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 @ESIMD_kernel2() #0 !sycl_explicit_simd !3{
21+
entry:
22+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
23+
ret void
24+
}
25+
26+
define dso_local spir_kernel void @SYCL_kernel1() #0 {
27+
entry:
28+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
29+
ret void
30+
}
31+
32+
define dso_local spir_kernel void @SYCL_kernel2() #0 {
33+
entry:
34+
%call = tail call spir_func i64 @_Z28__spirv_GlobalInvocationId_xv()
35+
ret void
36+
}
37+
38+
attributes #0 = { "sycl-module-id"="a.cpp" }
39+
attributes #1 = { "sycl-module-id"="b.cpp" }
40+
41+
!llvm.module.flags = !{!0}
42+
!opencl.spir.version = !{!1}
43+
!spirv.Source = !{!2}
44+
45+
!0 = !{i32 1, !"wchar_size", i32 4}
46+
!1 = !{i32 1, i32 2}
47+
!2 = !{i32 0, i32 100000}
48+
!3 = !{}
49+
50+
; CHECK: [Code|Properties|Symbols]
51+
; CHECK: {{.*}}_0.ll|{{.*}}_0.prop|{{.*}}_0.sym
52+
; CHECK: {{.*}}_esimd_0.ll|{{.*}}_esimd_0.prop|{{.*}}_esimd_0.sym
53+
54+
; CHECK-SYCL-SYM: SYCL_kernel1
55+
; CHECK-SYCL-SYM: SYCL_kernel2
56+
57+
; CHECK-ESIMD-SYM: ESIMD_kernel1
58+
; CHECK-ESIMD-SYM: ESIMD_kernel2

0 commit comments

Comments
 (0)