Skip to content

Commit fabf003

Browse files
DmitryBushevAlexeySachkov
authored andcommitted
Update translator for new Fast Composite extension
SPV_INTEL_fast_composite extension specification separated some decorations and execution modes from SPV_INTEL_vector_compute
1 parent 0dac9b0 commit fabf003

11 files changed

+30
-26
lines changed

include/LLVMSPIRVExtensions.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ EXT(SPV_INTEL_arbitrary_precision_integers)
2222
EXT(SPV_INTEL_optimization_hints)
2323
EXT(SPV_INTEL_float_controls2)
2424
EXT(SPV_INTEL_vector_compute)
25+
EXT(SPV_INTEL_fast_composite)
2526
EXT(SPV_INTEL_usm_storage_classes)
2627
EXT(SPV_INTEL_fpga_buffer_location)
2728
EXT(SPV_INTEL_arbitrary_precision_fixed_point)

lib/SPIRV/PreprocessMetadata.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,7 @@ void PreprocessMetadata::preprocessVectorComputeMetadata(Module *M,
328328
.done();
329329
}
330330
if (Attrs.hasFnAttribute(kVCMetadata::VCFCEntry)) {
331-
EM.addOp()
332-
.add(&F)
333-
.add(spv::ExecutionModeVectorComputeFastCompositeKernelINTEL)
334-
.done();
331+
EM.addOp().add(&F).add(spv::ExecutionModeFastCompositeKernelINTEL).done();
335332
}
336333
}
337334
}

lib/SPIRV/SPIRVReader.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3905,6 +3905,12 @@ bool SPIRVToLLVM::transMetadata() {
39053905
transVectorComputeMetadata(BF);
39063906
transFPGAFunctionMetadata(BF, F);
39073907

3908+
if (BF->hasDecorate(DecorationCallableFunctionINTEL))
3909+
F->addFnAttr(kVCMetadata::VCCallable);
3910+
if (isKernel(BF) &&
3911+
BF->getExecutionMode(ExecutionModeFastCompositeKernelINTEL))
3912+
F->addFnAttr(kVCMetadata::VCFCEntry);
3913+
39083914
if (F->getCallingConv() != CallingConv::SPIR_KERNEL)
39093915
continue;
39103916

@@ -4083,11 +4089,6 @@ bool SPIRVToLLVM::transVectorComputeMetadata(SPIRVFunction *BF) {
40834089
SPIRVWord SIMTMode = 0;
40844090
if (BF->hasDecorate(DecorationSIMTCallINTEL, 0, &SIMTMode))
40854091
F->addFnAttr(kVCMetadata::VCSIMTCall, std::to_string(SIMTMode));
4086-
if (BF->hasDecorate(DecorationVectorComputeCallableFunctionINTEL))
4087-
F->addFnAttr(kVCMetadata::VCCallable);
4088-
if (isKernel(BF) &&
4089-
BF->getExecutionMode(ExecutionModeVectorComputeFastCompositeKernelINTEL))
4090-
F->addFnAttr(kVCMetadata::VCFCEntry);
40914092

40924093
auto SEVAttr = Attribute::get(*Context, kVCMetadata::VCSingleElementVector);
40934094
if (BF->hasDecorate(DecorationSingleElementVectorINTEL))

lib/SPIRV/SPIRVWriter.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,11 @@ SPIRVFunction *LLVMToSPIRV::transFunctionDecl(Function *F) {
615615
BF->addDecorate(DecorationReferencedIndirectlyINTEL);
616616
}
617617

618+
if (Attrs.hasFnAttribute(kVCMetadata::VCCallable) &&
619+
BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_fast_composite)) {
620+
BF->addDecorate(DecorationCallableFunctionINTEL);
621+
}
622+
618623
if (BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute))
619624
transVectorComputeMetadata(F);
620625

@@ -648,10 +653,6 @@ void LLVMToSPIRV::transVectorComputeMetadata(Function *F) {
648653
BF->addDecorate(DecorationSIMTCallINTEL, SIMTMode);
649654
}
650655

