Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

topology.h

00001 //
00002 // topology.h
00003 //
00004 // Copyright (C) 1996 Limit Point Systems, Inc.
00005 //
00006 // Author: Curtis Janssen <cljanss@limitpt.com>
00007 // Maintainer: LPS
00008 //
00009 // This file is part of the SC Toolkit.
00010 //
00011 // The SC Toolkit is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Library General Public License as published by
00013 // the Free Software Foundation; either version 2, or (at your option)
00014 // any later version.
00015 //
00016 // The SC Toolkit is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 // GNU Library General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Library General Public License
00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
00024 //
00025 // The U.S. Government is granted a limited license as per AL 91-7.
00026 //
00027 
00028 #ifdef __GNUG__
00029 #pragma interface
00030 #endif
00031 
00032 #ifndef _util_group_topology_h
00033 #define _util_group_topology_h
00034 
00035 #include <util/class/class.h>
00036 #include <util/keyval/keyval.h>
00037 
00038 class GlobalMsgIter: public DescribedClass {
00039   protected:
00040     int me_;
00041     int nproc_;
00042     int root_;
00043     int i_;
00044     int n_; // the number of steps--intialized by derived class CTORs
00045     int fwd_;
00046 
00047     // for sending messages in the forward direction (like a bcast)
00048     virtual int fwdsendto() = 0;
00049     virtual int fwdsend() = 0;
00050     virtual int fwdrecvfrom() = 0;
00051     virtual int fwdrecv() = 0;
00052   public:
00053     GlobalMsgIter(int nproc, int me, int root = 0);
00054     void backwards() { fwd_ = 0; i_ = n_ - 1; }
00055     void forwards() { fwd_ = 1; i_ = 0; }
00056     void next() { if (fwd_) i_++; else i_--; }
00057     int done() { return i_<0 || i_>=n_; }
00058     int n() { return n_; }
00059     int sendto() { return fwd_?fwdsendto():fwdrecvfrom(); }
00060     int send() { return fwd_?fwdsend():fwdrecv(); }
00061     int recvfrom() { return fwd_?fwdrecvfrom():fwdsendto(); }
00062     int recv() { return fwd_?fwdrecv():fwdsend(); }
00063 };
00064 
00065 
00066 class MessageGrp;
00067 class MachineTopology: public DescribedClass {
00068   public:
00069     MachineTopology();
00070     MachineTopology(const Ref<KeyVal>&);
00071     ~MachineTopology();
00072 
00073     virtual Ref<GlobalMsgIter> global_msg_iter(const Ref<MessageGrp>&,
00074                                              int target) = 0;
00075 };
00076 
00077 
00078 #endif
00079 
00080 // Local Variables:
00081 // mode: c++
00082 // c-file-style: "CLJ"
00083 // End:

Generated at Thu Oct 4 18:08:47 2001 for MPQC 2.0.0 using the documentation package Doxygen 1.2.5.