Skip to content

Commit 768854e

Browse files
Update spirv-llvm-translator.conf (#5312)
Signed-off-by: Whitney Tsang <[email protected]>
1 parent 68a43d8 commit 768854e

File tree

3 files changed

+84
-1
lines changed

3 files changed

+84
-1
lines changed

third_party/intel/cmake/3388.patch

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
diff --git a/lib/SPIRV/SPIRVWriter.cpp b/lib/SPIRV/SPIRVWriter.cpp
2+
index d363f060a..28f83d661 100644
3+
--- a/lib/SPIRV/SPIRVWriter.cpp
4+
+++ b/lib/SPIRV/SPIRVWriter.cpp
5+
@@ -4211,20 +4211,6 @@ SPIRVValue *LLVMToSPIRVBase::transIntrinsicInst(IntrinsicInst *II,
6+
// -spirv-allow-unknown-intrinsics work correctly.
7+
auto IID = II->getIntrinsicID();
8+
switch (IID) {
9+
- case Intrinsic::fabs:
10+
- case Intrinsic::fma:
11+
- case Intrinsic::maxnum:
12+
- case Intrinsic::minnum:
13+
- case Intrinsic::fmuladd: {
14+
- Type *Ty = II->getType();
15+
- if (Ty->isBFloatTy())
16+
- BM->addCapability(internal::CapabilityBFloat16ArithmeticINTEL);
17+
- break;
18+
- }
19+
- default:
20+
- break;
21+
- }
22+
- switch (IID) {
23+
case Intrinsic::assume: {
24+
// llvm.assume translation is currently supported only within
25+
// SPV_KHR_expect_assume extension, ignore it otherwise, since it's
26+
@@ -5508,11 +5494,6 @@ SPIRVValue *LLVMToSPIRVBase::transDirectCallInst(CallInst *CI,
27+
SmallVector<std::string, 2> Dec;
28+
if (isBuiltinTransToExtInst(CI->getCalledFunction(), &ExtSetKind, &ExtOp,
29+
&Dec)) {
30+
- if (const auto *FirstArg = F->getArg(0)) {
31+
- const auto *Type = FirstArg->getType();
32+
- if (Type->isBFloatTy())
33+
- BM->addCapability(internal::CapabilityBFloat16ArithmeticINTEL);
34+
- }
35+
if (DemangledName.find("__spirv_ocl_printf") != StringRef::npos) {
36+
auto *FormatStrPtr = cast<PointerType>(CI->getArgOperand(0)->getType());
37+
if (FormatStrPtr->getAddressSpace() !=
38+
diff --git a/lib/SPIRV/libSPIRV/SPIRVModule.cpp b/lib/SPIRV/libSPIRV/SPIRVModule.cpp
39+
index a680574ec..2ff1df097 100644
40+
--- a/lib/SPIRV/libSPIRV/SPIRVModule.cpp
41+
+++ b/lib/SPIRV/libSPIRV/SPIRVModule.cpp
42+
@@ -1732,8 +1732,6 @@ SPIRVInstruction *SPIRVModuleImpl::addBinaryInst(Op TheOpCode, SPIRVType *Type,
43+
SPIRVValue *Op1,
44+
SPIRVValue *Op2,
45+
SPIRVBasicBlock *BB) {
46+
- if (Type->isTypeFloat(16, FPEncodingBFloat16KHR) && TheOpCode != OpDot)
47+
- addCapability(internal::CapabilityBFloat16ArithmeticINTEL);
48+
return addInstruction(SPIRVInstTemplateBase::create(
49+
TheOpCode, Type, getId(),
50+
getVec(Op1->getId(), Op2->getId()), BB, this),
51+
@@ -1757,8 +1755,6 @@ SPIRVInstruction *SPIRVModuleImpl::addUnaryInst(Op TheOpCode,
52+
SPIRVType *TheType,
53+
SPIRVValue *Op,
54+
SPIRVBasicBlock *BB) {
55+
- if (TheType->isTypeFloat(16, FPEncodingBFloat16KHR) && TheOpCode != OpDot)
56+
- addCapability(internal::CapabilityBFloat16ArithmeticINTEL);
57+
return addInstruction(
58+
SPIRVInstTemplateBase::create(TheOpCode, TheType, getId(),
59+
getVec(Op->getId()), BB, this),

third_party/intel/cmake/FindSPIRVToLLVMTranslator.cmake

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,30 @@ if (NOT SPIRVToLLVMTranslator_FOUND)
4949
if(NOT PATCH_RESULT EQUAL 0)
5050
message(FATAL_ERROR "Failed to apply 3122.patch to SPIRV-LLVM-Translator")
5151
endif()
52+
53+
# FIXME: Don't apply patch when Agama driver is updated to incorporate with the SPV_INTEL_bfloat16_arithmetic extension.
54+
execute_process(
55+
COMMAND git apply --check ${CMAKE_CURRENT_LIST_DIR}/3388.patch
56+
WORKING_DIRECTORY ${spirv-llvm-translator_SOURCE_DIR}
57+
ERROR_QUIET
58+
RESULT_VARIABLE PATCH_RESULT
59+
)
60+
if(PATCH_RESULT EQUAL 0)
61+
execute_process(
62+
COMMAND git apply ${CMAKE_CURRENT_LIST_DIR}/3388.patch
63+
WORKING_DIRECTORY ${spirv-llvm-translator_SOURCE_DIR}
64+
RESULT_VARIABLE PATCH_RESULT
65+
)
66+
else()
67+
execute_process( # Check if the patch is already applied
68+
COMMAND git apply --reverse --check ${CMAKE_CURRENT_LIST_DIR}/3388.patch
69+
WORKING_DIRECTORY ${spirv-llvm-translator_SOURCE_DIR}
70+
RESULT_VARIABLE PATCH_RESULT
71+
)
72+
endif()
73+
if(NOT PATCH_RESULT EQUAL 0)
74+
message(FATAL_ERROR "Failed to apply 3388.patch to SPIRV-LLVM-Translator")
75+
endif()
5276
endif()
5377

5478
set(SPIRVToLLVMTranslator_INCLUDE_DIR "${SPIRVToLLVMTranslator_SOURCE_DIR}/include"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8e8c02c4b803062501a6bd36aecdbb041fa1daef
1+
b12cb1c7371fc53cd0a6880795caec4f81a8eed0

0 commit comments

Comments
 (0)