From d13c619c6bb8c2d53f6977d7872296f6c0326b31 Mon Sep 17 00:00:00 2001 From: David Rohr Date: Tue, 22 Apr 2025 10:22:49 +0200 Subject: [PATCH 1/2] GPU ONNX: Fix compiler warning and simplify code --- .../Base/cuda/GPUReconstructionCUDA.cu | 55 +++++++++---------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu index c40c607396f3f..2cd705ba078b9 100644 --- a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu +++ b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu @@ -621,21 +621,10 @@ void GPUReconstructionCUDA::loadKernelModules(bool perKernel) } } -#ifndef __HIPCC__ // CUDA -void GPUReconstructionCUDA::startGPUProfiling() -{ - GPUChkErr(cudaProfilerStart()); -} - -void GPUReconstructionCUDA::endGPUProfiling() -{ - GPUChkErr(cudaProfilerStop()); -} - void GPUReconstructionCUDA::SetONNXGPUStream(Ort::SessionOptions& session_options, int32_t stream, int32_t* deviceId) { -#ifdef ORT_CUDA_BUILD - cudaGetDevice(deviceId); + GPUChkErr(cudaGetDevice(deviceId)); +#if !defined(__HIPCC__) && defined(ORT_CUDA_BUILD) OrtCUDAProviderOptionsV2* cuda_options = nullptr; CreateCUDAProviderOptions(&cuda_options); @@ -649,23 +638,8 @@ void GPUReconstructionCUDA::SetONNXGPUStream(Ort::SessionOptions& session_option session_options.AppendExecutionProvider_CUDA_V2(cuda_options); // Finally, don't forget to release the provider options - ReleaseCUDAProviderOptions(cuda_options); -#endif // ORT_CUDA_BUILD -} - -#else // HIP -void* GPUReconstructionHIP::getGPUPointer(void* ptr) -{ - void* retVal = nullptr; - GPUChkErr(hipHostGetDevicePointer(&retVal, ptr, 0)); - return retVal; -} - -void GPUReconstructionHIP::SetONNXGPUStream(Ort::SessionOptions& session_options, int32_t stream, int32_t* deviceId) -{ -#ifdef ORT_ROCM_BUILD - // Create ROCm provider options - cudaGetDevice(deviceId); +ReleaseCUDAProviderOptions(cuda_options); +#elif defined(ORT_ROCM_BUILD) // const auto& api = Ort::GetApi(); // api.GetCurrentGpuDeviceId(deviceId); OrtROCMProviderOptions rocm_options; @@ -676,4 +650,25 @@ void GPUReconstructionHIP::SetONNXGPUStream(Ort::SessionOptions& session_options session_options.AppendExecutionProvider_ROCM(rocm_options); #endif // ORT_ROCM_BUILD } + +#ifndef __HIPCC__ // CUDA + +void GPUReconstructionCUDA::startGPUProfiling() +{ + GPUChkErr(cudaProfilerStart()); +} + +void GPUReconstructionCUDA::endGPUProfiling() +{ + GPUChkErr(cudaProfilerStop()); +} + +#else // HIP +void* GPUReconstructionHIP::getGPUPointer(void* ptr) +{ + void* retVal = nullptr; + GPUChkErr(hipHostGetDevicePointer(&retVal, ptr, 0)); + return retVal; +} + #endif // __HIPCC__ From 8dd5b3321c1c60f9117af44e0344e8e6a5b954c6 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Tue, 22 Apr 2025 08:24:40 +0000 Subject: [PATCH 2/2] Please consider the following formatting changes --- GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu index 2cd705ba078b9..d5b01bfa34833 100644 --- a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu +++ b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu @@ -638,7 +638,7 @@ void GPUReconstructionCUDA::SetONNXGPUStream(Ort::SessionOptions& session_option session_options.AppendExecutionProvider_CUDA_V2(cuda_options); // Finally, don't forget to release the provider options -ReleaseCUDAProviderOptions(cuda_options); + ReleaseCUDAProviderOptions(cuda_options); #elif defined(ORT_ROCM_BUILD) // const auto& api = Ort::GetApi(); // api.GetCurrentGpuDeviceId(deviceId); @@ -663,7 +663,7 @@ void GPUReconstructionCUDA::endGPUProfiling() GPUChkErr(cudaProfilerStop()); } -#else // HIP +#else // HIP void* GPUReconstructionHIP::getGPUPointer(void* ptr) { void* retVal = nullptr;