![]() |
MFEM v4.9.0
Finite element discretization library
|
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as CUDA, OCCA, RAJA and OpenMP. More...
#include <device.hpp>
Public Member Functions | |
| Device () | |
| Default constructor. Unless Configure() is called later, the default Backend::CPU will be used. | |
| Device (const std::string &device, const int device_id=0) | |
| Construct a Device and configure it based on the device string. See Configure() for more details. | |
| ~Device () | |
| Destructor. | |
| void | Configure (const std::string &device, const int device_id=0) |
| Configure the Device backends. | |
| void | Print (std::ostream &os=mfem::out) |
| Print the configuration of the MFEM virtual device object. | |
Static Public Member Functions | |
| static void | SetMemoryTypes (MemoryType h_mt, MemoryType d_mt) |
| Set the default host and device MemoryTypes, h_mt and d_mt. | |
| static bool | IsConfigured () |
| Return true if Configure() has been called previously. | |
| static bool | IsAvailable () |
| Return true if an actual device (e.g. GPU) has been configured. | |
| static bool | IsEnabled () |
| Return true if any backend other than Backend::CPU is enabled. | |
| static bool | IsDisabled () |
| The opposite of IsEnabled(). | |
| static int | GetId () |
| Get the device ID of the configured device. | |
| static int | GetDeviceCount () |
| Get the number of available devices (may be called before configuration). | |
| static bool | Allows (unsigned long b_mask) |
| Return true if any of the backends in the backend mask, b_mask, are allowed. | |
| static MemoryType | GetHostMemoryType () |
| Get the current Host MemoryType. This is the MemoryType used by most MFEM classes when allocating memory used on the host. | |
| static MemoryClass | GetHostMemoryClass () |
| Get the current Host MemoryClass. This is the MemoryClass used by most MFEM host Memory objects. | |
| static MemoryType | GetDeviceMemoryType () |
| Get the current Device MemoryType. This is the MemoryType used by most MFEM classes when allocating memory to be used with device kernels. | |
| static MemoryType | GetMemoryType () |
| (DEPRECATED) Equivalent to GetDeviceMemoryType(). | |
| static MemoryClass | GetDeviceMemoryClass () |
| Get the current Device MemoryClass. This is the MemoryClass used by most MFEM device kernels to access Memory objects. | |
| static MemoryClass | GetMemoryClass () |
| (DEPRECATED) Equivalent to GetDeviceMemoryClass(). | |
| static void | SetGPUAwareMPI (const bool force=true) |
| Manually set the status of GPU-aware MPI flag for use in MPI communication routines which have optimized implementations for device buffers. | |
| static bool | GetGPUAwareMPI () |
| Get the status of GPU-aware MPI flag. | |
| static MemoryType | QueryMemoryType (const void *ptr) |
| static int | NumMultiprocessors (int device_id) |
| The number of hardware compute units/streaming multiprocessors available on a given compute device device_id. | |
| static int | NumMultiprocessors () |
| Same as NumMultiprocessors(int), for the currently active device. | |
| static int | WarpSize (int device_id) |
| The number of threads in a warp on a given compute device device_id. | |
| static int | WarpSize () |
| Same as WarpSize(int), for the currently active device. | |
| static void | DeviceMem (size_t *free, size_t *total) |
| Gets the free and total memory on the device. | |
Friends | |
| class | MemoryManager |
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as CUDA, OCCA, RAJA and OpenMP.
This class represents a "virtual device" with the following properties:
Definition at line 123 of file device.hpp.
| mfem::Device::Device | ( | ) |
Default constructor. Unless Configure() is called later, the default Backend::CPU will be used.
Definition at line 74 of file device.cpp.
|
inline |
Construct a Device and configure it based on the device string. See Configure() for more details.
Definition at line 180 of file device.hpp.
| mfem::Device::~Device | ( | ) |
Destructor.
Definition at line 156 of file device.cpp.
|
inlinestatic |
Return true if any of the backends in the backend mask, b_mask, are allowed.
This method can be used with any of the Backend::Id constants, the Backend::*_MASK, or combinations of those.
Definition at line 262 of file device.hpp.
| void mfem::Device::Configure | ( | const std::string & | device, |
| const int | device_id = 0 ) |
Configure the Device backends.
The string parameter device must be a comma-separated list of backend string names (see below). The device_id argument specifies the ID of the actual devices (e.g. GPU) to use.
Definition at line 189 of file device.cpp.
|
static |
Gets the free and total memory on the device.
Definition at line 700 of file device.cpp.