Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
commpi.C File Reference

Contains a dummy implementation of MPI subroutines for one thread. More...

#include "commpi.h"
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <map>
Include dependency graph for commpi.C:

Go to the source code of this file.

Typedefs

typedef std::map< int, void * > Msg_Queue
 A map from message tags to data addresses. More...
 

Functions

static int get_sizeof (MPI_Datatype i) throw (int)
 Get the size of a given MPI data type. More...
 
int COM_send (Msg_Queue &sendQ, Msg_Queue &recvQ, void *buf, int count, MPI_Datatype datatype, int tag)
 
int COM_recv (Msg_Queue &sendQ, Msg_Queue &recvQ, void *buf, int count, MPI_Datatype datatype, int tag)
 
int COMMPI_Isend (void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request)
 Begins a nonblocking send. More...
 
int COMMPI_Irecv (void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request *request)
 Begins a nonblocking receive. More...
 

Variables

static Msg_QueuesendQ =NULL
 
static Msg_QueuerecvQ =NULL
 

Detailed Description

Contains a dummy implementation of MPI subroutines for one thread.

If DUMMY_MPI is not define, it does produce anything. Note: This implementation is not thread-safe and it need not to be because it is only intended for a placeholder of MPI for one thread. It works even if MPI_Init was not called.

See Also
commpi.h

Definition in file commpi.C.

Typedef Documentation

typedef std::map<int, void*> Msg_Queue

A map from message tags to data addresses.

Definition at line 41 of file commpi.C.

Function Documentation

int COM_recv ( Msg_Queue sendQ,
Msg_Queue recvQ,
void *  buf,
int  count,
MPI_Datatype  datatype,
int  tag 
)

Definition at line 88 of file commpi.C.

References get_sizeof().

Referenced by COMMPI_Irecv().

89  {
90  try {
91  Msg_Queue::iterator it;
92  if ( (it=sendQ.find( tag)) != sendQ.end()) {
93  int extent=count*get_sizeof(datatype);
94  std::memcpy( buf, it->second, extent);
95  sendQ.erase(it);
96  }
97  else
98  recvQ[tag] = buf;
99  }
100  catch (int) {
101  std::cerr << "Unsupported data type " << datatype
102  << " used for MPI_Irecv" << std::endl;
103  std::abort();
104  }
105  return 0;
106 }
static Msg_Queue * sendQ
Definition: commpi.C:108
static int get_sizeof(MPI_Datatype i)
Get the size of a given MPI data type.
Definition: commpi.C:44
static Msg_Queue * recvQ
Definition: commpi.C:109

Here is the call graph for this function:

Here is the caller graph for this function:

int COM_send ( Msg_Queue sendQ,
Msg_Queue recvQ,
void *  buf,
int  count,
MPI_Datatype  datatype,
int  tag 
)

Definition at line 68 of file commpi.C.

References get_sizeof().

Referenced by COMMPI_Isend().

69  {
70  try {
71  Msg_Queue::iterator it;
72  if ( (it=recvQ.find( tag)) != recvQ.end()) {
73  int extent=count*get_sizeof(datatype);
74  std::memcpy( it->second, (char*)buf, extent);
75  recvQ.erase(it);
76  }
77  else
78  sendQ[tag] = buf;
79  }
80  catch (int) {
81  std::cerr << "Unsupported data type " << datatype
82  << " used for MPI_Isend" << std::endl;
83  std::abort();
84  }
85  return 0;
86 }
static Msg_Queue * sendQ
Definition: commpi.C:108
static int get_sizeof(MPI_Datatype i)
Get the size of a given MPI data type.
Definition: commpi.C:44
static Msg_Queue * recvQ
Definition: commpi.C:109

Here is the call graph for this function:

Here is the caller graph for this function:

int COMMPI_Irecv ( void *  buf,
int  count,
MPI_Datatype  datatype,
int  src,
int  tag,
MPI_Comm  comm,
MPI_Request *  request 
)

Begins a nonblocking receive.

Definition at line 131 of file commpi.C.

