![]() |
MFEM v4.10.0
Finite element discretization library
|
Communicator performing operations within groups defined by a GroupTopology with arbitrary-size data associated with each group. More...
#include <communication.hpp>
Classes | |
| struct | OpData |
| Data structure on which we define reduce operations. The data is associated with (and the operation is performed on) one group at a time. More... | |
Public Types | |
| enum | Mode { byGroup , byNeighbor } |
| Communication mode. More... | |
Public Member Functions | |
| GroupCommunicator (const GroupTopology >, Mode m=byNeighbor) | |
| Construct a GroupCommunicator object. | |
| void | Create (const Array< int > &ldof_group) |
| Initialize the communicator from a local-dof to group map. Finalize() is called internally. | |
| Table & | GroupLDofTable () |
| Fill-in the returned Table reference to initialize the GroupCommunicator then call Finalize(). | |
| const Table & | GroupLDofTable () const |
| Read-only access to group-ldof Table. | |
| void | Finalize () |
| Allocate internal buffers after the GroupLDofTable is defined. | |
| void | SetLTDofTable (const Array< int > &ldof_ltdof) |
| Initialize the internal group_ltdof Table. | |
| const GroupTopology & | GetGroupTopology () const |
| Get a const reference to the associated GroupTopology object. | |
| void | GetNeighborLTDofTable (Table &nbr_ltdof) const |
| Dofs to be sent (during Bcast) to communication neighbors. | |
| void | GetNeighborLDofTable (Table &nbr_ldof) const |
| Dofs to be received (during Bcast) from communication neighbors. | |
| const DeviceGroupCommunicator & | GetDeviceComm () const |
| Return the device communicator, 'device_gc', constructing it if it was not already constructed. | |
| template<class T > | |
| T * | CopyGroupToBuffer (const T *ldata, T *buf, int group, int layout) const |
| Copy the entries corresponding to the group group from the local array ldata to the buffer buf. | |
| template<class T > | |
| const T * | CopyGroupFromBuffer (const T *buf, T *ldata, int group, int layout) const |
| Copy the entries corresponding to the group group from the buffer buf to the local array ldata. | |
| template<class T > | |
| const T * | ReduceGroupFromBuffer (const T *buf, T *ldata, int group, int layout, void(*Op)(OpData< T >)) const |
| Perform the reduction operation Op to the entries of group group using the values from the buffer buf and the values from the local array ldata, saving the result in the latter. | |
| template<class T > | |
| void | BcastBegin (T *ldata, int layout) const |
| Begin a broadcast within each group where the master is the root, host version. | |
| template<class T > | |
| void | BcastBegin (Array< T > &ldata, int layout) const |
| Begin a broadcast within each group where the master is the root, device version. | |
| template<class T > | |
| void | BcastEnd (T *ldata, int layout) const |
| Finalize a broadcast started with the host version of BcastBegin(). | |
| template<class T > | |
| void | BcastEnd (Array< T > &ldata, int layout) const |
| Finalize a broadcast started with the device version of BcastBegin(). | |
| template<class T > | |
| void | Bcast (T *ldata, int layout) const |
| Broadcast within each group where the master is the root. | |
| template<class T > | |
| void | Bcast (T *ldata) const |
| Broadcast within each group where the master is the root, host version. | |
| template<class T > | |
| void | Bcast (Array< T > &ldata) const |
| Broadcast within each group where the master is the root, device version. | |
| template<class T > | |
| void | ReduceBegin (const T *ldata) const |
| Begin reduction operation within each group where the master is the root, host version. | |
| template<class T > | |
| void | ReduceBegin (const Array< T > &ldata, void(*Op)(OpData< T >)=nullptr) const |
| Begin reduction operation within each group where the master is the root, device version. | |
| template<class T > | |
| void | ReduceEnd (T *ldata, int layout, void(*Op)(OpData< T >)) const |
| Finalize reduction operation started with the host version of ReduceBegin(). | |
| template<class T > | |
| void | ReduceEnd (Array< T > &ldata, int layout, void(*Op)(OpData< T >)) const |
| Finalize reduction operation started with the device version of ReduceBegin(). | |
| template<class T > | |
| void | Reduce (T *ldata, void(*Op)(OpData< T >)) const |
| Reduce within each group where the master is the root, host version. | |
| template<class T > | |
| void | Reduce (Array< T > &ldata, void(*Op)(OpData< T >)) const |
| Reduce within each group where the master is the root, device version. | |
| template<class T > | |
| void | ReduceMarked (T *ldata, const Array< int > &marker, int layout, void(*Op)(OpData< T >)) const |
| Finalize reduction operation started with ReduceBegin(), but only apply the reduction to DOFs marked in the marker array. | |
| template<class T > | |
| void | Reduce (T *ldata, const Array< int > &marker, void(*Op)(OpData< T >)) const |
| Reduce within each group where the master is the root, but only for marked DOFs. | |
| void | PrintInfo (std::ostream &out=mfem::out) const |
| Print information about the GroupCommunicator from all MPI ranks. | |
| ~GroupCommunicator () | |
| Destroy a GroupCommunicator object, deallocating internal data structures and buffers. | |
Static Public Member Functions | |
| template<class T > | |
| static void | Sum (OpData< T >) |
| Reduce operation Sum, instantiated for int, double and float. | |
| template<class T > | |
| static void | Min (OpData< T >) |
| Reduce operation Min, instantiated for int, double and float. | |
| template<class T > | |
| static void | Max (OpData< T >) |
| Reduce operation Max, instantiated for int, double and float. | |
| template<class T > | |
| static void | BitOR (OpData< T >) |
| Reduce operation bitwise OR, instantiated for int only. | |
| template<class T > | |
| static void | MaxAbs (OpData< T >) |
Protected Attributes | |
| const GroupTopology & | gtopo |
| Mode | mode |
| Table | group_ldof |
| Table | group_ltdof |
| int | group_buf_size |
| Array< char > | group_buf |
| MPI_Request * | requests |
| int | comm_lock |
| int | num_requests |
| void(* | reduce_op )() |
| int * | request_marker |
| int * | buf_offsets |
| Table | nbr_send_groups |
| Table | nbr_recv_groups |
| bool | have_ltdof_ldof |
| Array< int > | ltdof_ldof |
| int | ldof_size |
| DeviceGroupCommunicator * | device_gc |
Friends | |
| class | DeviceGroupCommunicator |
Communicator performing operations within groups defined by a GroupTopology with arbitrary-size data associated with each group.
Definition at line 238 of file communication.hpp.
Communication mode.
| Enumerator | |
|---|---|
| byGroup | Communications are performed one group at a time. |
| byNeighbor | Communications are performed one neighbor at a time, aggregating over groups. |
Definition at line 244 of file communication.hpp.
| DO_NOT_DOCUMENT mfem::GroupCommunicator::GroupCommunicator | ( | const GroupTopology & | gt, |
| Mode | m = byNeighbor ) |
Construct a GroupCommunicator object.
The object must be initialized before it can be used to perform any operations. To initialize the object, either
Definition at line 371 of file communication.cpp.
| mfem::GroupCommunicator::~GroupCommunicator | ( | ) |
Destroy a GroupCommunicator object, deallocating internal data structures and buffers.
Definition at line 1746 of file communication.cpp.
|
inline |
Broadcast within each group where the master is the root, device version.
The implicit data layout is 0, i.e. the ldata array is an L-dof array.
This method performs the operation on device. However, not all communication modes are supported on device yet. In such cases, the operation is performed on host.
Definition at line 443 of file communication.hpp.
|
inline |
Broadcast within each group where the master is the root, host version.
The implicit data layout is 0, i.e. the ldata array is an L-dof array.
This method performs the operation on host and expects ldata to be a host pointer.
Definition at line 435 of file communication.hpp.
|
inline |
Broadcast within each group where the master is the root.
The data layout can be either 0 or 1.
For a description of layout, see CopyGroupToBuffer().
This method performs the operation on host and expects ldata to be a host pointer.
Definition at line 424 of file communication.hpp.
| void mfem::GroupCommunicator::BcastBegin | ( | Array< T > & | ldata, |
| int | layout ) const |
Begin a broadcast within each group where the master is the root, device version.
| [in,out] | ldata | Input L-vector data; in some cases it is used as a receive buffer, so its type is not const. |
| [in] | layout | For a description, see CopyGroupToBuffer(). |
This method performs the operation on device if the device flag of ldata is set. However, not all communication modes and layouts are supported on device yet. In such cases, the operation is performed on host.
Definition at line 889 of file communication.cpp.
| void mfem::GroupCommunicator::BcastBegin | ( | T * | ldata, |
| int | layout ) const |
Begin a broadcast within each group where the master is the root, host version.
| [in,out] | ldata | Input L-vector data; in some cases it is used as a receive buffer, so its type is not const. It must be a host pointer. |
| [in] | layout | For a description, see CopyGroupToBuffer(). |
This method performs the operation on host.
Definition at line 747 of file communication.cpp.
| void mfem::GroupCommunicator::BcastEnd | ( | Array< T > & | ldata, |
| int | layout ) const |
Finalize a broadcast started with the device version of BcastBegin().
| [out] | ldata | Output L-vector data. |
| [in] | layout | Output data layout; one of:
|
This method performs the operation on device if the device flag of ldata is set. However, not all communication modes and layouts are supported on device yet. In such cases, the operation is performed on host.
It is expected that the device flag of ldata is the same as the device flag of the data array provided to BcastBegin().
Definition at line 1013 of file communication.cpp.
| void mfem::GroupCommunicator::BcastEnd | ( | T * | ldata, |
| int | layout ) const |
Finalize a broadcast started with the host version of BcastBegin().
| [out] | ldata | Output L-vector data. It must be a host pointer. |
| [in] | layout | Output data layout; one of:
|
This method performs the operation on host.
Definition at line 942 of file communication.cpp.
|
static |
Reduce operation bitwise OR, instantiated for int only.
Definition at line 1584 of file communication.cpp.
| const T * mfem::GroupCommunicator::CopyGroupFromBuffer | ( | const T * | buf, |
| T * | ldata, | ||
| int | group, | ||
| int | layout ) const |
Copy the entries corresponding to the group group from the buffer buf to the local array ldata.
For a description of layout, see CopyGroupToBuffer().
Definition at line 674 of file communication.cpp.
| T * mfem::GroupCommunicator::CopyGroupToBuffer | ( | const T * | ldata, |
| T * | buf, | ||
| int | group, | ||
| int | layout ) const |
Copy the entries corresponding to the group group from the local array ldata to the buffer buf.
The layout of the local array can be:
{ J[j] : I[group] <= j < I[group+1] } where I,J=group_ldof.{I,J}{ j : I[group] <= j < I[group+1] } where I,J=group_ldof.{I,J}{ J[j] : I[group] <= j < I[group+1] } where I,J=group_ltdof.{I,J}. Definition at line 639 of file communication.cpp.
| void mfem::GroupCommunicator::Create | ( | const Array< int > & | ldof_group | ) |
Initialize the communicator from a local-dof to group map. Finalize() is called internally.
Definition at line 386 of file communication.cpp.
| void mfem::GroupCommunicator::Finalize | ( | ) |
Allocate internal buffers after the GroupLDofTable is defined.
Definition at line 415 of file communication.cpp.
| const DeviceGroupCommunicator & mfem::GroupCommunicator::GetDeviceComm | ( | ) | const |
Return the device communicator, 'device_gc', constructing it if it was not already constructed.
Definition at line 627 of file communication.cpp.
|
inline |
Get a const reference to the associated GroupTopology object.
Definition at line 302 of file communication.hpp.
| void mfem::GroupCommunicator::GetNeighborLDofTable | ( | Table & | nbr_ldof | ) | const |
Dofs to be received (during Bcast) from communication neighbors.
Definition at line 622 of file communication.cpp.
| void mfem::GroupCommunicator::GetNeighborLTDofTable | ( | Table & | nbr_ltdof | ) | const |
Dofs to be sent (during Bcast) to communication neighbors.
Definition at line 617 of file communication.cpp.
|
inline |
Fill-in the returned Table reference to initialize the GroupCommunicator then call Finalize().
Definition at line 288 of file communication.hpp.
|
inline |
Read-only access to group-ldof Table.
Definition at line 291 of file communication.hpp.
|
static |
Reduce operation Max, instantiated for int, double and float.
Definition at line 1566 of file communication.cpp.
|
static |
Reduce operation selecting the signed value with the largest absolute value, instantiated for int, double and float. The result keeps its sign; it is not the non-negative absolute value. Equal-magnitude ties are broken deterministically toward the more positive value, so opposite-sign ties resolve to the positive one regardless of accumulation order.
Definition at line 1600 of file communication.cpp.
|
static |
Reduce operation Min, instantiated for int, double and float.
Definition at line 1548 of file communication.cpp.
| void mfem::GroupCommunicator::PrintInfo | ( | std::ostream & | out = mfem::out | ) | const |
Print information about the GroupCommunicator from all MPI ranks.
Definition at line 1626 of file communication.cpp.
|
inline |
Reduce within each group where the master is the root, device version.
The implicit data layout is 0, i.e. the ldata array is an L-dof array.
The reduce operation is given by the second argument (see below for list of the supported operations.)
This method performs the operation on device. However, not all communication modes are supported on device yet. In such cases, the operation is performed on host.
Definition at line 551 of file communication.hpp.
|
inline |
Reduce within each group where the master is the root, but only for marked DOFs.
Definition at line 585 of file communication.hpp.
|
inline |
Reduce within each group where the master is the root, host version.
The implicit data layout is 0, i.e. the ldata array is an L-dof array.
The reduce operation is given by the second argument (see below for list of the supported operations.)
This method performs the operation on host and expects ldata to be a host pointer.
Definition at line 534 of file communication.hpp.
| void mfem::GroupCommunicator::ReduceBegin | ( | const Array< T > & | ldata, |
| void(* | Op )(OpData< T >) = nullptr ) const |
Begin reduction operation within each group where the master is the root, device version.
The input data layout is an array on all ldofs, i.e. layout 0, see CopyGroupToBuffer().
Generally, the reduce operation will be specified when calling ReduceEnd(), however, if the reduction operation is not supported on device, it must be given to this call as the optional second argument Op. This method is instantiated for int, double, and float.
This method performs the operation on device if the device flag of ldata is set. However, not all communication modes are supported on device yet. In such cases, the operation is performed on host.
Definition at line 1211 of file communication.cpp.
| void mfem::GroupCommunicator::ReduceBegin | ( | const T * | ldata | ) | const |
Begin reduction operation within each group where the master is the root, host version.
The input data layout is an array on all ldofs, i.e. layout 0, see CopyGroupToBuffer().
The reduce operation will be specified when calling ReduceEnd(). This method is instantiated for int, double, and float.
This method performs the operation on host and expects ldata to be a host pointer.
Definition at line 1054 of file communication.cpp.
| void mfem::GroupCommunicator::ReduceEnd | ( | Array< T > & | ldata, |
| int | layout, | ||
| void(* | Op )(OpData< T >) ) const |
Finalize reduction operation started with the device version of ReduceBegin().
The output data layout can be either 0 or 2, see CopyGroupToBuffer().
The reduce operation is given by the third argument (see below for list of the supported operations.) This method is instantiated for int, double, and float.
This method performs the operation on device if the device flag of ldata is set. However, not all communication modes and layouts are supported on device yet. In such cases, the operation is performed on host.
It is expected that the device flag of ldata is the same as the device flag of the data array provided to ReduceBegin().
Definition at line 1337 of file communication.cpp.
| void mfem::GroupCommunicator::ReduceEnd | ( | T * | ldata, |
| int | layout, | ||
| void(* | Op )(OpData< T >) ) const |
Finalize reduction operation started with the host version of ReduceBegin().
The output data layout can be either 0 or 2, see CopyGroupToBuffer().
The reduce operation is given by the third argument (see below for list of the supported operations.) This method is instantiated for int, double, and float.
This method performs the operation on host and expects ldata to be a host pointer.
Definition at line 1258 of file communication.cpp.
| const T * mfem::GroupCommunicator::ReduceGroupFromBuffer | ( | const T * | buf, |
| T * | ldata, | ||
| int | group, | ||
| int | layout, | ||
| void(* | Op )(OpData< T >) ) const |
Perform the reduction operation Op to the entries of group group using the values from the buffer buf and the values from the local array ldata, saving the result in the latter.
For a description of layout, see CopyGroupToBuffer().
Definition at line 708 of file communication.cpp.
| void mfem::GroupCommunicator::ReduceMarked | ( | T * | ldata, |
| const Array< int > & | marker, | ||
| int | layout, | ||
| void(* | Op )(OpData< T >) ) const |
Finalize reduction operation started with ReduceBegin(), but only apply the reduction to DOFs marked in the marker array.
Definition at line 1404 of file communication.cpp.
| void mfem::GroupCommunicator::SetLTDofTable | ( | const Array< int > & | ldof_ltdof | ) |
Initialize the internal group_ltdof Table.
This method must be called before performing operations that use local data layout 2, see CopyGroupToBuffer() for layout descriptions.
Definition at line 526 of file communication.cpp.
|
static |
Reduce operation Sum, instantiated for int, double and float.
Definition at line 1524 of file communication.cpp.
|
friend |
Definition at line 240 of file communication.hpp.
|
protected |
Definition at line 265 of file communication.hpp.
|
mutableprotected |
Definition at line 261 of file communication.hpp.
|
mutableprotected |
Definition at line 270 of file communication.hpp.
|
mutableprotected |
Definition at line 257 of file communication.hpp.
|
protected |
Definition at line 256 of file communication.hpp.
|
protected |
Definition at line 254 of file communication.hpp.
|
protected |
Definition at line 255 of file communication.hpp.
|
protected |
Definition at line 252 of file communication.hpp.
|
protected |
Definition at line 267 of file communication.hpp.
|
protected |
Definition at line 269 of file communication.hpp.
|
protected |
Definition at line 268 of file communication.hpp.
|
protected |
Definition at line 253 of file communication.hpp.
|
protected |
Definition at line 266 of file communication.hpp.
|
protected |
Definition at line 266 of file communication.hpp.
|
mutableprotected |
Definition at line 262 of file communication.hpp.
|
mutableprotected |
Definition at line 263 of file communication.hpp.
|
protected |
Definition at line 264 of file communication.hpp.
|
protected |
Definition at line 258 of file communication.hpp.