Skip to content

Commit

Permalink
GPU: Fix deinitialization order
Browse files Browse the repository at this point in the history
Was wrong for a long time, but not spotted since return value was not checked before
  • Loading branch information
davidrohr committed Mar 14, 2024
1 parent f50987d commit b316ab5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ GPUReconstructionCUDABackend::GPUReconstructionCUDABackend(const GPUSettingsDevi
GPUReconstructionCUDABackend::~GPUReconstructionCUDABackend()
{
if (mMaster == nullptr) {
for (unsigned int i = 0; i < mInternals->kernelModules.size(); i++) {
GPUFailedMsg(cuModuleUnload(*mInternals->kernelModules[i]));
}
delete mInternals;
}
}
Expand Down Expand Up @@ -451,6 +448,10 @@ int GPUReconstructionCUDA::ExitDevice_Runtime()
}

GPUFailedMsgI(cudaFreeHost(mHostMemoryBase));
for (unsigned int i = 0; i < mInternals->kernelModules.size(); i++) {
GPUFailedMsg(cuModuleUnload(*mInternals->kernelModules[i]));
}

GPUFailedMsgI(cudaDeviceReset());
GPUInfo("CUDA Uninitialized");
}
Expand Down

0 comments on commit b316ab5

Please sign in to comment.