00001
00002
00003 #ifndef _included_DAGHDistribution_h
00004 #define _included_DAGHDistribution_h
00005
00011 #include "DAGHParams.h"
00012 #include "DAGHDefaults.h"
00013
00014 #include "GridUnit.h"
00015 #include "GridUnitList.h"
00016
00017
00018
00019
00020 typedef unsigned long (*WorkFunc) (const unsigned long *numelems,
00021 const int *level);
00022
00023
00024 class DAGHSpan
00025 {
00026 dMapIndex min;
00027 dMapIndex max;
00028
00029 public:
00030 inline DAGHSpan() {}
00031
00032 inline DAGHSpan(dMapIndex const &lmin, dMapIndex const &lmax)
00033 : min(lmin), max(lmax) { }
00034
00035 inline DAGHSpan(const DAGHSpan& other)
00036 : min(other.min), max(other.max) { }
00037
00038 inline int contains(dMapIndex const index) const
00039 { return (index >= min && index <= max); }
00040
00041 inline const DAGHSpan& operator = (const DAGHSpan& other)
00042 { min = other.min; max = other.max; return *this; }
00043 };
00044
00049 class DAGHDistribution
00050 {
00052 int type;
00053
00055 BBox* boxes;
00056
00058 WorkFunc wfunc;
00059
00060 public:
00061 inline DAGHDistribution(const int disttype)
00062 : type(disttype) , boxes(0), wfunc(0) { }
00063
00064 DAGHDistribution(const int disttype, BBoxList& bbl);
00065
00066 inline ~DAGHDistribution() { if (boxes) delete [] boxes; }
00067
00068 void partition(GridUnitList*& globallist,
00069 GridUnitList*& locallist,
00070 const int np, const int me,
00071 const int minw, const short* olap);
00072
00073 void partition(const BBox& wbbox, BBox& mybbox,
00074 const int np, const int me);
00075
00076
00077
00078 inline int dist() const { return type; }
00079
00080 inline void set_dist(const int disttype)
00081 { type = disttype; }
00082
00083 void set_dist(const int disttype, BBoxList& bbl);
00084
00085 inline void set_workfunc( void *workfunc )
00086 { wfunc = (WorkFunc) workfunc; }
00087
00088 unsigned long get_load( GridUnitList &list, const short* olap );
00089
00090 private:
00091 void partitionComposite(GridUnitList*& globallist,
00092 GridUnitList*& locallist,
00093 const int np, const int me,
00094 const int minw, const short* olap);
00095
00096 void partitionBlockOne(const int axis,
00097 GridUnitList*& globallist,
00098 GridUnitList*& locallist,
00099 const int np, const int me,
00100 const int minw, const short* olap);
00101
00102 void partitionBlockTwo(const int axis1, const int axis2,
00103 GridUnitList*& globallist,
00104 GridUnitList*& locallist,
00105 const int np, const int me,
00106 const int minw, const short* olap);
00107
00108 void partitionBlockAll(GridUnitList*& globallist,
00109 GridUnitList*& locallist,
00110 const int np, const int me,
00111 const int minw, const short* olap);
00112
00113 void partitionUserDef(GridUnitList*& globallist,
00114 GridUnitList*& locallist,
00115 const int np, const int me,
00116 const int minw, const short* olap);
00117 };
00118
00119 #endif