Gromacs
2024.4
|
#include "gmxpre.h"
#include <algorithm>
#include "gromacs/hardware/device_management.h"
#include "gromacs/utility/arrayref.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/fatalerror.h"
#include "device_information.h"
Defines the implementations of device management functions that are common for CPU, CUDA and OpenCL.
Functions | |
bool | canPerformDeviceDetection (std::string *errorMessage) |
Return whether GPUs can be detected. More... | |
bool | isDeviceDetectionEnabled () |
Return whether GPU detection is enabled. More... | |
DeviceVendor | getDeviceVendor (const char *vendorName) |
Returns an DeviceVendor value corresponding to the input OpenCL vendor name. More... | |
int | getDeviceComputeUnitFactor (const DeviceInformation &deviceInfo) |
Get the factor to divide the number of compute units by. More... | |
std::vector < std::reference_wrapper < DeviceInformation > > | getCompatibleDevices (const std::vector< std::unique_ptr< DeviceInformation >> &deviceInfoList) |
Return a container of device-information handles that are compatible. More... | |
std::vector< int > | getCompatibleDeviceIds (gmx::ArrayRef< const std::unique_ptr< DeviceInformation >> deviceInfoList) |
Return a container of the IDs of the compatible GPU ids. More... | |
bool | deviceIdIsCompatible (gmx::ArrayRef< const std::unique_ptr< DeviceInformation >> deviceInfoList, const int deviceId) |
Return whether deviceId is found in deviceInfoList and is compatible. More... | |
gmx::GpuAwareMpiStatus | getMinimalSupportedGpuAwareMpiStatus (gmx::ArrayRef< const std::unique_ptr< DeviceInformation >> deviceInfoList) |
Return whether all compatible devices in deviceInfoList support GPU-aware MPI. More... | |
std::string | getDeviceCompatibilityDescription (const gmx::ArrayRef< const std::unique_ptr< DeviceInformation >> deviceInfoList, int deviceId) |
Return a string describing how compatible the GPU with given deviceId is. More... | |
void | serializeDeviceInformations (const std::vector< std::unique_ptr< DeviceInformation >> &deviceInfoList, gmx::ISerializer *serializer) |
Serialization of information on devices for MPI broadcasting. More... | |
std::vector< std::unique_ptr < DeviceInformation > > | deserializeDeviceInformations (gmx::ISerializer *serializer) |
Deserialization of information on devices after MPI broadcasting. More... | |
bool canPerformDeviceDetection | ( | std::string * | errorMessage | ) |
Return whether GPUs can be detected.
Returns true when this is a build of GROMACS configured to support GPU usage, GPU detection is not disabled by GMX_DISABLE_GPU_DETECTION
environment variable and a valid device driver, ICD, and/or runtime was detected. Does not throw.
[out] | errorMessage | When returning false on a build configured with GPU support and non-nullptr was passed, the string contains a descriptive message about why GPUs cannot be detected. |
std::vector<std::unique_ptr<DeviceInformation> > deserializeDeviceInformations | ( | gmx::ISerializer * | serializer | ) |
Deserialization of information on devices after MPI broadcasting.
[in] | serializer | Serializing object. |
bool deviceIdIsCompatible | ( | gmx::ArrayRef< const std::unique_ptr< DeviceInformation >> | deviceInfoList, |
int | deviceId | ||
) |
Return whether deviceId
is found in deviceInfoList
and is compatible.
This function filters the result of the detection for compatible GPUs, based on the previously run compatibility tests.
[in] | deviceInfoList | An information on available devices. |
[in] | deviceId | The device ID to find in the list. |
RangeError | If deviceId does not match the id of any device in deviceInfoList |
deviceId
is compatible. std::vector<int> getCompatibleDeviceIds | ( | gmx::ArrayRef< const std::unique_ptr< DeviceInformation >> | deviceInfoList | ) |
Return a container of the IDs of the compatible GPU ids.
This function filters the result of the detection for compatible GPUs, based on the previously run compatibility tests.
[in] | deviceInfoList | An information on available devices. |
std::vector<std::reference_wrapper<DeviceInformation> > getCompatibleDevices | ( | const std::vector< std::unique_ptr< DeviceInformation >> & | deviceInfoList | ) |
Return a container of device-information handles that are compatible.
This function filters the result of the detection for compatible GPUs, based on the previously run compatibility tests.
[in] | deviceInfoList | An information on available devices. |
std::string getDeviceCompatibilityDescription | ( | gmx::ArrayRef< const std::unique_ptr< DeviceInformation >> | deviceInfoList, |
int | deviceId | ||
) |
Return a string describing how compatible the GPU with given deviceId
is.
[in] | deviceInfoList | An information on available devices. |
[in] | deviceId | An index of the device to check |
int getDeviceComputeUnitFactor | ( | const DeviceInformation & | deviceInfo | ) |
Get the factor to divide the number of compute units by.
OpenCL and SYCL can report the number of Compute Units (CUs) a device has, see CL_DEVICE_MAX_COMPUTE_UNITS
and info::device::max_compute_units
. But "CU" is only vaguely defined by the standard, and on different vendors the same API call returns different things.
On NVIDIA, that is the number of SMs.
On AMD, that is the number of Compute Units, which are similar to CUDA's SM. Except on RDNA, where the number of Dual Compute Units is returned (https://stackoverflow.com/a/63976796/929437).
On Intel, that is the number of EUs (XVEs), which are similar to CUDA core. The concept similar to CUDA SM is called sub-slice (Xe Core, XC), and it contains 16 EUs (Gen9-Gen11, Xe).
This function uses CUDA SM as a reference. To get the number of SM-like units on a device, divide the result of CL_DEVICE_MAX_COMPUTE_UNITS
/ info::device::max_compute_units
API call by the value returned by this function.
[in] | deviceInfo | Device information. |
DeviceVendor getDeviceVendor | ( | const char * | vendorName | ) |
Returns an DeviceVendor value corresponding to the input OpenCL vendor name.
gmx::GpuAwareMpiStatus getMinimalSupportedGpuAwareMpiStatus | ( | gmx::ArrayRef< const std::unique_ptr< DeviceInformation >> | deviceInfoList | ) |
Return whether all compatible devices in deviceInfoList
support GPU-aware MPI.
bool isDeviceDetectionEnabled | ( | ) |
Return whether GPU detection is enabled.
Returns true when this is a build of GROMACS configured to support GPU usage and GPU detection is not disabled by GMX_DISABLE_GPU_DETECTION
environment variable.
Does not throw.
void serializeDeviceInformations | ( | const std::vector< std::unique_ptr< DeviceInformation >> & | deviceInfoList, |
gmx::ISerializer * | serializer | ||
) |
Serialization of information on devices for MPI broadcasting.
[in] | deviceInfoList | The vector with device informations to serialize. |
[in] | serializer | Serializing object. |