00001 // -*- C++ -*- 00002 /*************************************************************************** 00003 * 00004 * The IPPL Framework 00005 * 00006 * 00007 * Visit http://people.web.psi.ch/adelmann/ for more details 00008 * 00009 ***************************************************************************/ 00010 00011 #ifndef COMM_PM_H 00012 #define COMM_PM_H 00013 00014 /*************************************************************************** 00015 * CommPM.h - PM-specific communications object for use with the 00016 * Ippl framework. 00017 * Allows user to establish id's for available nodes, establish connections, 00018 * and send/receive data. 00019 ***************************************************************************/ 00020 00021 // include files 00022 #include "Message/Communicate.h" 00023 00024 00025 class CommPM : public Communicate { 00026 00027 public: 00028 // constructor and destructor 00029 // constructor arguments: command-line args, and number of processes 00030 // to start (if < 0, start the 'default' number, i.e. the number of 00031 // hosts in a MPI virtual machine, the number of nodes in an O2K, etc) 00032 CommPM(int& argc, char**& argv, int procs = (-1)); 00033 virtual ~CommPM(void); 00034 00035 // return the name of this item 00036 virtual const char *name() const { return "PM"; } 00037 00038 // 00039 // virtual routines to deal with memory management 00040 // 00041 00042 // clean up after a Message has been used (called by Message). 00043 virtual void cleanupMessage(void *); 00044 00045 protected: 00046 00047 // 00048 // implementation-specific routines (which begin with 'my') 00049 // these should be provided in a derived class, and contain the 00050 // comm-library-specific code 00051 // 00052 00053 // send a message ... arguments are the Message itself, the 00054 // destination node, the 'user' tag, and the 'encoding' tag. 00055 // Messages should be sent via the underlying mechanism by using the 00056 // encoding tag (one of the COMM_ tags), 00057 // and should embed the information about what the user 00058 // tag is in the data sent between nodes. Return success. 00059 virtual bool mysend(Message *, int node, int utag, int etag); 00060 00061 // receive a message from the given node and user tag. Return a NEW 00062 // Message object if a message arrives, or NULL if no message available. 00063 // node will be set to the node from which the message was sent. 00064 // tag will be set to the 'user tag' for that message. 00065 // etag is the 'encoding' tag, and must be one of the COMM_ tags. 00066 // Only message sent via the underlying mechanism with the 00067 // given etag are checked. When one is found, the user tag and sending 00068 // node are extracted from the sent data. 00069 // If node = COMM_ANY_NODE, checks for messages from any node. 00070 // If tag = COMM_ANY_TAG, checks for messages with any user tag. 00071 virtual Message *myreceive(int& node, int& tag, int etag); 00072 00073 // Synchronize all processors (everybody waits for everybody 00074 // else to get here before returning to calling function). 00075 virtual void mybarrier(void); 00076 00077 private: 00078 // pickup message from PM buffer 00079 int pickup_message(void); 00080 }; 00081 00082 00083 #endif // COMM_PM_H 00084 00085 /*************************************************************************** 00086 * $RCSfile: CommPM.h,v $ $Author: adelmann $ 00087 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:28 $ 00088 * IPPL_VERSION_ID: $Id: CommPM.h,v 1.1.1.1 2003/01/23 07:40:28 adelmann Exp $ 00089 ***************************************************************************/