Skip to content

Commit

Permalink
Merge pull request #188 from lkeegan/remove_reset_cuda_device_calls
Browse files Browse the repository at this point in the history
Disable `cudaDeviceReset()` calls in pmcx
  • Loading branch information
fangq authored Sep 28, 2023
2 parents ef5c4fc + 81d99a9 commit b6e84b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions pmcx/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def build_extension(self, ext):
f"-DPYTHON_EXECUTABLE={sys.executable}",
f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm
"-DBUILD_PYTHON=true",
"-DCUDA_NVCC_FLAGS=-DMCX_DISABLE_CUDA_DEVICE_RESET",
]
build_args = []
# Adding CMake arguments set as environment variable
Expand Down
7 changes: 7 additions & 0 deletions src/mcx_core.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2275,7 +2275,9 @@ __global__ void mcx_main_loop(uint media[], OutputType field[], float genergy[],
*/
void mcx_cu_assess(cudaError_t cuerr, const char* file, const int linenum) {
if (cuerr != cudaSuccess) {
#ifndef MCX_DISABLE_CUDA_DEVICE_RESET
cudaDeviceReset();
#endif
mcx_error(-(int)cuerr, (char*)cudaGetErrorString(cuerr), file, linenum);
}
}
Expand Down Expand Up @@ -2816,7 +2818,10 @@ void mcx_run_simulation(Config* cfg, GPUInfo* gpu) {
free(field);
free(Pseed);

#ifndef MCX_DISABLE_CUDA_DEVICE_RESET
CUDA_ASSERT(cudaDeviceReset());
#endif

}
#pragma omp barrier

Expand Down Expand Up @@ -3765,7 +3770,9 @@ is more than what your have specified (%d), please use the -H option to specify
/**
* The below call in theory is not needed, but it ensures the device is freed for other programs, especially on Windows
*/
#ifndef MCX_DISABLE_CUDA_DEVICE_RESET
CUDA_ASSERT(cudaDeviceReset());
#endif

/**
* Lastly, free all host buffers, the simulation is complete.
Expand Down

0 comments on commit b6e84b6

Please sign in to comment.