![]() |
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.
|
static |
Get the number of available devices (may be called before configuration).
Definition at line 425 of file device.cpp.
|
inlinestatic |
Get the current Device MemoryClass. This is the MemoryClass used by most MFEM device kernels to access Memory objects.
Definition at line 285 of file device.hpp.
|
inlinestatic |
Get the current Device MemoryType. This is the MemoryType used by most MFEM classes when allocating memory to be used with device kernels.
Definition at line 277 of file device.hpp.
|
inlinestatic |
Get the status of GPU-aware MPI flag.
Definition at line 298 of file device.hpp.
|
inlinestatic |
Get the current Host MemoryClass. This is the MemoryClass used by most MFEM host Memory objects.
Definition at line 272 of file device.hpp.
|
inlinestatic |
Get the current Host MemoryType. This is the MemoryType used by most MFEM classes when allocating memory used on the host.
Definition at line 268 of file device.hpp.
|
inlinestatic |
Get the device ID of the configured device.
Definition at line 253 of file device.hpp.
|
inlinestatic |
(DEPRECATED) Equivalent to GetDeviceMemoryClass().
Definition at line 289 of file device.hpp.
|
inlinestatic |
(DEPRECATED) Equivalent to GetDeviceMemoryType().
Definition at line 281 of file device.hpp.
|
inlinestatic |
Return true if an actual device (e.g. GPU) has been configured.
Definition at line 244 of file device.hpp.
|
inlinestatic |
Return true if Configure() has been called previously.
Definition at line 241 of file device.hpp.
|
inlinestatic |
The opposite of IsEnabled().
Definition at line 250 of file device.hpp.
|
inlinestatic |
Return true if any backend other than Backend::CPU is enabled.
Definition at line 247 of file device.hpp.
|
static |
Same as NumMultiprocessors(int), for the currently active device.
Definition at line 736 of file device.cpp.
|
static |
The number of hardware compute units/streaming multiprocessors available on a given compute device device_id.
Definition at line 719 of file device.cpp.
| void mfem::Device::Print | ( | std::ostream & | os = mfem::out | ) |
Print the configuration of the MFEM virtual device object.
Definition at line 317 of file device.cpp.
|
static |
Query the device driver for what memory type a given ptr is allocated with.
Definition at line 618 of file device.cpp.
|
inlinestatic |
Manually set the status of GPU-aware MPI flag for use in MPI communication routines which have optimized implementations for device buffers.
Definition at line 294 of file device.hpp.
|
static |
Set the default host and device MemoryTypes, h_mt and d_mt.
The host and device MemoryTypes are also set to be dual to each other.
These two MemoryTypes are used by most MFEM classes when allocating memory used on host and device, respectively.
This method can only be called before Device construction and configuration, and the specified memory types must be compatible with the subsequent Device configuration.
Definition at line 294 of file device.cpp.
|
static |
Same as WarpSize(int), for the currently active device.
Definition at line 764 of file device.cpp.
|
static |
The number of threads in a warp on a given compute device device_id.
Definition at line 747 of file device.cpp.
|
friend |
Definition at line 126 of file device.hpp.