VTK
dox/Parallel/Core/vtkSubGroup.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   ParaView
00004   Module:    vtkSubGroup.h
00005 
00006   Copyright (c) Kitware, Inc.
00007   All rights reserved.
00008   See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 /*----------------------------------------------------------------------------
00016  Copyright (c) Sandia Corporation
00017  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
00018 ----------------------------------------------------------------------------*/
00019 
00041 #ifndef __vtkSubGroup_h
00042 #define __vtkSubGroup_h
00043 
00044 #include "vtkParallelCoreModule.h" // For export macro
00045 #include "vtkObject.h"
00046 
00047 class vtkMultiProcessController;
00048 class vtkCommunicator;
00049 
00050 class VTKPARALLELCORE_EXPORT vtkSubGroup : public vtkObject
00051 {
00052 public:
00053   vtkTypeMacro(vtkSubGroup, vtkObject);
00054   virtual void PrintSelf(ostream &os, vtkIndent indent);
00055   static vtkSubGroup *New();
00056 
00057 //BTX
00058   // The wrapper gets confused here and falls down.
00059   enum {MINOP = 1, MAXOP = 2, SUMOP = 3};
00060 //ETX
00067   int Initialize(int p0, int p1, int me, int tag, vtkCommunicator *c);
00068 
00069   int Gather(int *data, int *to, int length, int root);
00070   int Gather(char *data, char *to, int length, int root);
00071   int Gather(float *data, float *to, int length, int root);
00072 #ifdef VTK_USE_64BIT_IDS
00073   int Gather(vtkIdType *data, vtkIdType *to, int length, int root);
00074 #endif
00075   int Broadcast(float *data, int length, int root);
00076   int Broadcast(double *data, int length, int root);
00077   int Broadcast(int *data, int length, int root);
00078   int Broadcast(char *data, int length, int root);
00079 #ifdef VTK_USE_64BIT_IDS
00080   int Broadcast(vtkIdType *data, int length, int root);
00081 #endif
00082   int ReduceSum(int *data, int *to, int length, int root);
00083   int ReduceMax(float *data, float *to, int length, int root);
00084   int ReduceMax(double *data, double *to, int length, int root);
00085   int ReduceMax(int *data, int *to, int length, int root);
00086   int ReduceMin(float *data, float *to, int length, int root);
00087   int ReduceMin(double *data, double *to, int length, int root);
00088   int ReduceMin(int *data, int *to, int length, int root);
00089 
00090   int AllReduceUniqueList(int *list, int len, int **newList);
00091   int MergeSortedUnique(int *list1, int len1, int *list2, int len2, int **newList);
00092 
00093   void setGatherPattern(int root, int length);
00094   int getLocalRank(int processID);
00095 
00096   int Barrier();
00097 
00098   void PrintSubGroup() const;
00099 
00100   static int MakeSortedUnique(int *list, int len, int **newList);
00101 
00102   int tag;
00103 
00104 protected:
00105   vtkSubGroup();
00106   ~vtkSubGroup();
00107 
00108 private:
00109   int computeFanInTargets();
00110   void restoreRoot(int rootLoc);
00111   void moveRoot(int rootLoc);
00112   void setUpRoot(int root);
00113 
00114   int nFrom;
00115   int nTo;
00116 
00117   int sendId;                // gather
00118   int sendOffset;
00119   int sendLength;
00120 
00121   int recvId[20];
00122   int recvOffset[20];
00123   int recvLength[20];
00124   int fanInFrom[20];         // reduce, broadcast
00125 
00126   int fanInTo;
00127   int nSend;
00128   int nRecv;
00129   int gatherRoot;
00130   int gatherLength;
00131 
00132   int *members;
00133   int nmembers;
00134   int myLocalRank;
00135 
00136   vtkCommunicator *comm;
00137 
00138   vtkSubGroup(const vtkSubGroup&); // Not implemented
00139   void operator=(const vtkSubGroup&); // Not implemented
00140 };
00141 #endif