VTK  9.3.1
vtkSubGroup.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright (c) Kitware, Inc.
3 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
4 // SPDX-License-Identifier: BSD-3-Clause
27 #ifndef vtkSubGroup_h
28 #define vtkSubGroup_h
29 
30 #include "vtkObject.h"
31 #include "vtkParallelCoreModule.h" // For export macro
32 
33 VTK_ABI_NAMESPACE_BEGIN
35 class vtkCommunicator;
36 
37 class VTKPARALLELCORE_EXPORT vtkSubGroup : public vtkObject
38 {
39 public:
40  vtkTypeMacro(vtkSubGroup, vtkObject);
41  void PrintSelf(ostream& os, vtkIndent indent) override;
42  static vtkSubGroup* New();
43 
44  // The wrapper gets confused here and falls down.
45  enum
46  {
47  MINOP = 1,
48  MAXOP = 2,
49  SUMOP = 3
50  };
51 
61  int Initialize(int p0, int p1, int me, int tag, vtkCommunicator* c);
62 
63  int Gather(int* data, int* to, int length, int root);
64  int Gather(char* data, char* to, int length, int root);
65  int Gather(float* data, float* to, int length, int root);
66 #ifdef VTK_USE_64BIT_IDS
67  int Gather(vtkIdType* data, vtkIdType* to, int length, int root);
68 #endif
69  int Broadcast(float* data, int length, int root);
70  int Broadcast(double* data, int length, int root);
71  int Broadcast(int* data, int length, int root);
72  int Broadcast(char* data, int length, int root);
73 #ifdef VTK_USE_64BIT_IDS
74  int Broadcast(vtkIdType* data, int length, int root);
75 #endif
76  int ReduceSum(int* data, int* to, int length, int root);
77  int ReduceMax(float* data, float* to, int length, int root);
78  int ReduceMax(double* data, double* to, int length, int root);
79  int ReduceMax(int* data, int* to, int length, int root);
80  int ReduceMin(float* data, float* to, int length, int root);
81  int ReduceMin(double* data, double* to, int length, int root);
82  int ReduceMin(int* data, int* to, int length, int root);
83 
84  int AllReduceUniqueList(int* list, int len, int** newList);
85  int MergeSortedUnique(int* list1, int len1, int* list2, int len2, int** newList);
86 
87  void setGatherPattern(int root, int length);
88  int getLocalRank(int processID);
89 
90  int Barrier();
91 
92  void PrintSubGroup() const;
93 
94  static int MakeSortedUnique(int* list, int len, int** newList);
95 
96  int tag;
97 
98 protected:
99  vtkSubGroup();
100  ~vtkSubGroup() override;
101 
102 private:
103  int computeFanInTargets();
104  void restoreRoot(int rootLoc);
105  void moveRoot(int rootLoc);
106  void setUpRoot(int root);
107 
108  int nFrom;
109  int nTo;
110 
111  int sendId; // gather
112  int sendOffset;
113  int sendLength;
114 
115  int recvId[20];
116  int recvOffset[20];
117  int recvLength[20];
118  int fanInFrom[20]; // reduce, broadcast
119 
120  int fanInTo;
121  int nSend;
122  int nRecv;
123  int gatherRoot;
124  int gatherLength;
125 
126  int* members;
127  int nmembers;
128  int myLocalRank;
129 
130  vtkCommunicator* comm;
131 
132  vtkSubGroup(const vtkSubGroup&) = delete;
133  void operator=(const vtkSubGroup&) = delete;
134 };
135 VTK_ABI_NAMESPACE_END
136 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:51
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int vtkIdType
Definition: vtkType.h:315
a simple class to control print indentation
Definition: vtkIndent.h:28
scalable collective communication for a subset of members of a parallel VTK application ...
Definition: vtkSubGroup.h:37
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
Used to send/receive messages in a multiprocess environment.
Multiprocessing communication superclass.