Skip to content

Commit a7534db

Browse files
committed
GPU RTC: Check that current compiler versions are the same as those used to create RTC code in cache
1 parent 359e28b commit a7534db

File tree

6 files changed

+21
-6
lines changed

6 files changed

+21
-6
lines changed

GPU/GPUTracking/Base/GPUReconstruction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ class GPUReconstruction
275275

276276
// Private helpers for library loading
277277
static std::shared_ptr<LibraryLoader>* GetLibraryInstance(DeviceType type, bool verbose);
278+
static std::string getBackendVersions();
278279

279280
// Private helper functions for memory management
280281
size_t AllocateRegisteredMemoryHelper(GPUMemoryResource* res, void*& ptr, void*& memorypool, void* memorybase, size_t memorysize, void* (GPUMemoryResource::*SetPointers)(void*), void*& memorypoolend, const char* device);

GPU/GPUTracking/Base/GPUReconstructionAvailableBackends.template.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
/// \file GPUReconstructionAvailableBackends.h
1313
/// \author David Rohr
1414

15+
// clang-format off
1516
#cmakedefine CUDA_ENABLED
1617
#cmakedefine HIP_ENABLED
1718
#cmakedefine OPENCL_ENABLED
19+
#cmakedefine GPUCA_COMPILER_VERSIONS @GPUCA_COMPILER_VERSIONS@
20+
// clang-format on

GPU/GPUTracking/Base/GPUReconstructionLibrary.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,8 @@ int32_t GPUReconstruction::LibraryLoader::CloseLibrary()
184184
mGPUEntry = nullptr;
185185
return 0;
186186
}
187+
188+
std::string GPUReconstruction::getBackendVersions()
189+
{
190+
return GPUCA_M_STR(GPUCA_COMPILER_VERSIONS);
191+
}

GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAGenRTC.cxx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,16 @@ int32_t GPUReconstructionCUDA::genRTC(std::string& filename, uint32_t& nCompile)
8080
GPUInfo("RTC Launch Bounds:\n%s", launchBounds.c_str());
8181
}
8282

83-
char shasource[21], shaparam[21], shacmd[21], shakernels[21], shabounds[21];
83+
const std::string compilerVersions = getBackendVersions();
84+
85+
char shasource[21], shaparam[21], shacmd[21], shakernels[21], shabounds[21], shaversion[21];
8486
if (GetProcessingSettings().rtc.cacheOutput) {
8587
o2::framework::internal::SHA1(shasource, _binary_GPUReconstructionCUDArtc_src_start, _binary_GPUReconstructionCUDArtc_src_len);
8688
o2::framework::internal::SHA1(shaparam, rtcparam.c_str(), rtcparam.size());
8789
o2::framework::internal::SHA1(shacmd, baseCommand.c_str(), baseCommand.size());
8890
o2::framework::internal::SHA1(shakernels, kernelsall.c_str(), kernelsall.size());
8991
o2::framework::internal::SHA1(shabounds, launchBounds.c_str(), launchBounds.size());
92+
o2::framework::internal::SHA1(shaversion, compilerVersions.c_str(), compilerVersions.size());
9093
}
9194

9295
nCompile = GetProcessingSettings().rtc.compilePerKernel ? kernels.size() : 1;
@@ -131,11 +134,12 @@ int32_t GPUReconstructionCUDA::genRTC(std::string& filename, uint32_t& nCompile)
131134
}
132135
return 0;
133136
};
134-
if (checkSHA(shasource, "source") || // TODO: CHECK VERSION!
137+
if (checkSHA(shasource, "source") ||
135138
checkSHA(shaparam, "param") ||
136139
checkSHA(shacmd, "command line") ||
137140
checkSHA(shakernels, "kernel definitions") ||
138-
checkSHA(shabounds, "launch bounds")) {
141+
checkSHA(shabounds, "launch bounds") ||
142+
checkSHA(shaversion, "compiler versions")) {
139143
break;
140144
}
141145
GPUSettingsProcessingRTC cachedSettings;
@@ -237,6 +241,7 @@ int32_t GPUReconstructionCUDA::genRTC(std::string& filename, uint32_t& nCompile)
237241
fwrite(shacmd, 1, 20, fp) != 20 ||
238242
fwrite(shakernels, 1, 20, fp) != 20 ||
239243
fwrite(shabounds, 1, 20, fp) != 20 ||
244+
fwrite(shaversion, 1, 20, fp) != 20 ||
240245
fwrite(&GetProcessingSettings().rtc, sizeof(GetProcessingSettings().rtc), 1, fp) != 1) {
241246
throw std::runtime_error("Error writing cache file");
242247
}

GPU/GPUTracking/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ install(DIRECTORY utils
396396
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/GPU
397397
FILES_MATCHING PATTERN *.h)
398398

399+
set(GPUCA_COMPILER_VERSIONS "CUDA ${CMAKE_CUDA_COMPILER_VERSION} HIP ${hip_VERSION} ${CMAKE_HIP_COMPILER_VERSION} ROCM ${CMAKE_HIP_COMPILER_ROCM_ROOT} LLVM ${LLVM_PACKAGE_VERSION}")
399400

400401
# GPUReconstructionLibrary needs to know which GPU backends are enabled for proper error messages
401402
configure_file(Base/GPUReconstructionAvailableBackends.template.h ${CMAKE_CURRENT_BINARY_DIR}/GPUReconstructionAvailableBackends.h)

dependencies/FindO2GPU.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ if(ENABLE_CUDA)
139139
message(${FAILURE_SEVERITY} "CUDA found but thrust not available")
140140
set(CMAKE_CUDA_COMPILER OFF)
141141
endif()
142-
if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "12.6")
143-
message(${FAILURE_SEVERITY} "CUDA Version too old: ${CMAKE_CUDA_COMPILER_VERSION}, 12.6 required")
142+
if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "12.8")
143+
message(${FAILURE_SEVERITY} "CUDA Version too old: ${CMAKE_CUDA_COMPILER_VERSION}, 12.8 required")
144144
set(CMAKE_CUDA_COMPILER OFF)
145145
endif()
146146
endif()
@@ -279,7 +279,7 @@ if(ENABLE_HIP)
279279
elseif(NOT ENABLE_HIP STREQUAL "AUTO")
280280
message(FATAL_ERROR "HIP requested, but CMAKE_PREFIX_PATH env variable does not contain rocm folder!")
281281
endif()
282-
if(hip_FOUND AND NOT hip_VERSION VERSION_GREATER_EQUAL "5.5")
282+
if(hip_FOUND AND NOT hip_VERSION VERSION_GREATER_EQUAL "6.3")
283283
set(hip_FOUND 0)
284284
endif()
285285
if(hip_FOUND AND hipcub_FOUND AND rocthrust_FOUND AND rocprim_FOUND AND hip_HIPCC_EXECUTABLE AND hip_HIPIFY_PERL_EXECUTABLE)

0 commit comments

Comments
 (0)