Skip to content

Commit f259510

Browse files
committed
GPU OpenCL: Make SPIR-V version settable in CMake
1 parent 58dfa1e commit f259510

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

GPU/GPUTracking/Base/opencl/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ set(OCL_DEFINECL "-D$<JOIN:$<TARGET_PROPERTY:O2::GPUTracking,COMPILE_DEFINITIONS
3939
set(SRCS GPUReconstructionOCL.cxx)
4040
set(HDRS GPUReconstructionOCL.h GPUReconstructionOCLInternals.h)
4141

42+
if (NOT DEFINED GPUCA_OCL_SPIRV_VERSION)
43+
set(GPUCA_OCL_SPIRV_VERSION 1.2)
44+
endif()
45+
4246
if(OPENCL_ENABLED_SPIRV) # BUILD OpenCL intermediate code for SPIR-V target
4347
# executes clang to create llvm IL code
4448
# Add -fintegrated-objemitter once we switch to clang >= 17
@@ -47,7 +51,7 @@ if(OPENCL_ENABLED_SPIRV) # BUILD OpenCL intermediate code for SPIR-V target
4751
OUTPUT ${CL_BIN}.spirv
4852
COMMAND ${CMAKE_COMMAND} -E env "PATH=${TMP_LLVM_SPIRV_PATH}:\$$PATH" ${LLVM_CLANG}
4953
-O0
50-
--target=spirv64
54+
--target=spirv64v${GPUCA_OCL_SPIRV_VERSION}
5155
-fno-integrated-objemitter
5256
-ferror-limit=1000 -Wno-invalid-constexpr -Wno-unused-command-line-argument
5357
${OCL_FLAGS}
@@ -106,4 +110,4 @@ endif()
106110
if(OPENCL_ENABLED_SPIRV)
107111
target_compile_definitions(${targetName} PRIVATE OPENCL_ENABLED_SPIRV)
108112
endif()
109-
target_compile_definitions(${targetName} PRIVATE GPUCA_OCL_BUILD_FLAGS=$<JOIN:${OCL_FLAGS},\ >)
113+
target_compile_definitions(${targetName} PRIVATE GPUCA_OCL_BUILD_FLAGS=$<JOIN:${OCL_FLAGS},\ > GPUCA_OCL_SPIRV_VERSION=${GPUCA_OCL_SPIRV_VERSION})

GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,14 @@ int32_t GPUReconstructionOCLBackend::InitDevice_Runtime()
209209
while ((pos = device_il_version.find("SPIR-V", pos)) != std::string::npos) {
210210
float spirvVersion;
211211
sscanf(device_il_version.c_str() + pos, "SPIR-V_%f", &spirvVersion);
212-
if (spirvVersion >= 1.2) {
212+
if (spirvVersion >= GPUCA_OCL_SPIRV_VERSION) {
213213
break;
214214
}
215215
pos += strlen("SPIR-V_0.0");
216216
}
217217
if (pos == std::string::npos) {
218218
deviceOK = false;
219-
deviceFailure += " - No SPIR-V 1.6 (" + device_il_version + ")";
219+
deviceFailure += " - No SPIR-V " + std::to_string(GPUCA_OCL_SPIRV_VERSION) + " (" + device_il_version + ")";
220220
}
221221
}
222222

0 commit comments

Comments
 (0)