Skip to content

Commit 3017ff6

Browse files
committed
[NFC] Verify cl_intel_subgroup_local_block_io extension in SPIR-V BE
1 parent dd7a3d4 commit 3017ff6

File tree

2 files changed

+166
-3
lines changed

2 files changed

+166
-3
lines changed

llvm/lib/Target/SPIRV/SPIRVBuiltins.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,10 +1197,10 @@ defm : DemangledIntelSubgroupsBuiltin<"shuffle_down", 3, 3, OpSubgroupShuffleDow
11971197
defm : DemangledIntelSubgroupsBuiltin<"shuffle_up", 3, 3, OpSubgroupShuffleUpINTEL>;
11981198
defm : DemangledIntelSubgroupsBuiltin<"shuffle_xor", 2, 2, OpSubgroupShuffleXorINTEL>;
11991199
foreach i = ["", "2", "4", "8"] in {
1200-
// cl_intel_subgroups
1200+
// cl_intel_subgroups, cl_intel_subgroup_local_block_io
12011201
defm : DemangledIntelSubgroupsBuiltin<!strconcat("block_read", i), 1, 2, OpSubgroupBlockReadINTEL>;
12021202
defm : DemangledIntelSubgroupsBuiltin<!strconcat("block_write", i), 2, 3, OpSubgroupBlockWriteINTEL>;
1203-
// cl_intel_subgroups_short
1203+
// cl_intel_subgroups_short, cl_intel_subgroup_local_block_io
12041204
defm : DemangledIntelSubgroupsBuiltin<!strconcat("block_read_ui", i), 1, 2, OpSubgroupBlockReadINTEL>;
12051205
defm : DemangledIntelSubgroupsBuiltin<!strconcat("block_write_ui", i), 2, 3, OpSubgroupBlockWriteINTEL>;
12061206
// cl_intel_media_block_io
@@ -1209,7 +1209,7 @@ foreach i = ["", "2", "4", "8"] in {
12091209
defm : DemangledIntelSubgroupsBuiltin<!strconcat("media_block_write", i), 5, 5, OpSubgroupImageMediaBlockWriteINTEL>;
12101210
defm : DemangledIntelSubgroupsBuiltin<!strconcat("media_block_write_ui", i), 5, 5, OpSubgroupImageMediaBlockWriteINTEL>;
12111211
}
1212-
// cl_intel_subgroups_char, cl_intel_subgroups_short, cl_intel_subgroups_long, cl_intel_media_block_io
1212+
// cl_intel_subgroups_char, cl_intel_subgroups_short, cl_intel_subgroups_long, cl_intel_media_block_io, cl_intel_subgroup_local_block_io
12131213
foreach i = ["", "2", "4", "8", "16"] in {
12141214
foreach j = ["c", "s", "l"] in {
12151215
defm : DemangledIntelSubgroupsBuiltin<!strconcat("block_read_u", j, i), 1, 2, OpSubgroupBlockReadINTEL>;
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
; Modified from: https://github.com/KhronosGroup/SPIRV-LLVM-Translator/test/extensions/INTEL/SPV_INTEL_subgroups/cl_intel_sub_groups.ll
2+
3+
;Source:
4+
;void __kernel test(float2 x, uint c,
5+
; read_only image2d_t image_in,
6+
; write_only image2d_t image_out,
7+
; int2 coord,
8+
; __local uint* p,
9+
; __local ushort* sp,
10+
; __local uchar* cp,
11+
; __local ulong* lp) {
12+
;
13+
; uint2 ui2 = intel_sub_group_block_read2(image_in, coord);
14+
; intel_sub_group_block_write2(image_out, coord, ui2);
15+
; ui2 = intel_sub_group_block_read2(p);
16+
; intel_sub_group_block_write2(p, ui2);
17+
;
18+
; ushort2 us2 = intel_sub_group_block_read_us2(image_in, coord);
19+
; intel_sub_group_block_write_us2(image_out, coord, us2);
20+
; us2 = intel_sub_group_block_read_us2(sp);
21+
; intel_sub_group_block_write_us2(sp, us2);
22+
;
23+
; uchar2 uc2 = intel_sub_group_block_read_uc2(image_in, coord);
24+
; intel_sub_group_block_write_uc2(image_out, coord, uc2);
25+
; uc2 = intel_sub_group_block_read_uc2(cp);
26+
; intel_sub_group_block_write_uc2(cp, uc2);
27+
;
28+
; ulong2 ul2 = intel_sub_group_block_read_ul2(image_in, coord);
29+
; intel_sub_group_block_write_ul2(image_out, coord, ul2);
30+
; ul2 = intel_sub_group_block_read_ul2(lp);
31+
; intel_sub_group_block_write_ul2(lp, ul2);
32+
;}
33+
34+
; RUN: not llc -O0 -mtriple=spirv32-unknown-unknown %s -o %t.spvt 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
35+
36+
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_INTEL_subgroups %s -o - | FileCheck %s
37+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_INTEL_subgroups %s -o - -filetype=obj | spirv-val %}
38+
39+
; CHECK-ERROR: LLVM ERROR: intel_sub_group_block_read2: the builtin requires the following SPIR-V extension: SPV_INTEL_subgroups
40+
41+
; CHECK-DAG: Capability SubgroupBufferBlockIOINTEL
42+
; CHECK-DAG: Capability SubgroupImageBlockIOINTEL
43+
; CHECK: Extension "SPV_INTEL_subgroups"
44+
45+
; CHECK-SPIRV-LABEL: Function
46+
; CHECK-SPIRV-LABEL: Label
47+
48+
; CHECK: SubgroupImageBlockReadINTEL
49+
; CHECK: SubgroupImageBlockWriteINTEL
50+
; CHECK: SubgroupBlockReadINTEL
51+
; CHECK: SubgroupBlockWriteINTEL
52+
53+
; CHECK: SubgroupImageBlockReadINTEL
54+
; CHECK: SubgroupImageBlockWriteINTEL
55+
; CHECK: SubgroupBlockReadINTEL
56+
; CHECK: SubgroupBlockWriteINTEL
57+
58+
; CHECK: SubgroupImageBlockReadINTEL
59+
; CHECK: SubgroupImageBlockWriteINTEL
60+
; CHECK: SubgroupBlockReadINTEL
61+
; CHECK: SubgroupBlockWriteINTEL
62+
63+
; CHECK: SubgroupImageBlockReadINTEL
64+
; CHECK: SubgroupImageBlockWriteINTEL
65+
; CHECK: SubgroupBlockReadINTEL
66+
; CHECK: SubgroupBlockWriteINTEL
67+
68+
; CHECK-SPIRV-LABEL: Return
69+
70+
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
71+
target triple = "spir64"
72+
73+
%opencl.image2d_ro_t = type opaque
74+
%opencl.image2d_wo_t = type opaque
75+
76+
; Function Attrs: convergent nounwind
77+
define spir_kernel void @test(<2 x float> %x, i32 %c, ptr addrspace(3) %image_in, ptr addrspace(3) %image_out, <2 x i32> %coord, ptr addrspace(3) %p, ptr addrspace(3) %sp, ptr addrspace(3) %cp, ptr addrspace(3) %lp) local_unnamed_addr #0 !kernel_arg_addr_space !1 !kernel_arg_access_qual !2 !kernel_arg_type !3 !kernel_arg_base_type !4 !kernel_arg_type_qual !5 !kernel_arg_name !6 {
78+
entry:
79+
%call4 = tail call spir_func <2 x i32> @_Z27intel_sub_group_block_read214ocl_image2d_roDv2_i(ptr addrspace(3) %image_in, <2 x i32> %coord) #2
80+
tail call spir_func void @_Z28intel_sub_group_block_write214ocl_image2d_woDv2_iDv2_j(ptr addrspace(3) %image_out, <2 x i32> %coord, <2 x i32> %call4) #2
81+
%call5 = tail call spir_func <2 x i32> @_Z27intel_sub_group_block_read2PU3AS1Kj(ptr addrspace(3) %p) #2
82+
tail call spir_func void @_Z28intel_sub_group_block_write2PU3AS1jDv2_j(ptr addrspace(3) %p, <2 x i32> %call5) #2
83+
84+
%call6 = tail call spir_func <2 x i16> @_Z30intel_sub_group_block_read_us214ocl_image2d_roDv2_i(ptr addrspace(3) %image_in, <2 x i32> %coord) #2
85+
tail call spir_func void @_Z31intel_sub_group_block_write_us214ocl_image2d_woDv2_iDv2_t(ptr addrspace(3) %image_out, <2 x i32> %coord, <2 x i16> %call6) #2
86+
%call7 = tail call spir_func <2 x i16> @_Z30intel_sub_group_block_read_us2PU3AS1Kt(ptr addrspace(3) %sp) #2
87+
tail call spir_func void @_Z31intel_sub_group_block_write_us2PU3AS1tDv2_t(ptr addrspace(3) %sp, <2 x i16> %call7) #2
88+
89+
%call8 = tail call spir_func <2 x i8> @_Z30intel_sub_group_block_read_uc214ocl_image2d_roDv2_i(ptr addrspace(3) %image_in, <2 x i32> %coord) #2
90+
tail call spir_func void @_Z31intel_sub_group_block_write_uc214ocl_image2d_woDv2_iDv2_h(ptr addrspace(3) %image_out, <2 x i32> %coord, <2 x i8> %call8) #2
91+
%call9 = tail call spir_func <2 x i8> @_Z30intel_sub_group_block_read_uc2PU3AS1Kh(ptr addrspace(3) %cp) #2
92+
tail call spir_func void @_Z31intel_sub_group_block_write_uc2PU3AS1hDv2_h(ptr addrspace(3) %cp, <2 x i8> %call9) #2
93+
94+
%call10 = tail call spir_func <2 x i64> @_Z30intel_sub_group_block_read_ul214ocl_image2d_roDv2_i(ptr addrspace(3) %image_in, <2 x i32> %coord) #2
95+
tail call spir_func void @_Z31intel_sub_group_block_write_ul214ocl_image2d_woDv2_iDv2_m(ptr addrspace(3) %image_out, <2 x i32> %coord, <2 x i64> %call10) #2
96+
%call11 = tail call spir_func <2 x i64> @_Z30intel_sub_group_block_read_ul2PU3AS1Km(ptr addrspace(3) %lp) #2
97+
tail call spir_func void @_Z31intel_sub_group_block_write_ul2PU3AS1mDv2_m(ptr addrspace(3) %lp, <2 x i64> %call11) #2
98+
99+
ret void
100+
}
101+
102+
; Function Attrs: convergent
103+
declare spir_func <2 x i32> @_Z27intel_sub_group_block_read214ocl_image2d_roDv2_i(ptr addrspace(3), <2 x i32>) local_unnamed_addr #1
104+
105+
; Function Attrs: convergent
106+
declare spir_func void @_Z28intel_sub_group_block_write214ocl_image2d_woDv2_iDv2_j(ptr addrspace(3), <2 x i32>, <2 x i32>) local_unnamed_addr #1
107+
108+
; Function Attrs: convergent
109+
declare spir_func <2 x i32> @_Z27intel_sub_group_block_read2PU3AS1Kj(ptr addrspace(3)) local_unnamed_addr #1
110+
111+
; Function Attrs: convergent
112+
declare spir_func void @_Z28intel_sub_group_block_write2PU3AS1jDv2_j(ptr addrspace(3), <2 x i32>) local_unnamed_addr #1
113+
114+
; Function Attrs: convergent
115+
declare spir_func <2 x i16> @_Z30intel_sub_group_block_read_us214ocl_image2d_roDv2_i(ptr addrspace(3), <2 x i32>) local_unnamed_addr #1
116+
117+
; Function Attrs: convergent
118+
declare spir_func void @_Z31intel_sub_group_block_write_us214ocl_image2d_woDv2_iDv2_t(ptr addrspace(3), <2 x i32>, <2 x i16>) local_unnamed_addr #1
119+
120+
; Function Attrs: convergent
121+
declare spir_func <2 x i16> @_Z30intel_sub_group_block_read_us2PU3AS1Kt(ptr addrspace(3)) local_unnamed_addr #1
122+
123+
; Function Attrs: convergent
124+
declare spir_func void @_Z31intel_sub_group_block_write_us2PU3AS1tDv2_t(ptr addrspace(3), <2 x i16>) local_unnamed_addr #1
125+
126+
; Function Attrs: convergent
127+
declare spir_func <2 x i8> @_Z30intel_sub_group_block_read_uc214ocl_image2d_roDv2_i(ptr addrspace(3), <2 x i32>) local_unnamed_addr #1
128+
129+
; Function Attrs: convergent
130+
declare spir_func void @_Z31intel_sub_group_block_write_uc214ocl_image2d_woDv2_iDv2_h(ptr addrspace(3), <2 x i32>, <2 x i8>) local_unnamed_addr #1
131+
132+
; Function Attrs: convergent
133+
declare spir_func <2 x i8> @_Z30intel_sub_group_block_read_uc2PU3AS1Kh(ptr addrspace(3)) local_unnamed_addr #1
134+
135+
; Function Attrs: convergent
136+
declare spir_func void @_Z31intel_sub_group_block_write_uc2PU3AS1hDv2_h(ptr addrspace(3), <2 x i8>) local_unnamed_addr #1
137+
138+
; Function Attrs: convergent
139+
declare spir_func <2 x i64> @_Z30intel_sub_group_block_read_ul214ocl_image2d_roDv2_i(ptr addrspace(3), <2 x i32>) local_unnamed_addr #1
140+
141+
; Function Attrs: convergent
142+
declare spir_func void @_Z31intel_sub_group_block_write_ul214ocl_image2d_woDv2_iDv2_m(ptr addrspace(3), <2 x i32>, <2 x i64>) local_unnamed_addr #1
143+
144+
; Function Attrs: convergent
145+
declare spir_func <2 x i64> @_Z30intel_sub_group_block_read_ul2PU3AS1Km(ptr addrspace(3)) local_unnamed_addr #1
146+
147+
; Function Attrs: convergent
148+
declare spir_func void @_Z31intel_sub_group_block_write_ul2PU3AS1mDv2_m(ptr addrspace(3), <2 x i64>) local_unnamed_addr #1
149+
150+
attributes #0 = { convergent nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "denorms-are-zero"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="128" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" "unsafe-fp-math"="false" "use-soft-float"="false" }
151+
attributes #1 = { convergent "correctly-rounded-divide-sqrt-fp-math"="false" "denorms-are-zero"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
152+
attributes #2 = { convergent nounwind }
153+
154+
!opencl.ocl.version = !{!0}
155+
!opencl.spir.version = !{!0}
156+
157+
!0 = !{i32 1, i32 2}
158+
!1 = !{i32 0, i32 0, i32 1, i32 1, i32 0, i32 1, i32 1, i32 1, i32 1}
159+
!2 = !{!"none", !"none", !"read_only", !"write_only", !"none", !"none", !"none", !"none", !"none"}
160+
!3 = !{!"float2", !"uint", !"image2d_t", !"image2d_t", !"int2", !"uint*", !"ushort*", !"uchar*", !"ulong*"}
161+
!4 = !{!"float __attribute__((ext_vector_type(2)))", !"uint", !"image2d_t", !"image2d_t", !"int __attribute__((ext_vector_type(2)))", !"uint*", !"ushort*", !"uchar*", !"ulong*"}
162+
!5 = !{!"", !"", !"", !"", !"", !"", !"", !"", !""}
163+
!6 = !{!"x", !"c", !"image_in", !"image_out", !"coord", !"p", !"sp", !"cp", !"lp"}

0 commit comments

Comments
 (0)