Skip to content

Commit f554c4f

Browse files
SPIR-V is an official target, no need to edit scripts/compile-triton.sh and CMakeLists.txt
1 parent b411a51 commit f554c4f

File tree

3 files changed

+14
-41
lines changed

3 files changed

+14
-41
lines changed

scripts/compile-triton.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ build_llvm() {
132132
-DCMAKE_BUILD_TYPE=Release \
133133
-DLLVM_ENABLE_ASSERTIONS=true \
134134
-DLLVM_ENABLE_PROJECTS="mlir" \
135-
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=SPIRV \
136-
-DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" \
135+
-DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU;SPIRV" \
137136
-DLLVM_INSTALL_UTILS=true \
138137
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
139138
-DCMAKE_INSTALL_PREFIX=$PACKAGES_DIR/llvm \

third_party/intel/lib/Target/SPIRV/CMakeLists.txt

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,19 @@
11
# SPIRV-LLVM-Translator is required.
22
find_package(SPIRVToLLVMTranslator)
33

4-
# Check if there is the LLVM SPIR-V backend.
5-
is_llvm_target_library("SPIRV" spirv_present_result INCLUDED_TARGETS)
6-
7-
if(spirv_present_result)
8-
message(STATUS "Found SPIR-V Backend")
9-
add_compile_definitions(LLVM_SPIRV_BACKEND_TARGET_PRESENT)
10-
add_mlir_translation_library(TritonSPIRV
11-
SPIRVTranslation.cpp
12-
13-
LINK_COMPONENTS
14-
Core
15-
# spirv backend
16-
SPIRVCodeGen
17-
18-
LINK_LIBS PUBLIC
19-
TritonLLVMIR
20-
# spirv tools
21-
LLVMSPIRVLib
22-
)
23-
else()
24-
add_mlir_translation_library(TritonSPIRV
25-
SPIRVTranslation.cpp
26-
27-
LINK_COMPONENTS
28-
Core
29-
30-
LINK_LIBS PUBLIC
31-
TritonLLVMIR
32-
# spirv tools
33-
LLVMSPIRVLib
34-
)
35-
endif()
4+
add_mlir_translation_library(TritonSPIRV
5+
SPIRVTranslation.cpp
6+
7+
LINK_COMPONENTS
8+
Core
9+
# spirv backend
10+
SPIRVCodeGen
11+
12+
LINK_LIBS PUBLIC
13+
TritonLLVMIR
14+
# spirv tools
15+
LLVMSPIRVLib
16+
)
3617

3718
# Add SPIRV-LLVM-Translator include directory.
3819
target_include_directories(TritonSPIRV PRIVATE ${SPIRVToLLVMTranslator_INCLUDE_DIR})

third_party/intel/lib/Target/SPIRV/SPIRVTranslation.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "llvm/Target/TargetMachine.h"
1414
#include "llvm/TargetParser/Triple.h"
1515

16-
#if defined(LLVM_SPIRV_BACKEND_TARGET_PRESENT)
1716
namespace llvm {
1817

1918
using namespace llvm;
@@ -102,8 +101,6 @@ bool runSpirvBackend(Module *M, std::ostream &OS, std::string &ErrMsg,
102101

103102
} // namespace llvm
104103

105-
#endif // LLVM_SPIRV_BACKEND_TARGET_PRESENT
106-
107104
namespace triton {
108105

109106
class SmallVectorBuffer : public std::streambuf {
@@ -156,16 +153,12 @@ std::string translateLLVMIRToSPIRV(llvm::Module &module) {
156153
SPIRVOpts.setPreserveAuxData(false);
157154
SPIRVOpts.setSPIRVAllowUnknownIntrinsics({"llvm.genx.GenISA."});
158155

159-
#if defined(LLVM_SPIRV_BACKEND_TARGET_PRESENT)
160156
int SpvTranslateMode = 0;
161157
if (const char *EnvIsBackend = std::getenv("TRITON_USE_SPIRV_BACKEND"))
162158
llvm::StringRef(EnvIsBackend).getAsInteger(10, SpvTranslateMode);
163159
auto success = SpvTranslateMode
164160
? llvm::runSpirvBackend(&module, OS, Err, SPIRVOpts)
165161
: llvm::writeSpirv(&module, SPIRVOpts, OS, Err);
166-
#else
167-
auto success = llvm::writeSpirv(&module, SPIRVOpts, OS, Err);
168-
#endif // LLVM_SPIRV_BACKEND_TARGET_PRESENT
169162

170163
if (!success) {
171164
llvm::errs() << "SPIRVTranslation: SPIRV translation failed with"

0 commit comments

Comments
 (0)