Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
mpi_wrappers.hpp File Reference
#include <mpi.h>
#include <petsc.h>
#include <cassert>
#include <iostream>
#include <stdexcept>
#include <string>
#include <vector>
#include <Eigen/Dense>
#include "vulpes/datastructure/crs_map.hpp"
#include "vulpes/utils/profiler.hpp"
#include "vulpes/utils/threading.hpp"
Include dependency graph for mpi_wrappers.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  vulpes::mpi::MpiHandle

Namespaces

namespace  vulpes
namespace  vulpes::mpi

Functions

template<typename T>
MPI_Datatype vulpes::mpi::getMpiType ()
 Map a C++ arithmetic type to its corresponding MPI_Datatype.
static bool vulpes::mpi::isInitialized ()
 Return true if MPI has been initialized.
static bool vulpes::mpi::isPetscInitialized ()
 Return true if PETSc has been initialized.
static bool vulpes::mpi::isFinalized ()
 Return true if MPI has been finalized.
static bool vulpes::mpi::isPetscFinalized ()
 Return true if PETSc has been finalized.
static int vulpes::mpi::rank ()
 Return the MPI rank in MPI_COMM_WORLD.
static int vulpes::mpi::size ()
 Return the size of MPI_COMM_WORLD.
static bool vulpes::mpi::root ()
 Return true if the rank in MPI_COMM_WORLD is zero.
template<typename T>
void vulpes::mpi::send (const T *data, int count, int destination, MPI_Comm communicator=MPI_COMM_WORLD)
 Send count contiguous values of type T to a destination rank.
template<typename T>
void vulpes::mpi::send (const T &data, int destination, MPI_Comm communicator=MPI_COMM_WORLD)
 Send a single value of type T to a destination rank.
template<typename T>
void vulpes::mpi::send (const std::vector< T > &data, int destination, MPI_Comm communicator=MPI_COMM_WORLD)
 Send a std::vector<T>, prefixed with its size.
void vulpes::mpi::send (const std::string &data, int destination, MPI_Comm communicator=MPI_COMM_WORLD)
 Send a std::string, prefixed with its size.
template<typename T, std::size_t N>
void vulpes::mpi::send (const std::vector< std::array< T, N > > &data, int destination, MPI_Comm communicator=MPI_COMM_WORLD)
 Send a std::vector<std::array<T, N>>, prefixed with its size.
template<typename T, int N, int M, int Options>
void vulpes::mpi::send (const std::vector< Eigen::Matrix< T, N, M, Options > > &data, int destination, MPI_Comm communicator=MPI_COMM_WORLD)
 Send a std::vector of fixed-size Eigen matrices, prefixed with its size.
template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
void vulpes::mpi::send (const datastructure::CrsMap< DataType, IndexType, RowSize > &map, int destination, MPI_Comm communicator=MPI_COMM_WORLD)
 Send a CrsMap by sending its data and indices in sequence.
template<typename T>
void vulpes::mpi::recv (T *data, int count, int source, MPI_Comm communicator=MPI_COMM_WORLD, MPI_Status *status=MPI_STATUS_IGNORE)
 Receive count contiguous values of type T from a source rank.
template<typename T>
T vulpes::mpi::recv (int source, MPI_Comm communicator=MPI_COMM_WORLD, MPI_Status *status=MPI_STATUS_IGNORE)
 Receive a single value of type T from a source rank.
template<typename T>
void vulpes::mpi::recv (std::vector< T > &data, int source, MPI_Comm communicator=MPI_COMM_WORLD, MPI_Status *status=MPI_STATUS_IGNORE)
 Receive a std::vector<T> previously sent with send(), resizing data to the transmitted size.
void vulpes::mpi::recv (std::string &data, int source, MPI_Comm communicator=MPI_COMM_WORLD, MPI_Status *status=MPI_STATUS_IGNORE)
 Receive a std::string previously sent with send(), resizing data to the transmitted size.
template<typename T, std::size_t N>
void vulpes::mpi::recv (std::vector< std::array< T, N > > &data, int source, MPI_Comm communicator=MPI_COMM_WORLD, MPI_Status *status=MPI_STATUS_IGNORE)
 Receive a std::vector<std::array<T, N>> previously sent with send(), resizing data to the transmitted size.
