Gromacs
2024.4
|
#include "gmxpre.h"
#include "device_management.h"
#include "gromacs/utility/fatalerror.h"
#include "device_information.h"
Defines the CPU stubs for the device management.
Functions | |
std::vector< std::unique_ptr < DeviceInformation > > | findDevices () |
Find all GPUs in the system. More... | |
void | setActiveDevice (const DeviceInformation &) |
Set the active GPU. More... | |
void | releaseDevice (DeviceInformation *) |
Releases the GPU device used by the active context at the time of calling (CUDA only). More... | |
std::string | getDeviceInformationString (const DeviceInformation &) |
Formats and returns a device information string for a given GPU. More... | |
bool | isDeviceDetectionFunctional (std::string *) |
Return whether GPU detection is functioning correctly. More... | |
std::vector<std::unique_ptr<DeviceInformation> > findDevices | ( | ) |
Find all GPUs in the system.
Will detect every GPU supported by the device driver in use. Must only be called if canPerformDeviceDetection()
has returned true. This routine also checks for the compatibility of each device and fill the deviceInfo array with the required information on each device: ID, device properties, status.
Note that this function leaves the GPU runtime API error state clean; this is implemented ATM in the CUDA flavor. This invalidates any existing CUDA streams, allocated memory on GPU, etc.
InternalError | if a GPU API returns an unexpected failure (because the call to canDetectGpus() should always prevent this occuring) |
std::string getDeviceInformationString | ( | const DeviceInformation & | deviceInfo | ) |
Formats and returns a device information string for a given GPU.
Given an index directly into the array of available GPUs, returns a formatted info string for the respective GPU which includes ID, name, compute capability, and detection status.
[in] | deviceInfo | An information on device that is to be set. |
bool isDeviceDetectionFunctional | ( | std::string * | errorMessage | ) |
Return whether GPU detection is functioning correctly.
Returns true when this is a build of GROMACS configured to support GPU usage, and a valid device driver, ICD, and/or runtime was detected.
This function is not intended to be called from build configurations that do not support GPUs, and there will be no descriptive message in that case.
[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. |
Does not throw.
void releaseDevice | ( | DeviceInformation * | deviceInfo | ) |
Releases the GPU device used by the active context at the time of calling (CUDA only).
If deviceInfo
is nullptr, then it is understood that no device was selected so no context is active to be freed. Otherwise, the context is explicitly destroyed and therefore all data uploaded to the GPU is lost. This must only be called when none of this data is required anymore, because subsequent attempts to free memory associated with the context will otherwise fail.
Calls gmx_warning
upon errors.
[in] | deviceInfo | Information on the device to be released. |
void setActiveDevice | ( | const DeviceInformation & | deviceInfo | ) |
Set the active GPU.
This sets the device for which the device information is passed active. Essential in CUDA, where the device buffers and kernel launches are not connected to the device context. In OpenCL, checks the device vendor and makes vendor-specific performance adjustments.
[in] | deviceInfo | Information on the device to be set. |
Issues a fatal error for any critical errors that occur during initialization.