![]() |
MFEM v4.10.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 std::string | GetUUID (const int device_id=0) |
| static bool | Allows (unsigned long b_mask) |
| Return true if any of the backends in the backend mask, b_mask, are allowed. | |
| static auto | GetRajaResource () |
| 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 128 of file device.hpp.
| mfem::Device::Device | ( | ) |
Default constructor. Unless Configure() is called later, the default Backend::CPU will be used.
Definition at line 76 of file device.cpp.
|
inline |
Construct a Device and configure it based on the device string. See Configure() for more details.
Definition at line 185 of file device.hpp.
| mfem::Device::~Device | ( | ) |
Destructor.
Definition at line 158 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 271 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 191 of file device.cpp.
|
static |
Gets the free and total memory on the device.
Definition at line 704 of file device.cpp.
|
static |
Get the number of available devices (may be called before configuration).
Definition at line 427 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 306 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 298 of file device.hpp.
|
inlinestatic |
Get the status of GPU-aware MPI flag.
Definition at line 319 of file device.hpp.
|
inlinestatic |
Get the current Host MemoryClass. This is the MemoryClass used by most MFEM host Memory objects.
Definition at line 293 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 289 of file device.hpp.
|
inlinestatic |
Get the device ID of the configured device.
Definition at line 258 of file device.hpp.
|
inlinestatic |
(DEPRECATED) Equivalent to GetDeviceMemoryClass().
Definition at line 310 of file device.hpp.
|
inlinestatic |
(DEPRECATED) Equivalent to GetDeviceMemoryType().
Definition at line 302 of file device.hpp.
|
inlinestatic |
Definition at line 276 of file device.hpp.
|
static |
Gets a string representation of the GPU UUID. 0 <= device_id < GetDeviceCount()
Definition at line 723 of file device.cpp.
|
inlinestatic |
Return true if an actual device (e.g. GPU) has been configured.
Definition at line 249 of file device.hpp.
|
inlinestatic |
Return true if Configure() has been called previously.
Definition at line 246 of file device.hpp.
|
inlinestatic |
The opposite of IsEnabled().
Definition at line 255 of file device.hpp.
|
inlinestatic |
Return true if any backend other than Backend::CPU is enabled.
Definition at line 252 of file device.hpp.
|
static |
Same as NumMultiprocessors(int), for the currently active device.
Definition at line 764 of file device.cpp.
|
static |
The number of hardware compute units/streaming multiprocessors available on a given compute device device_id.
Definition at line 746 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 319 of file device.cpp.
|
static |
Query the device driver for what memory type a given ptr is allocated with.
Definition at line 622 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 315 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 296 of file device.cpp.
|
static |
Same as WarpSize(int), for the currently active device.
Definition at line 792 of file device.cpp.
|
static |
The number of threads in a warp on a given compute device device_id.
Definition at line 775 of file device.cpp.
|
friend |
Definition at line 131 of file device.hpp.