src/Message/CommPVM.h

Go to the documentation of this file.
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_PVM_H
00012 #define COMM_PVM_H
00013 
00014 /*
00015  * CommPVM.h - PVM-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 CommPVM : 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 PVM virtual machine, the number of nodes in an O2K, etc)
00032   CommPVM(int argc = 0, char** argv = NULL, int procs = (-1));
00033   virtual ~CommPVM(void);
00034 
00035   // return the name of this item
00036   virtual const char *name() const { return "PVM"; }
00037 
00038 protected:
00039 
00040   //
00041   // implementation-specific routines (which begin with 'my')
00042   //    these should be provided in a derived class, and contain the
00043   //    comm-library-specific code
00044   //
00045 
00046   // send a message ... arguments are the Message itself, the
00047   // destination node, the 'user' tag, and the 'encoding' tag.
00048   // Messages should be sent via the underlying mechanism by using the
00049   // encoding tag (one of the COMM_ tags),
00050   // and should embed the information about what the user
00051   // tag is in the data sent between nodes.  Return success.
00052   virtual bool mysend(Message *, int node, int utag, int etag);
00053 
00054   // receive a message from the given node and user tag.  Return a NEW
00055   // Message object if a message arrives, or NULL if no message available.
00056   // node will be set to the node from which the message was sent.
00057   // tag will be set to the 'user tag' for that message.
00058   // etag is the 'encoding' tag, and must be one of the COMM_ tags. 
00059   // Only messages sent via the underlying mechanism with the
00060   // given etag are checked.  When one is found, the user tag and sending
00061   // node are extracted from the sent data.
00062   // If node = COMM_ANY_NODE, checks for messages from any node.
00063   // If tag = COMM_ANY_TAG, checks for messages with any user tag.
00064   virtual Message *myreceive(int& node, int& tag, int etag);
00065 
00066   // Synchronize all processors (everybody waits for everybody
00067   // else to get here before returning to calling function).
00068   virtual void mybarrier(void);
00069 
00070 private:
00071   char *execName;       // name of executable (without path)
00072   int *tids;            // task ID's for the tasks used by this application
00073 
00074   // take data from the given Message, and pack it into the current send buf
00075   void pack_message(Message *, int);
00076 
00077   // take data out of the current receive buf and create a new Message
00078   Message *unpack_message(int &node, int &tag);
00079 
00080 };
00081 
00082 #endif // COMM_PVM_H
00083 
00084 /***************************************************************************
00085  * $RCSfile: CommPVM.h,v $   $Author: adelmann $
00086  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:28 $
00087  * IPPL_VERSION_ID: $Id: CommPVM.h,v 1.1.1.1 2003/01/23 07:40:28 adelmann Exp $ 
00088  ***************************************************************************/

Generated on Mon Jan 16 13:23:51 2006 for IPPL by  doxygen 1.4.6