PaGMO  1.1.5
Public Member Functions | Static Public Member Functions
pagmo::mpi_environment Class Reference

MPI environment class. More...

#include <mpi_environment.h>

Inherits noncopyable.

Public Member Functions

 mpi_environment ()
 Default constructor. More...
 
 ~mpi_environment ()
 Destructor. More...
 

Static Public Member Functions

static bool is_multithread ()
 Thread-safety of the MPI implementation. More...
 
static int get_size ()
 MPI world size. More...
 
static int get_rank ()
 MPI rank. More...
 
template<class T >
static void recv (T &retval, int source)
 Receive MPI payload. More...
 
template<class T >
static void send (const T &payload, int destination)
 Send MPI payload. More...
 
static bool iprobe (int)
 Probe for message. More...
 

Detailed Description

MPI environment class.

This class is used to initialise the PaGMO MPI environment: an instance of this class should be created before using any MPI feature in PaGMO. Apart from this kind of usage, regular users should never need to access any method from this class. See the MPI page for a usage example.

NOTE: this class is available only if PaGMO was compiled with MPI support.

Author
Francesco Biscani (blues.nosp@m.carn.nosp@m.i@gma.nosp@m.il.c.nosp@m.om)

Definition at line 174 of file mpi_environment.h.

Constructor & Destructor Documentation

pagmo::mpi_environment::mpi_environment ( )

Default constructor.

Initialises the MPI environment with MPI_Init_thread. pagmo::mpi_environment objects should be created only in the main thread of execution.

Exceptions
std::runtime_errorif another instance of this class has already been created, or if the MPI implementation does not support at least the MPI_THREAD_SERIALIZED thread level and this is the root node, or if the world size is not at least 2.

Definition at line 51 of file mpi_environment.cpp.

pagmo::mpi_environment::~mpi_environment ( )

Destructor.

Will send a shutdown signal to all processes with nonzero rank and call MPI_Finalize().

Definition at line 81 of file mpi_environment.cpp.

Member Function Documentation

int pagmo::mpi_environment::get_rank ( )
static

MPI rank.

This method is thread-safe only if mpi_environment::is_multithread returns true.

Returns
the MPI rank of the process.
Exceptions
std::runtime_errorif the MPI environment has not been initialised.

Definition at line 145 of file mpi_environment.cpp.

int pagmo::mpi_environment::get_size ( )
static

MPI world size.

This method is thread-safe only if mpi_environment::is_multithread returns true.

Returns
the MPI world size.
Exceptions
std::runtime_errorif the MPI environment has not been initialised.

Definition at line 129 of file mpi_environment.cpp.

bool pagmo::mpi_environment::iprobe ( int  source)
static

Probe for message.

This method is thread-safe only if mpi_environment::is_multithread returns true.

Parameters
[in]sourcerank of the processor that will be probed.
Returns
true if source sent a message to this process, false otherwise.
Exceptions
std::runtime_errorif the MPI environment has not been initialised.

Definition at line 112 of file mpi_environment.cpp.

bool pagmo::mpi_environment::is_multithread ( )
static

Thread-safety of the MPI implementation.

This method is always thread-safe.

Returns
true if the MPI implementation of this process is completely thred-safe (i.e., the MPI implementation supports MPI_THREAD_MULTIPLE), false for any other MPI thread level.
Exceptions
std::runtime_errorif the MPI environment has not been initialised.

Definition at line 162 of file mpi_environment.cpp.

template<class T >
static void pagmo::mpi_environment::recv ( T &  retval,
int  source 
)
inlinestatic

Receive MPI payload.

Receive an instance of class T from the processor with ID source and store it into retval. This method is thread-safe only if mpi_environment::is_multithread returns true.

Parameters
[out]retvalinstance of class T that will contain the payload.
[in]sourcerank of the processor from which the message will be received.

Definition at line 191 of file mpi_environment.h.

template<class T >
static void pagmo::mpi_environment::send ( const T &  payload,
int  destination 
)
inlinestatic

Send MPI payload.

Send an instance of class T to the processor with ID destination. This method is thread-safe only if mpi_environment::is_multithread returns true.

Parameters
[in]payloadinstance of class T that will be sent to destination.
[in]destinationrank of the processor to which the message will be sent.

Definition at line 218 of file mpi_environment.h.


The documentation for this class was generated from the following files: