Skip to content

Commit fc5452f

Browse files
NikitaRudenkoIntelvmustya
authored andcommitted
[Backport to 12] Update SPV_INTEL_vector_compute to rev 15
This adds NamedBarrierCountINTEL Execution Mode, see more in intel/llvm#1612
1 parent 1814d1f commit fc5452f

File tree

8 files changed

+68
-0
lines changed

8 files changed

+68
-0
lines changed

lib/SPIRV/PreprocessMetadata.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,20 @@ void PreprocessMetadata::preprocessVectorComputeMetadata(Module *M,
330330
if (Attrs.hasFnAttribute(kVCMetadata::VCFCEntry)) {
331331
EM.addOp().add(&F).add(spv::ExecutionModeFastCompositeKernelINTEL).done();
332332
}
333+
334+
if (Attrs.hasFnAttribute(kVCMetadata::VCNamedBarrierCount)) {
335+
SPIRVWord NBarrierCnt = 0;
336+
Attrs
337+
.getAttribute(AttributeList::FunctionIndex,
338+
kVCMetadata::VCNamedBarrierCount)
339+
.getValueAsString()
340+
.getAsInteger(0, NBarrierCnt);
341+
EM.addOp()
342+
.add(&F)
343+
.add(spv::ExecutionModeNamedBarrierCountINTEL)
344+
.add(NBarrierCnt)
345+
.done();
346+
}
333347
}
334348
}
335349

lib/SPIRV/SPIRVReader.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3780,6 +3780,13 @@ bool SPIRVToLLVM::transVectorComputeMetadata(SPIRVFunction *BF) {
37803780
F->addAttribute(AttributeList::FunctionIndex, Attr);
37813781
}
37823782

3783+
if (auto *EM = BF->getExecutionMode(ExecutionModeNamedBarrierCountINTEL)) {
3784+
unsigned int NBarrierCnt = EM->getLiterals()[0];
3785+
Attribute Attr = Attribute::get(*Context, kVCMetadata::VCNamedBarrierCount,
3786+
std::to_string(NBarrierCnt));
3787+
F->addAttribute(AttributeList::FunctionIndex, Attr);
3788+
}
3789+
37833790
return true;
37843791
}
37853792

lib/SPIRV/SPIRVWriter.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3549,6 +3549,16 @@ bool LLVMToSPIRV::transExecutionMode() {
35493549
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
35503550
BF, static_cast<ExecutionMode>(EMode), SLMSize)));
35513551
} break;
3552+
case spv::ExecutionModeNamedBarrierCountINTEL: {
3553+
if (!BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute))
3554+
break;
3555+
unsigned NBarrierCnt = 0;
3556+
N.get(NBarrierCnt);
3557+
BF->addExecutionMode(new SPIRVExecutionMode(
3558+
BF, static_cast<ExecutionMode>(EMode), NBarrierCnt));
3559+
BM->addExtension(ExtensionID::SPV_INTEL_vector_compute);
3560+
BM->addCapability(CapabilityVectorComputeINTEL);
3561+
} break;
35523562

35533563
case spv::ExecutionModeDenormPreserve:
35543564
case spv::ExecutionModeDenormFlushToZero:

lib/SPIRV/VectorComputeUtil.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ const static char VCCallable[] = "VCCallable";
112112
const static char VCSingleElementVector[] = "VCSingleElementVector";
113113
const static char VCFCEntry[] = "VCFCEntry";
114114
const static char VCMediaBlockIO[] = "VCMediaBlockIO";
115+
const static char VCNamedBarrierCount[] = "VCNamedBarrierCount";
115116
} // namespace kVCMetadata
116117

117118
namespace kVCType {

lib/SPIRV/libSPIRV/SPIRVEntry.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ void SPIRVExecutionMode::decode(std::istream &I) {
571571
case ExecutionModeFloatingPointModeALTINTEL:
572572
case ExecutionModeFloatingPointModeIEEEINTEL:
573573
case ExecutionModeSharedLocalMemorySizeINTEL:
574+
case ExecutionModeNamedBarrierCountINTEL:
574575
case ExecutionModeSubgroupSize:
575576
case ExecutionModeMaxWorkDimINTEL:
576577
case ExecutionModeNumSIMDWorkitemsINTEL:

lib/SPIRV/libSPIRV/SPIRVEnum.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ template <> inline void SPIRVMap<SPIRVExecutionModeKind, SPIRVCapVec>::init() {
255255
{CapabilityVectorComputeINTEL});
256256
ADD_VEC_INIT(ExecutionModeFastCompositeKernelINTEL,
257257
{CapabilityFastCompositeINTEL});
258+
ADD_VEC_INIT(ExecutionModeNamedBarrierCountINTEL,
259+
{CapabilityVectorComputeINTEL});
258260
}
259261

260262
template <> inline void SPIRVMap<SPIRVMemoryModelKind, SPIRVCapVec>::init() {

lib/SPIRV/libSPIRV/spirv.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ enum ExecutionMode {
180180
ExecutionModeNumSIMDWorkitemsINTEL = 5896,
181181
ExecutionModeSchedulerTargetFmaxMhzINTEL = 5903,
182182
ExecutionModeFastCompositeKernelINTEL = 6088,
183+
ExecutionModeNamedBarrierCountINTEL = 6417,
183184
ExecutionModeMax = 0x7fffffff,
184185
};
185186

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
; RUN: llvm-as %s -o %t.bc
2+
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_INTEL_vector_compute
3+
; RUN: llvm-spirv %t.spv -o %t.spt --to-text
4+
; RUN: llvm-spirv -r %t.spv -o %t.bc
5+
; RUN: llvm-dis %t.bc -o %t.ll
6+
; RUN: FileCheck %s --input-file %t.spt -check-prefix=SPV
7+
; RUN: FileCheck %s --input-file %t.ll -check-prefix=LLVM
8+
9+
; ModuleID = 'slm.bc'
10+
source_filename = "slm.cpp"
11+
target datalayout = "e-p:64:64-i64:64-n8:16:32"
12+
target triple = "spir"
13+
14+
; LLVM-DAG: @k_rte{{[^a-zA-Z0-9_][^#]*}}#[[K_RTE:[0-9]+]]
15+
; LLVM-DAG: attributes #[[K_RTE]]{{[^0-9].*"VCNamedBarrierCount"="8"}}
16+
; SPV-DAG: Extension "SPV_INTEL_vector_compute"
17+
; SPV-DAG: Capability VectorComputeINTEL
18+
; SPV: EntryPoint {{[0-9]+}} [[S_RTE:[0-9]+]] "k_rte"
19+
; SPV: ExecutionMode [[S_RTE]] 6417 8
20+
; Function Attrs: noinline norecurse nounwind readnone
21+
define dso_local dllexport spir_kernel void @k_rte(i32 %ibuf, i32 %obuf) local_unnamed_addr #1 {
22+
entry:
23+
ret void
24+
}
25+
26+
attributes #1 = { noinline norecurse nounwind readnone "VCMain" "VCFunction" "VCNamedBarrierCount"="8" "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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" "unsafe-fp-math"="false" "use-soft-float"="false" }
27+
28+
!llvm.module.flags = !{!0}
29+
!llvm.ident = !{!1}
30+
31+
!0 = !{i32 1, !"wchar_size", i32 4}
32+
!1 = !{!"clang version 8.0.1"}

0 commit comments

Comments
 (0)