Skip to content

Commit bcf59e8

Browse files
committed
GPU RTC: Add option to load runtime launch bounds parameters from file
1 parent 13b9e9c commit bcf59e8

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAGenRTC.cxx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,23 @@ int32_t GPUReconstructionCUDA::genRTC(std::string& filename, uint32_t& nCompile)
5959
std::string baseCommand = (mProcessingSettings.rtctech.prependCommand != "" ? (mProcessingSettings.rtctech.prependCommand + " ") : "");
6060
baseCommand += (getenv("O2_GPU_RTC_OVERRIDE_CMD") ? std::string(getenv("O2_GPU_RTC_OVERRIDE_CMD")) : std::string(_binary_GPUReconstructionCUDArtc_command_start, _binary_GPUReconstructionCUDArtc_command_len));
6161
baseCommand += std::string(" ") + (mProcessingSettings.rtctech.overrideArchitecture != "" ? mProcessingSettings.rtctech.overrideArchitecture : std::string(_binary_GPUReconstructionCUDArtc_command_arch_start, _binary_GPUReconstructionCUDArtc_command_arch_len));
62+
63+
if (mProcessingSettings.rtctech.loadLaunchBoundsFromFile.size()) {
64+
FILE* fp = fopen(mProcessingSettings.rtctech.loadLaunchBoundsFromFile.c_str(), "rb");
65+
if (fp == nullptr) {
66+
throw std::runtime_error("Cannot open launch bounds parameter module file");
67+
}
68+
fseek(fp, 0, SEEK_END);
69+
size_t size = ftell(fp);
70+
if (size != sizeof(*mParDevice)) {
71+
throw std::runtime_error("launch bounds parameter file has incorrect size");
72+
}
73+
fseek(fp, 0, SEEK_SET);
74+
if (fread(mParDevice, 1, size, fp) != size) {
75+
throw std::runtime_error("Error reading launch bounds parameter file");
76+
}
77+
fclose(fp);
78+
}
6279
const std::string launchBounds = o2::gpu::internal::GPUDefParametersExport(*mParDevice, true);
6380
if (mProcessingSettings.rtctech.printLaunchBounds || mProcessingSettings.debugLevel >= 3) {
6481
GPUInfo("RTC Launch Bounds:\n%s", launchBounds.c_str());

GPU/GPUTracking/Definitions/GPUSettingsList.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ AddOption(printLaunchBounds, bool, false, "", 0, "Print launch bounds used for R
228228
AddOption(cacheFolder, std::string, "./rtccache/", "", 0, "Folder in which the cache file is stored")
229229
AddOption(prependCommand, std::string, "", "", 0, "Prepend RTC compilation commands by this string")
230230
AddOption(overrideArchitecture, std::string, "", "", 0, "Override arhcitecture part of RTC compilation command line") // Part of cmdLine, so checked against the cache
231+
AddOption(loadLaunchBoundsFromFile, std::string, "", "", 0, "Load a parameter object containing the launch bounds from a file")
231232
AddHelp("help", 'h')
232233
EndConfig()
233234

0 commit comments

Comments
 (0)