36 #ifndef MADNESS_WORLD_WORLDMPI_H__INCLUDED
37 #define MADNESS_WORLD_WORLDMPI_H__INCLUDED
61 #ifdef MADNESS_USE_BSEND_ACKS
62 #define MADNESS_ACK_BUFF_SIZE 1000
63 #endif // MADNESS_USE_BSEND_ACKS
65 #define MPI_THREAD_STRING(level) \
66 ( level==MPI_THREAD_SERIALIZED ? "THREAD_SERIALIZED" : \
67 ( level==MPI_THREAD_MULTIPLE ? "THREAD_MULTIPLE" : \
68 ( level==MPI_THREAD_FUNNELED ? "THREAD_FUNNELED" : \
69 ( level==MPI_THREAD_SINGLE ? "THREAD_SINGLE" : "THREAD_UNKNOWN" ) ) ) )
78 static const Tag DYNAMIC_TAG_BASE = 1024;
82 class WorldMpiRuntime;
99 #ifdef MADNESS_USE_BSEND_ACKS
100 static char* mpi_ack_buffer[MADNESS_ACK_BUFF_SIZE];
101 #endif // MADNESS_USE_BSEND_ACKS
108 WorldMpi(
int& argc,
char**& argv,
int requested) {
118 #ifdef MADNESS_USE_BSEND_ACKS
121 #endif // MADNESS_USE_BSEND_ACKS
125 WorldMpi(
const WorldMpi&);
126 WorldMpi& operator=(
const WorldMpi&);
134 #ifdef MADNESS_USE_BSEND_ACKS
138 #endif // MADNESS_USE_BSEND_ACKS
152 std::cout <<
"!! MPI Error: " << mpi_error_string <<
"\n";
169 static void initialize(
int& argc,
char**& argv,
int requested) {
172 MADNESS_ASSERT(! world_mpi);
185 if((provided < requested) && (rank == 0)) {
186 std::cout <<
"!! Error: MPI_Init_thread did not provide requested functionality: "
188 <<
"!! Error: The MPI standard makes no guarantee about the correctness of a program in such circumstances. \n"
189 <<
"!! Error: Please reconfigure your MPI to provide the proper thread support. \n"
192 }
else if((provided > requested) && (rank == 0)) {
193 std::cout <<
"!! Warning: MPI_Init_thread provided more than the requested functionality: "
195 <<
"!! Warning: You are likely using an MPI implementation with mediocre thread support. \n"
199 #if defined(MVAPICH2_VERSION)
201 char * mv2_string = NULL;
202 int mv2_affinity = 1;
204 if ((mv2_string = getenv(
"MV2_ENABLE_AFFINITY")) != NULL) {
205 mv2_affinity = atoi(mv2_string);
208 if (mv2_affinity!=0) {
209 std::cout <<
"!! Error: You are using MVAPICH2 with affinity enabled, probably by default. \n"
210 <<
"!! Error: This will cause catastrophic performance issues in MADNESS. \n"
211 <<
"!! Error: Rerun your job with MV2_ENABLE_AFFINITY=0 \n"
215 #endif // defined(MVAPICH2_VERSION)
272 template <
typename T>
274 Isend(
const T& datum,
int dest,
int tag=SafeMPI::DEFAULT_SEND_RECV_TAG)
const {
279 template <
typename T>
281 Irecv(
T* buf,
int count,
int source,
int tag=SafeMPI::DEFAULT_SEND_RECV_TAG)
const {
287 template <
typename T>
289 Irecv(
T& buf,
int source,
int tag=SafeMPI::DEFAULT_SEND_RECV_TAG)
const {
296 void Send(
const T* buf,
long lenbuf,
int dest,
int tag=SafeMPI::DEFAULT_SEND_RECV_TAG)
const {
304 template <
typename T>
306 Send(
const T& datum,
int dest,
int tag=SafeMPI::DEFAULT_SEND_RECV_TAG)
const {
312 template <
typename T>
313 void Recv(
T* buf,
long lenbuf,
int src,
int tag)
const {
318 template <
typename T>
325 template <
typename T>
327 Recv(
T& buf,
int src,
int tag=SafeMPI::DEFAULT_SEND_RECV_TAG)
const {
335 template <
typename T>
344 template <
typename T>
359 #endif // MADNESS_WORLD_WORLDMPI_H__INCLUDED
void Attach_buffer(void *buffer, int size)
Set buffer for Bsend .
Definition: safempi.h:773
Serializes calls to MPI in case it does not support THREAD_MULTIPLE.
Definition: shared_ptr_bits.h:38
Request Isend(const void *buf, const int count, const MPI_Datatype datatype, const int dest, const int tag) const
Definition: safempi.h:580
void Recv(void *buf, const int count, const MPI_Datatype datatype, const int source, const int tag, MPI_Status &status) const
Definition: safempi.h:611
MPI runtime reference counter.
Definition: worldmpi.h:232
void Recv(T *buf, long lenbuf, int src, int tag) const
Receive data of up to lenbuf elements from process dest.
Definition: worldmpi.h:313
#define MPI_THREAD_STRING(level)
Definition: worldmpi.h:65
Wrapper around MPI_Comm. Has a shallow copy constructor; use Create(Get_group()) for deep copy...
Definition: safempi.h:437
bool Is_initialized()
Check MPI initialization status.
Definition: safempi.h:112
static void initialize(int &argc, char **&argv, int requested)
Initialize the MPI runtime.
Definition: worldmpi.h:169
MPI singleton that manages MPI setup and teardown for MADNESS.
Definition: worldmpi.h:88
int Finalize()
Analogous to MPI_Finalize.
Definition: safempi.h:749
madness::disable_if< std::is_pointer< T >, void >::type Recv(T &buf, int src, int tag=SafeMPI::DEFAULT_SEND_RECV_TAG) const
Receive datum from process src.
Definition: worldmpi.h:327
Intracomm(const WorldInitObject &)
Definition: safempi.cc:66
WorldMpiRuntime()
Definition: worldmpi.h:237
int Tag
Used to clearly identify message tag/type.
Definition: worldtypes.h:38
~WorldMpi()
WorldMpi destructor.
Definition: worldmpi.h:133
void init_comm_world()
Initialize SafeMPI::COMM_WORLD.
Definition: safempi.h:695
SafeMPI::Request Irecv(T *buf, int count, int source, int tag=SafeMPI::DEFAULT_SEND_RECV_TAG) const
Async receive data of up to lenbuf elements from process dest.
Definition: worldmpi.h:281
madness::disable_if< std::is_pointer< T >, void >::type Send(const T &datum, int dest, int tag=SafeMPI::DEFAULT_SEND_RECV_TAG) const
Send element to process dest with default tag=1001.
Definition: worldmpi.h:306
SafeMPI::Intracomm & comm()
Returns the associated SafeMPI communicator.
Definition: worldmpi.h:259
int Get_size() const
Definition: safempi.h:575
This class wraps/extends the MPI interface for World.
Definition: worldmpi.h:245
POD holding excitation energy and response vector for a single excitation.
Definition: tdhf_CIS.h:134
World & initialize(int &argc, char **&argv)
Initialize the MADNESS runtime.
Definition: world.cc:134
#define MPI_COMM_WORLD
Definition: stubmpi.h:23
int MPI_Error_string(int errorcode, char *string, int *resultlen)
Definition: stubmpi.h:203
int Detach_buffer(void *&buffer)
Unset the Bsend buffer.
Definition: safempi.h:780
disable_if from Boost for conditionally instantiating templates based on type
Definition: enable_if.h:78
~WorldMpiRuntime()
Definition: worldmpi.h:238
#define MPI_BYTE
Definition: stubmpi.h:66
int size() const
Definition: worldmpi.h:354
madness::disable_if< std::is_pointer< T >, SafeMPI::Request >::type Isend(const T &datum, int dest, int tag=SafeMPI::DEFAULT_SEND_RECV_TAG) const
Isend one element ... disabled for pointers to reduce accidental misuse.
Definition: worldmpi.h:274
void Bcast(T *buffer, int count, int root) const
MPI broadcast an array of count elements.
Definition: worldmpi.h:336
int Init_thread(int &argc, char **&argv, int requested)
Analogous to MPI_Init_thread.
Definition: safempi.h:709
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
madness::disable_if< std::is_pointer< T >, SafeMPI::Request >::type Irecv(T &buf, int source, int tag=SafeMPI::DEFAULT_SEND_RECV_TAG) const
Async receive datum from process dest with default tag=1.
Definition: worldmpi.h:289
~WorldMpiInterface()
Definition: worldmpi.h:256
void Recv(T *buf, long lenbuf, int src, int tag, SafeMPI::Status &status) const
Receive data of up to lenbuf elements from process dest with status.
Definition: worldmpi.h:319
void finalize()
Call this once at the very end of your main program instead of calling MPI_Finalize.
Definition: world.cc:212
static void finalize()
Finalize the MPI runtime.
Definition: worldmpi.h:223
int Query_thread()
Analogous to MPI_Query_thread.
Definition: safempi.h:758
int Get_rank() const
Definition: safempi.h:570
WorldMpiInterface(const SafeMPI::Intracomm &comm)
Definition: worldmpi.h:252
Definition: safempi.h:243
void reset()
Definition: shared_ptr_bits.h:459
int rank() const
Definition: worldmpi.h:350
bool Is_finalized()
Check MPI finalization status.
Definition: safempi.h:121
madness::disable_if< std::is_pointer< T >, void >::type Bcast(T &buffer, int root) const
MPI broadcast a datum.
Definition: worldmpi.h:346
#define MPI_MAX_ERROR_STRING
Definition: stubmpi.h:31
Intracomm COMM_WORLD
Definition: safempi.cc:70
Definition: safempi.cc:36
void Bcast(void *buf, size_t count, const MPI_Datatype datatype, const int root) const
Definition: safempi.h:623
Request Irecv(void *buf, const int count, const MPI_Datatype datatype, const int src, const int tag) const
Definition: safempi.h:588
void Send(const void *buf, const int count, const MPI_Datatype datatype, int dest, int tag) const
Definition: safempi.h:596
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
Definition: safempi.h:178
void Send(const T *buf, long lenbuf, int dest, int tag=SafeMPI::DEFAULT_SEND_RECV_TAG) const
Send array of lenbuf elements to process dest.
Definition: worldmpi.h:296
int nproc() const
Definition: worldmpi.h:352
#define MPI_SUCCESS
Definition: stubmpi.h:28
int MPI_Abort(MPI_Comm, int code)
Definition: stubmpi.h:174