Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/SPIRV/PreprocessMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,18 @@ void PreprocessMetadataBase::preprocessVectorComputeMetadata(Module *M,
.add(spv::internal::ExecutionModeFastCompositeKernelINTEL)
.done();
}

if (Attrs.hasFnAttr(kVCMetadata::VCNamedBarrierCount)) {
SPIRVWord NBarrierCnt = 0;
Attrs.getFnAttr(kVCMetadata::VCNamedBarrierCount)
.getValueAsString()
.getAsInteger(0, NBarrierCnt);
EM.addOp()
.add(&F)
.add(spv::internal::ExecutionModeNamedBarrierCountINTEL)
.add(NBarrierCnt)
.done();
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions lib/SPIRV/SPIRVReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4215,6 +4215,14 @@ bool SPIRVToLLVM::transVectorComputeMetadata(SPIRVFunction *BF) {
F->addFnAttr(Attr);
}

if (auto *EM =
BF->getExecutionMode(internal::ExecutionModeNamedBarrierCountINTEL)) {
unsigned int NBarrierCnt = EM->getLiterals()[0];
Attribute Attr = Attribute::get(*Context, kVCMetadata::VCNamedBarrierCount,
std::to_string(NBarrierCnt));
F->addFnAttr(Attr);
}

return true;
}

Expand Down
10 changes: 10 additions & 0 deletions lib/SPIRV/SPIRVWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4560,6 +4560,16 @@ bool LLVMToSPIRVBase::transExecutionMode() {
break;
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
} break;
case spv::internal::ExecutionModeNamedBarrierCountINTEL: {
if (!BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute))
break;
unsigned NBarrierCnt = 0;
N.get(NBarrierCnt);
BF->addExecutionMode(new SPIRVExecutionMode(
BF, static_cast<ExecutionMode>(EMode), NBarrierCnt));
BM->addExtension(ExtensionID::SPV_INTEL_vector_compute);
BM->addCapability(CapabilityVectorComputeINTEL);
} break;

case spv::ExecutionModeDenormPreserve:
case spv::ExecutionModeDenormFlushToZero:
Expand Down
1 change: 1 addition & 0 deletions lib/SPIRV/VectorComputeUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const static char VCCallable[] = "VCCallable";
const static char VCSingleElementVector[] = "VCSingleElementVector";
const static char VCFCEntry[] = "VCFCEntry";
const static char VCMediaBlockIO[] = "VCMediaBlockIO";
const static char VCNamedBarrierCount[] = "VCNamedBarrierCount";
} // namespace kVCMetadata

namespace kVCType {
Expand Down
1 change: 1 addition & 0 deletions lib/SPIRV/libSPIRV/SPIRVEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ void SPIRVExecutionMode::decode(std::istream &I) {
case ExecutionModeFloatingPointModeALTINTEL:
case ExecutionModeFloatingPointModeIEEEINTEL:
case ExecutionModeSharedLocalMemorySizeINTEL:
case internal::ExecutionModeNamedBarrierCountINTEL:
case ExecutionModeSubgroupSize:
case ExecutionModeMaxWorkDimINTEL:
case ExecutionModeNumSIMDWorkitemsINTEL:
Expand Down
2 changes: 2 additions & 0 deletions lib/SPIRV/libSPIRV/SPIRVEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ template <> inline void SPIRVMap<SPIRVExecutionModeKind, SPIRVCapVec>::init() {
{internal::CapabilityFastCompositeINTEL});
ADD_VEC_INIT(internal::ExecutionModeStreamingInterfaceINTEL,
{CapabilityFPGAKernelAttributesINTEL});
ADD_VEC_INIT(internal::ExecutionModeNamedBarrierCountINTEL,
{CapabilityVectorComputeINTEL});
}

template <> inline void SPIRVMap<SPIRVMemoryModelKind, SPIRVCapVec>::init() {
Expand Down
6 changes: 5 additions & 1 deletion lib/SPIRV/libSPIRV/spirv_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ enum InternalFunctionControlMask { IFunctionControlOptNoneINTELMask = 0x10000 };

enum InternalExecutionMode {
IExecModeFastCompositeKernelINTEL = 6088,
IExecModeStreamingInterfaceINTEL = 6154
IExecModeStreamingInterfaceINTEL = 6154,
IExecModeNamedBarrierCountINTEL = 6417
};

enum InternalLoopControlMask { ILoopControlLoopCountINTELMask = 0x1000000 };
Expand Down Expand Up @@ -178,6 +179,9 @@ constexpr ExecutionMode ExecutionModeFastCompositeKernelINTEL =
constexpr ExecutionMode ExecutionModeStreamingInterfaceINTEL =
static_cast<ExecutionMode>(IExecModeStreamingInterfaceINTEL);

constexpr ExecutionMode ExecutionModeNamedBarrierCountINTEL =
static_cast<ExecutionMode>(IExecModeNamedBarrierCountINTEL);

static const LoopControlMask LoopControlLoopCountINTELMask =
static_cast<LoopControlMask>(ILoopControlLoopCountINTELMask);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
; RUN: llvm-as %s -o %t.bc
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_INTEL_vector_compute
; RUN: llvm-spirv %t.spv -o %t.spt --to-text
; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.bc
; RUN: llvm-dis %t.bc -o %t.ll
; RUN: FileCheck %s --input-file %t.spt -check-prefix=SPV
; RUN: FileCheck %s --input-file %t.ll -check-prefix=LLVM

; ModuleID = 'slm.bc'
source_filename = "slm.cpp"
target datalayout = "e-p:64:64-i64:64-n8:16:32"
target triple = "spir"

; LLVM-DAG: @k_rte{{[^a-zA-Z0-9_][^#]*}}#[[K_RTE:[0-9]+]]
; LLVM-DAG: attributes #[[K_RTE]]{{[^0-9].*"VCNamedBarrierCount"="8"}}
; SPV-DAG: Extension "SPV_INTEL_vector_compute"
; SPV-DAG: Capability VectorComputeINTEL
; SPV: EntryPoint {{[0-9]+}} [[S_RTE:[0-9]+]] "k_rte"
; SPV: ExecutionMode [[S_RTE]] 6417 8
; Function Attrs: noinline norecurse nounwind readnone
define dso_local dllexport spir_kernel void @k_rte(i32 %ibuf, i32 %obuf) local_unnamed_addr #1 {
entry:
ret void
}

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" }

!llvm.module.flags = !{!0}
!llvm.ident = !{!1}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 8.0.1"}