References COM_recv(), and COMMPI_Initialized().

Referenced by Pane_communicator::begin_update(), and Pane_ghost_connectivity::send_pane_info().

133  {
134 #ifndef DUMMY_MPI
135  if ( COMMPI_Initialized())
136  return MPI_Irecv( buf, count, datatype, src, tag, comm, request);
137 #endif
138  try {
139  if ( sendQ == NULL) sendQ = new Msg_Queue();
140  if ( recvQ == NULL) recvQ = new Msg_Queue();
141  }
142  catch (...) {
143  std::cerr << "Out of memory" << std::endl;
144  std::abort();
145  }
146  return COM_recv( *sendQ, *recvQ, buf, count, datatype, tag);
147 }
std::map< int, void * > Msg_Queue
A map from message tags to data addresses.
Definition: commpi.C:41
static Msg_Queue * sendQ
Definition: commpi.C:108
int COM_recv(Msg_Queue &sendQ, Msg_Queue &recvQ, void *buf, int count, MPI_Datatype datatype, int tag)
Definition: commpi.C:88
static Msg_Queue * recvQ
Definition: commpi.C:109
int COMMPI_Initialized()
Definition: commpi.h:168

Here is the call graph for this function:

Here is the caller graph for this function:

int COMMPI_Isend ( void *  buf,
int  count,
MPI_Datatype  datatype,
int  dest,
int  tag,
MPI_Comm  comm,
MPI_Request *  request 
)

Begins a nonblocking send.

Definition at line 112 of file commpi.C.

References COM_send(), and COMMPI_Initialized().

Referenced by Pane_communicator::begin_update(), and Pane_ghost_connectivity::send_pane_info().

114  {
115 #ifndef DUMMY_MPI
116  if ( COMMPI_Initialized())
117  return MPI_Isend( buf, count, datatype, dest, tag, comm, request);
118 #endif
119  try {
120  if ( sendQ == NULL) sendQ = new Msg_Queue();
121  if ( recvQ == NULL) recvQ = new Msg_Queue();
122  }
123  catch (...) {
124  std::cerr << "Out of memory" << std::endl;
125  std::abort();
126  }
127  return COM_send( *sendQ, *recvQ, buf, count, datatype, tag);
128 }
int COM_send(Msg_Queue &sendQ, Msg_Queue &recvQ, void *buf, int count, MPI_Datatype datatype, int tag)
Definition: commpi.C:68
std::map< int, void * > Msg_Queue
A map from message tags to data addresses.
Definition: commpi.C:41
static Msg_Queue * sendQ
Definition: commpi.C:108
static Msg_Queue * recvQ
Definition: commpi.C:109
int COMMPI_Initialized()
Definition: commpi.h:168

Here is the call graph for this function:

Here is the caller graph for this function:

static int get_sizeof ( MPI_Datatype  i)
throw (int
)
static

Get the size of a given MPI data type.

Definition at line 44 of file commpi.C.

References i, and MPI_BYTE.

Referenced by Attribute::allocate(), COM_get_sizeof(), COM_recv(), COM_send(), Attribute::copy_array(), Attribute::inherit(), io_hdf_data(), io_pane_attribute(), Roccom_base::set_f90pointer(), Attribute::set_pointer(), and write_attr_CGNS().

44  {
45  if(i == MPI_DOUBLE)
46  return(sizeof(double));
47  else if(i == MPI_FLOAT)
48  return(sizeof(float));
49  else if(i == MPI_INT)
50  return(sizeof(int));
51  else if(i == MPI_BYTE)
52  return(sizeof(char));
53  else if(i == MPI_CHAR)
54  return(sizeof(char));
55  else
56  throw(-1);
57 }
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_BYTE
blockLoc i
Definition: read.cpp:79

Here is the caller graph for this function:

Variable Documentation

Msg_Queue* recvQ =NULL
static

Definition at line 109 of file commpi.C.

Msg_Queue* sendQ =NULL
static

Definition at line 108 of file commpi.C.