Skip to content

Commit 21c7a30

Browse files
Update SPV_INTEL_vector_compute to rev 15
This adds NamedBarrierCountINTEL Execution Mode, see more in intel/llvm#1612 Co-authored-by: nrudenko <[email protected]>
1 parent 40fd741 commit 21c7a30

File tree

8 files changed

+71
-1
lines changed

8 files changed

+71
-1
lines changed

lib/SPIRV/PreprocessMetadata.cpp

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

lib/SPIRV/SPIRVReader.cpp

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

4218+
if (auto *EM =
4219+
BF->getExecutionMode(internal::ExecutionModeNamedBarrierCountINTEL)) {
4220+
unsigned int NBarrierCnt = EM->getLiterals()[0];
4221+
Attribute Attr = Attribute::get(*Context, kVCMetadata::VCNamedBarrierCount,
4222+
std::to_string(NBarrierCnt));
4223+
F->addFnAttr(Attr);
4224+
}
4225+
42184226
return true;
42194227
}
42204228

lib/SPIRV/SPIRVWriter.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4560,6 +4560,16 @@ bool LLVMToSPIRVBase::transExecutionMode() {
45604560
break;
45614561
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
45624562
} break;
4563+
case spv::internal::ExecutionModeNamedBarrierCountINTEL: {
4564+
if (!BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute))
4565+
break;
4566+
unsigned NBarrierCnt = 0;
4567+
N.get(NBarrierCnt);
4568+
BF->addExecutionMode(new SPIRVExecutionMode(
4569+
BF, static_cast<ExecutionMode>(EMode), NBarrierCnt));
4570+
BM->addExtension(ExtensionID::SPV_INTEL_vector_compute);
4571+
BM->addCapability(CapabilityVectorComputeINTEL);
4572+
} break;
45634573

45644574
case spv::ExecutionModeDenormPreserve:
45654575
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
@@ -582,6 +582,7 @@ void SPIRVExecutionMode::decode(std::istream &I) {
582582
case ExecutionModeFloatingPointModeALTINTEL:
583583
case ExecutionModeFloatingPointModeIEEEINTEL:
584584
case ExecutionModeSharedLocalMemorySizeINTEL:
585+
case internal::ExecutionModeNamedBarrierCountINTEL:
585586
case ExecutionModeSubgroupSize:
586587
case ExecutionModeMaxWorkDimINTEL:
587588
case ExecutionModeNumSIMDWorkitemsINTEL:

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() {

lib/SPIRV/libSPIRV/spirv_internal.hpp

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

8484
enum InternalExecutionMode {
8585
IExecModeFastCompositeKernelINTEL = 6088,
86-
IExecModeStreamingInterfaceINTEL = 6154
86+
IExecModeStreamingInterfaceINTEL = 6154,
87+
IExecModeNamedBarrierCountINTEL = 6417
8788
};
8889

8990
enum InternalLoopControlMask { ILoopControlLoopCountINTELMask = 0x1000000 };
@@ -178,6 +179,9 @@ constexpr ExecutionMode ExecutionModeFastCompositeKernelINTEL =
178179
constexpr ExecutionMode ExecutionModeStreamingInterfaceINTEL =
179180
static_cast<ExecutionMode>(IExecModeStreamingInterfaceINTEL);
180181

182+
constexpr ExecutionMode ExecutionModeNamedBarrierCountINTEL =
183+
static_cast<ExecutionMode>(IExecModeNamedBarrierCountINTEL);
184+
181185
static const LoopControlMask LoopControlLoopCountINTELMask =
182186
static_cast<LoopControlMask>(ILoopControlLoopCountINTELMask);
183187

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)