- Main Page
- Classes
- Files
- 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 namespace sc {
    00039
    00040 class GlobalMsgIter: public DescribedClass {
    00041   protected:
    00042     int me_;
    00043     int nproc_;
    00044     int root_;
    00045     int i_;
    00046     int n_; // the number of steps--intialized by derived class CTORs
    00047     int fwd_;
    00048
    00049     // for sending messages in the forward direction (like a bcast)
    00050     virtual int fwdsendto() = 0;
    00051     virtual int fwdsend() = 0;
    00052     virtual int fwdrecvfrom() = 0;
    00053     virtual int fwdrecv() = 0;
    00054   public:
    00055     GlobalMsgIter(int nproc, int me, int root = 0);
    00056     ~GlobalMsgIter();
    00057     void backwards() { fwd_ = 0; i_ = n_ - 1; }
    00058     void forwards() { fwd_ = 1; i_ = 0; }
    00059     void next() { if (fwd_) i_++; else i_--; }
    00060     int done() { return i_<0 || i_>=n_; }
    00061     int n() { return n_; }
    00062     int sendto() { return fwd_?fwdsendto():fwdrecvfrom(); }
    00063     int send() { return fwd_?fwdsend():fwdrecv(); }
    00064     int recvfrom() { return fwd_?fwdrecvfrom():fwdsendto(); }
    00065     int recv() { return fwd_?fwdrecv():fwdsend(); }
    00066 };
    00067
    00068
    00069 class MessageGrp;
    00070 class MachineTopology: public DescribedClass {
    00071   public:
    00072     MachineTopology();
    00073     MachineTopology(const Ref<KeyVal>&);
    00074     ~MachineTopology();
    00075
    00076     virtual Ref<GlobalMsgIter> global_msg_iter(const Ref<MessageGrp>&,
    00077                                              int target) = 0;
    00078 };
    00079
    00080 }
    00081
    00082 #endif
    00083
    00084 // Local Variables:
    00085 // mode: c++
    00086 // c-file-style: "CLJ"
    00087 // End: