OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
CommSHMEMPI.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /***************************************************************************
3  *
4  * The IPPL Framework
5  *
6  *
7  * Visit http://people.web.psi.ch/adelmann/ for more details
8  *
9  ***************************************************************************/
10 
11 #ifndef COMM_SHMEMPI_H
12 #define COMM_SHMEMPI_H
13 
14 /***************************************************************************
15  * CommSHMEMPI.h - MPI-specific communications object for use with the
16  * Ippl framework. This differs from CommMPI in that it will, for on-box
17  * communication on symmetric multiprocessors, use SHMEM instead of MPI
18  * for greater efficiency. It is basically "MPI + SHMEM on-box". John
19  * Hall is the person to praise or blame for the name SHMEMPI.
20  *
21  * Allows user to establish id's for available nodes, establish connections,
22  * and send/receive data.
23  *
24  ***************************************************************************/
25 
26 // include files
27 #include "Message/Communicate.h"
28 
29 
30 class CommSHMEMPI : public Communicate
31 {
32 
33 public:
34  // constructor and destructor
35  // constructor arguments: command-line args, and number of processes
36  // to start (if < 0, start the 'default' number ... for MPI, this value
37  // will be ignored, since the number of nodes is determined by the args
38  // to mpirun.
39  CommSHMEMPI(int& argc, char**& argv, int procs = (-1));
40  virtual ~CommSHMEMPI(void);
41 
42  // return the name of this item
43  virtual const char *name() const
44  {
45  return "SHMEMPI";
46  }
47 
48  //
49  // virtual routines to deal with memory management
50  //
51 
52  // clean up after a Message has been used (called by Message).
53  virtual void cleanupMessage(void *);
54 
55 protected:
56 
57  //
58  // implementation-specific routines (which begin with 'my')
59  // these should be provided in a derived class, and contain the
60  // comm-library-specific code
61  //
62 
63  // send a message ... arguments are the Message itself, the
64  // destination node, the 'user' tag, and the 'encoding' tag.
65  // Messages should be sent via the underlying mechanism by using the
66  // encoding tag (one of the COMM_ tags),
67  // and should embed the information about what the user
68  // tag is in the data sent between nodes. Return success.
69  virtual bool mysend(Message *, int node, int utag, int etag);
70 
71  // receive a message from the given node and user tag. Return a NEW
72  // Message object if a message arrives, or NULL if no message available.
73  // node will be set to the node from which the message was sent.
74  // tag will be set to the 'user tag' for that message.
75  // etag is the 'encoding' tag, and must be one of the COMM_ tags.
76  // Only message sent via the underlying mechanism with the
77  // given etag are checked. When one is found, the user tag and sending
78  // node are extracted from the sent data.
79  // If node = COMM_ANY_NODE, checks for messages from any node.
80  // If tag = COMM_ANY_TAG, checks for messages with any user tag.
81  virtual Message *myreceive(int& node, int& tag, int etag);
82 
83  // Synchronize all processors (everybody waits for everybody
84  // else to get here before returning to calling function).
85  virtual void mybarrier(void);
86 
87 private:
88  // take data from the given Message, and pack it into the current send buf
89  void *pack_message(Message *msg, int tag, int &buffsize);
90 };
91 
92 #endif // COMM_SHMEMPI_H
void * pack_message(Message *msg, int tag, int &buffsize)
virtual void cleanupMessage(void *)
virtual bool mysend(Message *, int node, int utag, int etag)
virtual void mybarrier(void)
virtual ~CommSHMEMPI(void)
CommSHMEMPI(int &argc, char **&argv, int procs=(-1))
Definition: CommSHMEMPI.cpp:62
virtual const char * name() const
Definition: CommSHMEMPI.h:43
virtual Message * myreceive(int &node, int &tag, int etag)