template<typename T, int N, int M, int Options>
void vulpes::mpi::recv (std::vector< Eigen::Matrix< T, N, M, Options > > &data, int source, MPI_Comm communicator=MPI_COMM_WORLD, MPI_Status *status=MPI_STATUS_IGNORE)
 Receive a std::vector of fixed-size Eigen matrices previously sent with send(), resizing data to the transmitted size.
template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
void vulpes::mpi::recv (datastructure::CrsMap< DataType, IndexType, RowSize > &map, int source, MPI_Comm communicator=MPI_COMM_WORLD, MPI_Status *status=MPI_STATUS_IGNORE)
 Receive a CrsMap by receiving its data and indices in sequence.
template<typename T>
void vulpes::mpi::bcast (T *data, int count, int root, MPI_Comm communicator=MPI_COMM_WORLD)
 Broadcast count contiguous values of type T from root.
template<typename T>
void vulpes::mpi::bcast (T &data, int root, MPI_Comm communicator=MPI_COMM_WORLD)
 Broadcast a single value of type T from root.
template<typename T>
void vulpes::mpi::bcast (std::vector< T > &data, int root, MPI_Comm communicator=MPI_COMM_WORLD)
 Broadcast a std::vector<T> from root, resizing data on the other ranks to match the root's size.
void vulpes::mpi::bcast (std::string &data, int root, MPI_Comm communicator=MPI_COMM_WORLD)
 Broadcast a std::string from root, resizing data on the other ranks to match the root's size.
template<typename T, int N, int M, int Options>
void vulpes::mpi::bcast (Eigen::Matrix< T, N, M, Options > &data, int root, MPI_Comm communicator=MPI_COMM_WORLD)
 Broadcast a dynamically-sized Eigen matrix from root, resizing data on the other ranks to match the root's shape.
template<typename T>
void vulpes::mpi::reduce (const T *send_data, T *recv_data, int count, MPI_Op op, int root, MPI_Comm communicator=MPI_COMM_WORLD)
 Reduce count contiguous values of type T onto root.
template<typename T>
T vulpes::mpi::reduce (const T &send_data, MPI_Op op, int root, MPI_Comm communicator=MPI_COMM_WORLD)
 Reduce a single value of type T onto root.
auto vulpes::mpi::computeChuncks (int32_t count, int32_t stride=1)
 Split count elements into near-equal contiguous chunks, one per rank in the current communicator.
template<typename T>
void vulpes::mpi::gather (const T *send_data, int send_count, T *recv_data, int recv_count, int root, MPI_Comm communicator=MPI_COMM_WORLD)
 Gather send_count contiguous values of type T from every rank into recv_data on root.
template<typename T>
void vulpes::mpi::gather (const std::vector< T > &send_data, std::vector< T > &recv_data, int root, MPI_Comm communicator=MPI_COMM_WORLD)
 Gather a std::vector<T> of equal size from every rank into recv_data on root.
template<typename T>
void vulpes::mpi::gatherv (const T *send_data, int send_count, T *recv_data, int *recv_count, int *displs, int root, MPI_Comm communicator=MPI_COMM_WORLD)
 Gather variable-length contiguous values of type T from every rank into recv_data on root.
template<typename T>
void vulpes::mpi::scatter (const T *send_data, int send_count, T *recv_data, int recv_count, int root, MPI_Comm communicator=MPI_COMM_WORLD)
 Scatter recv_count contiguous values of type T from root to every rank.
template<typename T>
void vulpes::mpi::scatter (const std::vector< T > &send_data, std::vector< T > &recv_data, int root, MPI_Comm communicator=MPI_COMM_WORLD)
 Scatter a std::vector<T> from root into equal-size chunks on every rank.
template<typename T>
void vulpes::mpi::scatterv (const T *send_data, int *send_counts, int *displacements, T *recv_data, int recv_count, int root, MPI_Comm mpi_comm=MPI_COMM_WORLD, MPI_Datatype send_t=getMpiType< T >(), MPI_Datatype recv_t=getMpiType< T >())
 Scatter variable-length contiguous values of type T from root to every rank.

Variables

static constexpr int vulpes::mpi::s_default_tag = 0
 Default MPI message tag used by all wrappers in this file.