651-
if (Attrs.hasFnAttribute(kVCMetadata::VCCallable)) {
652-
BF->addDecorate(DecorationVectorComputeCallableFunctionINTEL);
653-
}
654-
655656
if (Attrs.hasAttribute(AttributeList::ReturnIndex,
656657
kVCMetadata::VCSingleElementVector)) {
657658
auto *RT = BF->getType();
@@ -3386,8 +3387,8 @@ bool LLVMToSPIRV::transExecutionMode() {
33863387
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
33873388
BF, static_cast<ExecutionMode>(EMode), TargetWidth)));
33883389
} break;
3389-
case spv::ExecutionModeVectorComputeFastCompositeKernelINTEL: {
3390-
if (BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute))
3390+
case spv::ExecutionModeFastCompositeKernelINTEL: {
3391+
if (BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_fast_composite))
33913392
BF->addExecutionMode(BM->add(
33923393
new SPIRVExecutionMode(BF, static_cast<ExecutionMode>(EMode))));
33933394
} break;

lib/SPIRV/libSPIRV/SPIRVDecorate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ class SPIRVDecorate : public SPIRVDecorateGeneric {
190190
return ExtensionID::SPV_INTEL_fpga_cluster_attributes;
191191
case DecorationFuseLoopsInFunctionINTEL:
192192
return ExtensionID::SPV_INTEL_loop_fuse;
193+
case DecorationCallableFunctionINTEL:
194+
return ExtensionID::SPV_INTEL_fast_composite;
193195
default:
194196
return {};
195197
}

lib/SPIRV/libSPIRV/SPIRVEntry.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,8 @@ class SPIRVCapability : public SPIRVEntryNoId<OpCapability> {
842842
case CapabilityVectorComputeINTEL:
843843
case CapabilityVectorAnyINTEL:
844844
return ExtensionID::SPV_INTEL_vector_compute;
845+
case CapabilityFastCompositeINTEL:
846+
return ExtensionID::SPV_INTEL_fast_composite;
845847
default:
846848
return {};
847849
}

lib/SPIRV/libSPIRV/SPIRVEnum.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ template <> inline void SPIRVMap<SPIRVExecutionModeKind, SPIRVCapVec>::init() {
252252
{CapabilityFloatingPointModeINTEL});
253253
ADD_VEC_INIT(ExecutionModeSharedLocalMemorySizeINTEL,
254254
{CapabilityVectorComputeINTEL});
255-
ADD_VEC_INIT(ExecutionModeVectorComputeFastCompositeKernelINTEL,
256-
{CapabilityVectorComputeINTEL});
255+
ADD_VEC_INIT(ExecutionModeFastCompositeKernelINTEL,
256+
{CapabilityFastCompositeINTEL});
257257
}
258258

