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 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     void backwards() { fwd_ = 0; i_ = n_ - 1; }
    00057     void forwards() { fwd_ = 1; i_ = 0; }
    00058     void next() { if (fwd_) i_++; else i_--; }
    00059     int done() { return i_<0 || i_>=n_; }
    00060     int n() { return n_; }
    00061     int sendto() { return fwd_?fwdsendto():fwdrecvfrom(); }
    00062     int send() { return fwd_?fwdsend():fwdrecv(); }
    00063     int recvfrom() { return fwd_?fwdrecvfrom():fwdsendto(); }
    00064     int recv() { return fwd_?fwdrecv():fwdsend(); }
    00065 };
    00066
    00067
    00068 class MessageGrp;
    00069 class MachineTopology: public DescribedClass {
    00070   public:
    00071     MachineTopology();
    00072     MachineTopology(const Ref<KeyVal>&);
    00073     ~MachineTopology();
    00074
    00075     virtual Ref<GlobalMsgIter> global_msg_iter(const Ref<MessageGrp>&,
    00076                                              int target) = 0;
    00077 };
    00078
    00079 }
    00080
    00081 #endif
    00082
    00083 // Local Variables:
    00084 // mode: c++
    00085 // c-file-style: "CLJ"
    00086 // End: