00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00041 #ifndef __vtkSubGroup_h
00042 #define __vtkSubGroup_h
00043
00044 #include "vtkObject.h"
00045
00046 class vtkMultiProcessController;
00047 class vtkCommunicator;
00048
00049 class VTK_PARALLEL_EXPORT vtkSubGroup : public vtkObject
00050 {
00051 public:
00052 vtkTypeMacro(vtkSubGroup, vtkObject);
00053 virtual void PrintSelf(ostream &os, vtkIndent indent);
00054 static vtkSubGroup *New();
00055
00056
00057
00058 enum {MINOP = 1, MAXOP = 2, SUMOP = 3};
00059
00066 int Initialize(int p0, int p1, int me, int tag, vtkCommunicator *c);
00067
00068 int Gather(int *data, int *to, int length, int root);
00069 int Gather(char *data, char *to, int length, int root);
00070 int Gather(float *data, float *to, int length, int root);
00071 #ifdef VTK_USE_64BIT_IDS
00072 int Gather(vtkIdType *data, vtkIdType *to, int length, int root);
00073 #endif
00074 int Broadcast(float *data, int length, int root);
00075 int Broadcast(double *data, int length, int root);
00076 int Broadcast(int *data, int length, int root);
00077 int Broadcast(char *data, int length, int root);
00078 #ifdef VTK_USE_64BIT_IDS
00079 int Broadcast(vtkIdType *data, int length, int root);
00080 #endif
00081 int ReduceSum(int *data, int *to, int length, int root);
00082 int ReduceMax(float *data, float *to, int length, int root);
00083 int ReduceMax(double *data, double *to, int length, int root);
00084 int ReduceMax(int *data, int *to, int length, int root);
00085 int ReduceMin(float *data, float *to, int length, int root);
00086 int ReduceMin(double *data, double *to, int length, int root);
00087 int ReduceMin(int *data, int *to, int length, int root);
00088
00089 int AllReduceUniqueList(int *list, int len, int **newList);
00090 int MergeSortedUnique(int *list1, int len1, int *list2, int len2, int **newList);
00091
00092 void setGatherPattern(int root, int length);
00093 int getLocalRank(int processID);
00094
00095 int Barrier();
00096
00097 void PrintSubGroup() const;
00098
00099 static int MakeSortedUnique(int *list, int len, int **newList);
00100
00101 int tag;
00102
00103 protected:
00104 vtkSubGroup();
00105 ~vtkSubGroup();
00106
00107 private:
00108 int computeFanInTargets();
00109 void restoreRoot(int rootLoc);
00110 void moveRoot(int rootLoc);
00111 void setUpRoot(int root);
00112
00113 int nFrom;
00114 int nTo;
00115
00116 int sendId;
00117 int sendOffset;
00118 int sendLength;
00119
00120 int recvId[20];
00121 int recvOffset[20];
00122 int recvLength[20];
00123 int fanInFrom[20];
00124
00125 int fanInTo;
00126 int nSend;
00127 int nRecv;
00128 int gatherRoot;
00129 int gatherLength;
00130
00131 int *members;
00132 int nmembers;
00133 int myLocalRank;
00134
00135 vtkCommunicator *comm;
00136
00137 vtkSubGroup(const vtkSubGroup&);
00138 void operator=(const vtkSubGroup&);
00139 };
00140 #endif