+ else
+ {
+ // TODO:
+ // - we inspect the CUDA API state to retrieve and record any
+ // errors that occurred during is_gmx_supported_gpu_id() here,
+ // but this would be more elegant done within is_gmx_supported_gpu_id()
+ // and only return a string with the error if one was encountered.
+ // - we'll be reporting without rank information which is not ideal.
+ // - we'll end up warning also in cases where users would already
+ // get an error before mdrun aborts.
+ //
+ // Here we also clear the CUDA API error state so potential
+ // errors during sanity checks don't propagate.
+ if ((stat = cudaGetLastError()) != cudaSuccess)
+ {
+ gmx_warning(gmx::formatString("An error occurred while sanity checking device #%d; %s: %s",
+ devs[i].id, cudaGetErrorName(stat), cudaGetErrorString(stat)).c_str());
+ }
+ }