Skip to content

Commit 5369a73

Browse files
vmustyadbudanov-cmplr
authored andcommitted
Update SPV_INTEL_vector_compute to rev 15
This adds NamedBarrierCountINTEL Execution Mode, see more in #1612 Co-authored-by: nrudenko <[email protected]> Original commit: KhronosGroup/SPIRV-LLVM-Translator@21c7a30
1 parent 4447e58 commit 5369a73

File tree

8 files changed

+71
-1
lines changed

8 files changed

+71
-1
lines changed

llvm-spirv/lib/SPIRV/PreprocessMetadata.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,18 @@ void PreprocessMetadataBase::preprocessVectorComputeMetadata(Module *M,
349349
.add(spv::internal::ExecutionModeFastCompositeKernelINTEL)
350350
.done();
351351
}
352+
353+
if (Attrs.hasFnAttr(kVCMetadata::VCNamedBarrierCount)) {
354+
SPIRVWord NBarrierCnt = 0;
355+
Attrs.getFnAttr(kVCMetadata::VCNamedBarrierCount)
356+
.getValueAsString()
357+
.getAsInteger(0, NBarrierCnt);
358+
EM.addOp()
359+
.add(&F)
360+
.add(spv::internal::ExecutionModeNamedBarrierCountINTEL)
361+
.add(NBarrierCnt)
362+
.done();
363+
}
352364
}
353365
}
354366

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4206,6 +4206,14 @@ bool SPIRVToLLVM::transVectorComputeMetadata(SPIRVFunction *BF) {
42064206
F->addFnAttr(Attr);
42074207
}
42084208

4209+
if (auto *EM =
4210+
BF->getExecutionMode(internal::ExecutionModeNamedBarrierCountINTEL)) {
4211+
unsigned int NBarrierCnt = EM->getLiterals()[0];
4212+
Attribute Attr = Attribute::get(*Context, kVCMetadata::VCNamedBarrierCount,
4213+
std::to_string(NBarrierCnt));
4214+
F->addFnAttr(Attr);
4215+
}
4216+
42094217
return true;
42104218
}
42114219

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4572,6 +4572,16 @@ bool LLVMToSPIRVBase::transExecutionMode() {
45724572
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
45734573
BF, static_cast<ExecutionMode>(EMode), SLMSize)));
45744574
} break;
4575+
case spv::internal::ExecutionModeNamedBarrierCountINTEL: {
4576+
if (!BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute))
4577+
break;
4578+
unsigned NBarrierCnt = 0;
4579+
N.get(NBarrierCnt);
4580+
BF->addExecutionMode(new SPIRVExecutionMode(
4581+
BF, static_cast<ExecutionMode>(EMode), NBarrierCnt));
4582+
BM->addExtension(ExtensionID::SPV_INTEL_vector_compute);
4583+
BM->addCapability(CapabilityVectorComputeINTEL);
4584+
} break;
45754585

45764586
case spv::ExecutionModeDenormPreserve:
45774587
case spv::ExecutionModeDenormFlushToZero:

llvm-spirv/lib/SPIRV/VectorComputeUtil.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ const static char VCCallable[] = "VCCallable";
114114
const static char VCSingleElementVector[] = "VCSingleElementVector";
115115
const static char VCFCEntry[] = "VCFCEntry";
116116
const static char VCMediaBlockIO[] = "VCMediaBlockIO";
117+
const static char VCNamedBarrierCount[] = "VCNamedBarrierCount";
117118
} // namespace kVCMetadata
118119

119120
namespace kVCType {

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVEntry.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ void SPIRVExecutionMode::decode(std::istream &I) {
580580
case ExecutionModeFloatingPointModeALTINTEL:
581581
case ExecutionModeFloatingPointModeIEEEINTEL:
582582
case ExecutionModeSharedLocalMemorySizeINTEL:
583+
case internal::ExecutionModeNamedBarrierCountINTEL:
583584
case ExecutionModeSubgroupSize:
584585
case ExecutionModeMaxWorkDimINTEL:
585586
case ExecutionModeNumSIMDWorkitemsINTEL:

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVEnum.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ template <> inline void SPIRVMap<SPIRVExecutionModeKind, SPIRVCapVec>::init() {
263263
{internal::CapabilityFastCompositeINTEL});
264264
ADD_VEC_INIT(internal::ExecutionModeStreamingInterfaceINTEL,
265265
{CapabilityFPGAKernelAttributesINTEL});
266+
ADD_VEC_INIT(internal::ExecutionModeNamedBarrierCountINTEL,
267+
{CapabilityVectorComputeINTEL});
266268
}
267269

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

llvm-spirv/lib/SPIRV/libSPIRV/spirv_internal.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ enum InternalFunctionControlMask { IFunctionControlOptNoneINTELMask = 0x10000 };
8585

8686
enum InternalExecutionMode {
8787
IExecModeFastCompositeKernelINTEL = 6088,
88-
IExecModeStreamingInterfaceINTEL = 6154
88+
IExecModeStreamingInterfaceINTEL = 6154,
89+
IExecModeNamedBarrierCountINTEL = 6417
8990
};
9091

9192
enum InternalLoopControlMask { ILoopControlLoopCountINTELMask = 0x1000000 };
@@ -184,6 +185,9 @@ constexpr ExecutionMode ExecutionModeFastCompositeKernelINTEL =
184185
constexpr ExecutionMode ExecutionModeStreamingInterfaceINTEL =
185186
static_cast<ExecutionMode>(IExecModeStreamingInterfaceINTEL);
186187

188+
constexpr ExecutionMode ExecutionModeNamedBarrierCountINTEL =
189+
static_cast<ExecutionMode>(IExecModeNamedBarrierCountINTEL);
190+
187191
static const LoopControlMask LoopControlLoopCountINTELMask =
188192
static_cast<LoopControlMask>(ILoopControlLoopCountINTELMask);
189193

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 -emit-opaque-pointers %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)