This repository was archived by the owner on Mar 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 2828#include < pat_api.h>
2929#endif
3030
31+ #if defined(CORENEURON_ENABLE_GPU) && defined(CORENEURON_PREFER_OPENMP_OFFLOAD) && defined(_OPENMP)
32+ #include < cuda_runtime_api.h>
33+ #endif
34+
3135namespace coreneuron {
3236extern InterleaveInfo* interleave_info;
3337void copy_ivoc_vect_to_device (const IvocVect& iv, IvocVect& div);
@@ -60,6 +64,12 @@ void cnrn_target_set_default_device(int device_num) {
6064#elif defined(CORENEURON_ENABLE_GPU) && defined(CORENEURON_PREFER_OPENMP_OFFLOAD) && \
6165 defined (_OPENMP)
6266 omp_set_default_device (device_num);
67+ // It seems that with NVHPC 21.9 then only setting the default OpenMP device
68+ // is not enough: there were errors on some nodes when not-the-0th GPU was
69+ // used. These seemed to be related to the NMODL instance structs, which are
70+ // allocated using cudaMallocManaged.
71+ auto const cuda_code = cudaSetDevice (device_num);
72+ assert (cuda_code == cudaSuccess);
6373#else
6474 throw std::runtime_error (
6575 " cnrn_target_set_default_device() not implemented without OpenACC/OpenMP and gpu build" );
You can’t perform that action at this time.
0 commit comments