Program Listing for File mpi_env.hpp¶
↰ Return to documentation for file (/home/docs/checkouts/readthedocs.org/user_builds/intel-qs/checkouts/docs/include/mpi_env.hpp
)
#ifndef IQS_MPI_ENV_HPP
#define IQS_MPI_ENV_HPP
#ifdef INTELQS_HAS_MPI
#include <mpi.h>
#endif
#include <string>
#include <unistd.h>
#ifdef INTELQS_HAS_MPI
#include "mpi_exception.hpp"
#endif
#ifdef _OPENMP
#include <omp.h>
#endif
namespace qhipster {
namespace mpi {
class Environment
{
public:
Environment(int& argc, char**& argv);
~Environment();
Environment(Environment const&) = delete;
Environment& operator=(Environment const&) = delete;
// One needs to know what he/she is doing to call this method.
static void UpdateStateComm (int num_states, bool do_print_info=true);
static bool IsUsefulRank() {return useful_rank;}
static int GetPoolRank();
static int GetStateRank();
static int GetRank() {return GetStateRank();}
static int GetPoolSize();
static int GetStateSize();
static int GetSize() {return GetStateSize();}
template <class Type>
static Type IncoherentSumOverAllStatesOfPool(Type local_value);
static int GetNumRanksPerNode();
static int GetNumNodes();
static int GetNodeId();
static int GetStateId();
static int GetNumStates();
static void RemapStateRank(int newme);
#ifdef INTELQS_HAS_MPI
static MPI_Comm pool_communicator;
static MPI_Comm state_communicator;
static MPI_Comm GetPoolComm();
static MPI_Comm GetStateComm();
static MPI_Comm GetComm();
#endif
private:
bool inited_;
static bool useful_rank;
// int num_ranks_per_state;
static int num_ranks_per_node;
static int num_nodes;
static int my_node_id;
static int num_states;
static int my_state_id;
#ifdef INTELQS_HAS_MPI
MPI_Request synch_request;
#endif
};
void PoolBarrier();
void StateBarrier();
void Barrier();
void PoolPrint(std::string s, bool all=false);
void StatePrint(std::string s, bool all=false);
void Print(std::string s, bool all=false);
#ifdef INTELQS_HAS_MPI
void Print(std::string s, MPI_Comm comm, bool all=true);
#endif
} // end namespace mpi
} // end namespace qhipster
#endif // header guard IQS_MPI_ENV_HPP