OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
CommPM.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_PM_H
12 #define COMM_PM_H
13 
14 /***************************************************************************
15  * CommPM.h - PM-specific communications object for use with the
16  * Ippl framework.
17  * Allows user to establish id's for available nodes, establish connections,
18  * and send/receive data.
19  ***************************************************************************/
20 
21 // include files
22 #include "Message/Communicate.h"
23 
24 
25 class CommPM : public Communicate
26 {
27 
28 public:
29  // constructor and destructor
30  // constructor arguments: command-line args, and number of processes
31  // to start (if < 0, start the 'default' number, i.e. the number of
32  // hosts in a MPI virtual machine, the number of nodes in an O2K, etc)
33  CommPM(int& argc, char**& argv, int procs = (-1));
34  virtual ~CommPM(void);
35 
36  // return the name of this item
37  virtual const char *name() const
38  {
39  return "PM";
40  }
41 
42  //
43  // virtual routines to deal with memory management
44  //
45 
46  // clean up after a Message has been used (called by Message).
47  virtual void cleanupMessage(void *);
48 
49 protected:
50 
51  //
52  // implementation-specific routines (which begin with 'my')
53  // these should be provided in a derived class, and contain the
54  // comm-library-specific code
55  //
56 
57  // send a message ... arguments are the Message itself, the
58  // destination node, the 'user' tag, and the 'encoding' tag.
59  // Messages should be sent via the underlying mechanism by using the
60  // encoding tag (one of the COMM_ tags),
61  // and should embed the information about what the user
62  // tag is in the data sent between nodes. Return success.
63  virtual bool mysend(Message *, int node, int utag, int etag);
64 
65  // receive a message from the given node and user tag. Return a NEW
66  // Message object if a message arrives, or NULL if no message available.
67  // node will be set to the node from which the message was sent.
68  // tag will be set to the 'user tag' for that message.
69  // etag is the 'encoding' tag, and must be one of the COMM_ tags.
70  // Only message sent via the underlying mechanism with the
71  // given etag are checked. When one is found, the user tag and sending
72  // node are extracted from the sent data.
73  // If node = COMM_ANY_NODE, checks for messages from any node.
74  // If tag = COMM_ANY_TAG, checks for messages with any user tag.
75  virtual Message *myreceive(int& node, int& tag, int etag);
76 
77  // Synchronize all processors (everybody waits for everybody
78  // else to get here before returning to calling function).
79  virtual void mybarrier(void);
80 
81 private:
82  // pickup message from PM buffer
83  int pickup_message(void);
84 };
85 
86 #endif // COMM_PM_H
virtual bool mysend(Message *, int node, int utag, int etag)
Definition: CommPM.cpp:305
CommPM(int &argc, char **&argv, int procs=(-1))
Definition: CommPM.cpp:78
virtual const char * name() const
Definition: CommPM.h:37
Definition: CommPM.h:25
int pickup_message(void)
Definition: CommPM.cpp:359
virtual void cleanupMessage(void *)
Definition: CommPM.cpp:477
virtual ~CommPM(void)
Definition: CommPM.cpp:213
virtual Message * myreceive(int &node, int &tag, int etag)
Definition: CommPM.cpp:417
virtual void mybarrier(void)
Definition: CommPM.cpp:467