00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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_;
00047 int fwd_;
00048
00049
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
00085
00086
00087