Skip to content

Commit ba57ab0

Browse files
jzcsys-ce-bb
authored andcommitted
Update magic value used in named sub group size extension (#2420)
* Update magic value used in named sub group size extension * Remove print Original commit: KhronosGroup/SPIRV-LLVM-Translator@e8e06667df8f5f5
1 parent d524bac commit ba57ab0

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

llvm-spirv/lib/SPIRV/PreprocessMetadata.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ void PreprocessMetadataBase::visit(Module *M) {
168168
// !{void (i32 addrspace(1)*)* @kernel, i32 35, i32 size}
169169
if (MDNode *ReqdSubgroupSize = Kernel.getMetadata(kSPIR2MD::SubgroupSize)) {
170170
// A primary named subgroup size is encoded as
171-
// the metadata intel_reqd_sub_group_size with value 0.
171+
// the metadata intel_reqd_sub_group_size with value -1.
172172
auto Val = getMDOperandAsInt(ReqdSubgroupSize, 0);
173-
if (Val == 0)
173+
if (Val == -1U)
174174
EM.addOp()
175175
.add(&Kernel)
176176
.add(spv::internal::ExecutionModeNamedSubgroupSizeINTEL)

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4184,8 +4184,8 @@ bool SPIRVToLLVM::transMetadata() {
41844184
->getLiterals()[0] == 0 &&
41854185
"Invalid named sub group size");
41864186
// On the LLVM IR side, this is represented as the metadata
4187-
// intel_reqd_sub_group_size with value 0.
4188-
auto *SizeMD = ConstantAsMetadata::get(getUInt32(M, 0));
4187+
// intel_reqd_sub_group_size with value -1.
4188+
auto *SizeMD = ConstantAsMetadata::get(getInt32(M, -1));
41894189
F->setMetadata(kSPIR2MD::SubgroupSize, MDNode::get(*Context, SizeMD));
41904190
}
41914191
// Generate metadata for max_work_group_size

llvm-spirv/test/extensions/INTEL/SPV_INTEL_subgroup_requirements/named_sub_group_sizes.ll

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
; CHECK-SPIRV: ExecutionMode [[kernel]] 6446 0
2020

2121
; CHECK-LLVM: spir_kernel void @_ZTSZ4mainE7Kernel1() {{.*}} !intel_reqd_sub_group_size ![[MD:[0-9]+]]
22-
; CHECK-LLVM: ![[MD]] = !{i32 0}
22+
; CHECK-LLVM: ![[MD]] = !{i32 -1}
2323

24+
; Check that with no SPV_INTEL_subgroup_requirements,
25+
; (1) No SubgroupRequirementsINTEL Capability nor SPV_INTEL_subgroup_requirements extension is attached
26+
; (2) the SubgroupSize (=35) ExecutionMode is attached with the value original value from the LLVM IR
2427
; CHECK-SPIRV-2-NOT: Capability SubgroupRequirementsINTEL
2528
; CHECK-SPIRV-2-NOT: Extension "SPV_INTEL_subgroup_requirements"
2629
; CHECK-SPIRV-2: EntryPoint 6 [[kernel:[0-9]+]] "_ZTSZ4mainE7Kernel1"
27-
; CHECK-SPIRV-2: ExecutionMode [[kernel]] 35 0
30+
; CHECK-SPIRV-2: ExecutionMode [[kernel]] 35 4294967295
2831

2932
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
3033
target triple = "spir64-unknown-unknown"
@@ -51,4 +54,4 @@ attributes #0 = { mustprogress norecurse nounwind "frame-pointer"="all" "no-trap
5154
!4 = !{!"clang version 18.0.0git (/ws/llvm/clang 8fd29b3c2aa9f9ce163be557b51de39c95aaf230)"}
5255
!5 = !{i32 358}
5356
!6 = !{}
54-
!7 = !{i32 0}
57+
!7 = !{i32 -1}

0 commit comments

Comments
 (0)