Skip to content

Commit 121ec68

Browse files
committed
GPU ONNX: Fix compiler warning and simplify code
1 parent 33f9308 commit 121ec68

File tree

1 file changed

+24
-29
lines changed

1 file changed

+24
-29
lines changed

GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -621,21 +621,10 @@ void GPUReconstructionCUDA::loadKernelModules(bool perKernel)
621621
}
622622
}
623623

624-
#ifndef __HIPCC__ // CUDA
625-
void GPUReconstructionCUDA::startGPUProfiling()
626-
{
627-
GPUChkErr(cudaProfilerStart());
628-
}
629-
630-
void GPUReconstructionCUDA::endGPUProfiling()
631-
{
632-
GPUChkErr(cudaProfilerStop());
633-
}
634-
635624
void GPUReconstructionCUDA::SetONNXGPUStream(Ort::SessionOptions& session_options, int32_t stream, int32_t* deviceId)
636625
{
637-
#ifdef ORT_CUDA_BUILD
638-
cudaGetDevice(deviceId);
626+
GPUChkErr(cudaGetDevice(deviceId));
627+
#if !defined(__HIPCC__) && defined(ORT_CUDA_BUILD)
639628
OrtCUDAProviderOptionsV2* cuda_options = nullptr;
640629
CreateCUDAProviderOptions(&cuda_options);
641630

@@ -650,22 +639,7 @@ void GPUReconstructionCUDA::SetONNXGPUStream(Ort::SessionOptions& session_option
650639

651640
// Finally, don't forget to release the provider options
652641
ReleaseCUDAProviderOptions(cuda_options);
653-
#endif // ORT_CUDA_BUILD
654-
}
655-
656-
#else // HIP
657-
void* GPUReconstructionHIP::getGPUPointer(void* ptr)
658-
{
659-
void* retVal = nullptr;
660-
GPUChkErr(hipHostGetDevicePointer(&retVal, ptr, 0));
661-
return retVal;
662-
}
663-
664-
void GPUReconstructionHIP::SetONNXGPUStream(Ort::SessionOptions& session_options, int32_t stream, int32_t* deviceId)
665-
{
666-
#ifdef ORT_ROCM_BUILD
667-
// Create ROCm provider options
668-
cudaGetDevice(deviceId);
642+
#elif defined(ORT_ROCM_BUILD)
669643
// const auto& api = Ort::GetApi();
670644
// api.GetCurrentGpuDeviceId(deviceId);
671645
OrtROCMProviderOptions rocm_options;
@@ -676,4 +650,25 @@ void GPUReconstructionHIP::SetONNXGPUStream(Ort::SessionOptions& session_options
676650
session_options.AppendExecutionProvider_ROCM(rocm_options);
677651
#endif // ORT_ROCM_BUILD
678652
}
653+
654+
#ifndef __HIPCC__ // CUDA
655+
656+
void GPUReconstructionCUDA::startGPUProfiling()
657+
{
658+
GPUChkErr(cudaProfilerStart());
659+
}
660+
661+
void GPUReconstructionCUDA::endGPUProfiling()
662+
{
663+
GPUChkErr(cudaProfilerStop());
664+
}
665+
666+
#else // HIP
667+
void* GPUReconstructionHIP::getGPUPointer(void* ptr)
668+
{
669+
void* retVal = nullptr;
670+
GPUChkErr(hipHostGetDevicePointer(&retVal, ptr, 0));
671+
return retVal;
672+
}
673+
679674
#endif // __HIPCC__

0 commit comments

Comments
 (0)