VTK
vtkSubGroup.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkSubGroup.h
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*----------------------------------------------------------------------------
16  Copyright (c) Sandia Corporation
17  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
18 ----------------------------------------------------------------------------*/
19 
41 #ifndef __vtkSubGroup_h
42 #define __vtkSubGroup_h
43 
44 #include "vtkObject.h"
45 
47 class vtkCommunicator;
48 
50 {
51 public:
52  vtkTypeMacro(vtkSubGroup, vtkObject);
53  virtual void PrintSelf(ostream &os, vtkIndent indent);
54  static vtkSubGroup *New();
55 
56 //BTX
57  // The wrapper gets confused here and falls down.
58  enum {MINOP = 1, MAXOP = 2, SUMOP = 3};
59 //ETX
66  int Initialize(int p0, int p1, int me, int tag, vtkCommunicator *c);
67 
68  int Gather(int *data, int *to, int length, int root);
69  int Gather(char *data, char *to, int length, int root);
70  int Gather(float *data, float *to, int length, int root);
71 #ifdef VTK_USE_64BIT_IDS
72  int Gather(vtkIdType *data, vtkIdType *to, int length, int root);
73 #endif
74  int Broadcast(float *data, int length, int root);
75  int Broadcast(double *data, int length, int root);
76  int Broadcast(int *data, int length, int root);
77  int Broadcast(char *data, int length, int root);
78 #ifdef VTK_USE_64BIT_IDS
79  int Broadcast(vtkIdType *data, int length, int root);
80 #endif
81  int ReduceSum(int *data, int *to, int length, int root);
82  int ReduceMax(float *data, float *to, int length, int root);
83  int ReduceMax(double *data, double *to, int length, int root);
84  int ReduceMax(int *data, int *to, int length, int root);
85  int ReduceMin(float *data, float *to, int length, int root);
86  int ReduceMin(double *data, double *to, int length, int root);
87  int ReduceMin(int *data, int *to, int length, int root);
88 
89  int AllReduceUniqueList(int *list, int len, int **newList);
90  int MergeSortedUnique(int *list1, int len1, int *list2, int len2, int **newList);
91 
92  void setGatherPattern(int root, int length);
93  int getLocalRank(int processID);
94 
95  int Barrier();
96 
97  void PrintSubGroup() const;
98 
99  static int MakeSortedUnique(int *list, int len, int **newList);
100 
101  int tag;
102 
103 protected:
104  vtkSubGroup();
105  ~vtkSubGroup();
106 
107 private:
108  int computeFanInTargets();
109  void restoreRoot(int rootLoc);
110  void moveRoot(int rootLoc);
111  void setUpRoot(int root);
112 
113  int nFrom;
114  int nTo;
115 
116  int sendId; // gather
117  int sendOffset;
118  int sendLength;
119 
120  int recvId[20];
121  int recvOffset[20];
122  int recvLength[20];
123  int fanInFrom[20]; // reduce, broadcast
124 
125  int fanInTo;
126  int nSend;
127  int nRecv;
128  int gatherRoot;
129  int gatherLength;
130 
131  int *members;
132  int nmembers;
133  int myLocalRank;
134 
135  vtkCommunicator *comm;
136 
137  vtkSubGroup(const vtkSubGroup&); // Not implemented
138  void operator=(const vtkSubGroup&); // Not implemented
139 };
140 #endif