Skip to content

Commit

Permalink
Merge pull request glotzerlab#1271 from glotzerlab/check-managed-memory
Browse files Browse the repository at this point in the history
Make device unavailable if it doesn't support managed memory.
  • Loading branch information
joaander authored Mar 18, 2022
2 parents 6b5b3b0 + fc8ef4c commit 8345749
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
20 changes: 20 additions & 0 deletions hoomd/ExecutionConfiguration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,26 @@ void ExecutionConfiguration::scanGPUs()
continue;
}

// exclude a GPU when it doesn't support mapped memory
#ifdef __HIP_PLATFORM_NVCC__
int supports_managed_memory = 0;
cudaError_t cuda_error
= cudaDeviceGetAttribute(&supports_managed_memory, cudaDevAttrManagedMemory, dev);
if (cuda_error != cudaSuccess)
{
s_gpu_scan_messages.push_back("Failed to get device attribute: "
+ string(cudaGetErrorString(cuda_error)));
continue;
}
if (!supports_managed_memory)
{
ostringstream s;
s << "The device " << prop.name << " does not support managed memory.";
s_gpu_scan_messages.push_back(s.str());
continue;
}
#endif

s_capable_gpu_descriptions.push_back(describeGPU((int)s_capable_gpu_ids.size(), prop));
s_capable_gpu_ids.push_back(dev);
}
Expand Down
5 changes: 3 additions & 2 deletions hoomd/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
pytest_plugins = ("hoomd.pytest_plugin_validate",)

devices = [hoomd.device.CPU]
if (hoomd.device.GPU.is_available()
and len(hoomd.device.GPU.get_available_devices()) > 0):
_n_available_gpu = len(hoomd.device.GPU.get_available_devices())
_github_actions = os.environ.get('GITHUB_ACTIONS') is not None
if hoomd.version.gpu_enabled and (_n_available_gpu > 0 or _github_actions):

if os.environ.get('_HOOMD_SKIP_CPU_TESTS_WHEN_GPUS_PRESENT_') is not None:
devices.pop(0)
Expand Down

0 comments on commit 8345749

Please sign in to comment.