15#define GPUCA_GPUCODE_HOSTONLY
18#include "GPUReconstructionRTCHelpers.inc"
19#include "GPUKernelsWith1Warp.inc"
23namespace rtc = o2::gpu::internal::rtc;
31int32_t GPUReconstructionCUDA::genRTC(std::string&
filename, uint32_t& nCompile)
34 const std::string_view rtcSource(_binary_GPUReconstructionCUDArtc_src_start, _binary_GPUReconstructionCUDArtc_src_len);
35 const std::string rtcparam = rtc::paramCode(proc,
param());
36 rtc::tmpFilename(
filename,
"/tmp/o2cagpu_rtc_");
38 std::vector<std::string> kernels;
39 getRTCKernelCalls(kernels);
40 const std::string kernelsall = rtc::joinKernels(kernels);
42 const std::string baseCommand = rtc::baseCommand(proc, std::string_view(_binary_GPUReconstructionCUDArtc_command_start, _binary_GPUReconstructionCUDArtc_command_len)) +
" " +
43 (proc.rtctech.overrideArchitecture !=
"" ? proc.rtctech.overrideArchitecture : std::string(_binary_GPUReconstructionCUDArtc_command_arch_start, _binary_GPUReconstructionCUDArtc_command_arch_len));
44 const std::string noFastMath(_binary_GPUReconstructionCUDArtc_command_no_fast_math_start, _binary_GPUReconstructionCUDArtc_command_no_fast_math_len);
47 if constexpr (std::string_view(
"CUDA") ==
"HIP") {
48 if (proc.hipOverrideAMDEUSperCU > 0) {
49 mParDevice->par_AMD_EUS_PER_CU = proc.hipOverrideAMDEUSperCU;
50 }
else if (
mParDevice->par_AMD_EUS_PER_CU <= 0) {
51 GPUFatal(
"AMD_EUS_PER_CU not set in the parameters provided for the AMD GPU, you can override this via --PROChipOverrideAMDEUSperCU [n]");
55 if (std::find(gpuKernelsWith1Warp.begin(), gpuKernelsWith1Warp.end(),
GetKernelName(
i)) != gpuKernelsWith1Warp.end()) {
60 if (proc.rtctech.printLaunchBounds >= 2) {
64 nCompile = proc.rtc.compilePerKernel ? kernels.size() : 1;
66 rtc::Cache cache(proc,
"cuda", {rtcSource, rtcparam, baseCommand, kernelsall, launchBounds, compilerVersions});
67 if (!cache.load(
filename, mRtcBinExtension, nCompile)) {
68 rtc::compile(proc, nCompile,
"CUDA", [&](uint32_t
i) {
70 if (proc.debugLevel >= 3) {
71 printf(
"Compiling %s\n", (fileBase + mRtcSrcExtension).c_str());
73 const bool deterministic = rtc::deterministic(proc,
GetKernelName(
i));
74 const std::string kernel = std::string(
"extern \"C\" {") + (proc.rtc.compilePerKernel ? kernels[
i] : kernelsall) +
"}";
75 rtc::writeSource(fileBase + mRtcSrcExtension, deterministic, rtcparam, launchBounds, rtcSource, kernel);
76 const std::string command = baseCommand + (deterministic ?
" " + noFastMath :
"") +
" -c " + fileBase + mRtcSrcExtension +
" -o " + fileBase + mRtcBinExtension;
77 rtc::runCommand(proc, command, fileBase + mRtcSrcExtension,
"Error during CUDA compilation");
79 cache.store(
filename, mRtcBinExtension, nCompile);
static const char * GetKernelName()
static uint32_t GetNKernels()
GPUDefParameters * mParDevice
static std::string getBackendVersions()
const GPUSettingsProcessing & GetProcessingSettings() const
std::string to_string(gsl::span< T, Size > span)
#define QGET_LD_BINARY_SYMBOLS(filename)
int32_t par_LB_maxThreads[$< LIST:LENGTH, $< TARGET_PROPERTY:O2_GPU_KERNELS, O2_GPU_KERNEL_NAMES > >]