259259
template <> inline void SPIRVMap<SPIRVMemoryModelKind, SPIRVCapVec>::init() {
@@ -414,8 +414,7 @@ template <> inline void SPIRVMap<Decoration, SPIRVCapVec>::init() {
414414
{CapabilityFunctionFloatControlINTEL});
415415
ADD_VEC_INIT(DecorationSingleElementVectorINTEL,
416416
{CapabilityVectorComputeINTEL});
417-
ADD_VEC_INIT(DecorationVectorComputeCallableFunctionINTEL,
418-
{CapabilityVectorComputeINTEL});
417+
ADD_VEC_INIT(DecorationCallableFunctionINTEL, {CapabilityFastCompositeINTEL});
419418
ADD_VEC_INIT(DecorationStallEnableINTEL,
420419
{CapabilityFPGAClusterAttributesINTEL});
421420
ADD_VEC_INIT(DecorationFuseLoopsInFunctionINTEL, {CapabilityLoopFuseINTEL});

lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ template <> inline void SPIRVMap<Decoration, std::string>::init() {
163163
add(DecorationFunctionFloatingPointModeINTEL,
164164
"FunctionFloatingPointModeINTEL");
165165
add(DecorationSingleElementVectorINTEL, "SingleElementVectorINTEL");
166-
add(DecorationVectorComputeCallableFunctionINTEL,
167-
"VectorComputeCallableFunctionINTEL");
166+
add(DecorationCallableFunctionINTEL, "CallableFunctionINTEL");
168167
add(DecorationStallEnableINTEL, "StallEnableINTEL");
169168
add(DecorationFuseLoopsInFunctionINTEL, "FuseLoopsInFunctionINTEL");
170169
add(DecorationMax, "Max");
@@ -511,6 +510,7 @@ template <> inline void SPIRVMap<Capability, std::string>::init() {
511510
add(CapabilityLoopFuseINTEL, "LoopFuseINTEL");
512511
add(CapabilityMax, "Max");
513512
add(CapabilityLongConstantCompositeINTEL, "LongConstantCompositeINTEL");
513+
add(CapabilityFastCompositeINTEL, "FastCompositeINTEL");
514514
}
515515
SPIRV_DEF_NAMEMAP(Capability, SPIRVCapabilityNameMap)
516516

lib/SPIRV/libSPIRV/spirv.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ enum ExecutionMode {
178178
ExecutionModeNoGlobalOffsetINTEL = 5895,
179179
ExecutionModeNumSIMDWorkitemsINTEL = 5896,
180180
ExecutionModeSchedulerTargetFmaxMhzINTEL = 5903,
181-
ExecutionModeVectorComputeFastCompositeKernelINTEL = 6088,
181+
ExecutionModeFastCompositeKernelINTEL = 6088,
182182
ExecutionModeMax = 0x7fffffff,
183183
};
184184

@@ -547,7 +547,7 @@ enum Decoration {
547547
DecorationIOPipeStorageINTEL = 5944,
548548
DecorationFunctionFloatingPointModeINTEL = 6080,
549549
DecorationSingleElementVectorINTEL = 6085,
550-
DecorationVectorComputeCallableFunctionINTEL = 6087,
550+
DecorationCallableFunctionINTEL = 6087,
551551
DecorationMax = 0x7fffffff,
552552
};
553553

@@ -1047,6 +1047,7 @@ enum Capability {
10471047
CapabilityAtomicFloat32AddEXT = 6033,
10481048
CapabilityAtomicFloat64AddEXT = 6034,
10491049
CapabilityLongConstantCompositeINTEL = 6089,
1050+
CapabilityFastCompositeINTEL = 6093,
10501051
CapabilityMax = 0x7fffffff,
10511052
};
10521053

test/callable-attribute-decoration.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; RUN: llvm-as %s -o %t.bc
2-
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_INTEL_vector_compute
2+
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_INTEL_fast_composite
33
; RUN: llvm-spirv %t.spv -o %t.spt --to-text
44
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
55
; RUN: llvm-spirv %t.spv -o %t.bc -r
@@ -12,7 +12,7 @@ define dso_local <4 x i32> @foo(<4 x i32> %a, <4 x i32> %b) #0 {
1212
entry:
1313
ret <4 x i32> %a
1414
}
15-
; CHECK-SPIRV: 3 Decorate {{[0-9]+}} VectorComputeCallableFunctionINTEL
15+
; CHECK-SPIRV: 3 Decorate {{[0-9]+}} CallableFunctionINTEL
1616
; CHECK-LLVM: attributes
1717
; CHECK-LLVM-SAME: "VCCallable"
1818

test/fast-composit-entry.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; RUN: llvm-as %s -o %t.bc
2-
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_INTEL_vector_compute
2+
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_INTEL_fast_composite
33
; RUN: llvm-spirv %t.spv -o %t.spt --to-text
44
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
55
; RUN: llvm-spirv %t.spv -o %t.bc -r

0 commit comments

Comments
 (0)