VTK
vtkMPICommunicator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMPICommunicator.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm 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 =========================================================================*/
38 #ifndef __vtkMPICommunicator_h
39 #define __vtkMPICommunicator_h
40 
41 #include "vtkCommunicator.h"
42 
43 class vtkMPIController;
44 class vtkProcessGroup;
45 
46 class vtkMPICommunicatorOpaqueComm;
47 class vtkMPICommunicatorOpaqueRequest;
48 class vtkMPICommunicatorReceiveDataInfo;
49 
51 {
52 public:
53 //BTX
54 
56  {
57  public:
58  Request();
59  Request( const Request& );
60  ~Request();
61  Request& operator = ( const Request& );
62  int Test();
63  void Cancel();
64  void Wait();
65  vtkMPICommunicatorOpaqueRequest* Req;
66  };
67 
68 //ETX
69 
71  void PrintSelf(ostream& os, vtkIndent indent);
72 
74  static vtkMPICommunicator* New();
75 
78  static vtkMPICommunicator* GetWorldCommunicator();
79 
80 
84  int Initialize(vtkProcessGroup *group);
85 
88  int SplitInitialize(vtkCommunicator *oldcomm, int color, int key);
89 
91 
93  virtual int SendVoidArray(const void *data, vtkIdType length, int type,
94  int remoteProcessId, int tag);
95  virtual int ReceiveVoidArray(void *data, vtkIdType length, int type,
96  int remoteProcessId, int tag);
98 
100 
104  int NoBlockSend(const int* data, int length, int remoteProcessId, int tag,
105  Request& req);
106  int NoBlockSend(const unsigned long* data, int length, int remoteProcessId,
107  int tag, Request& req);
108  int NoBlockSend(const char* data, int length, int remoteProcessId,
109  int tag, Request& req);
110  int NoBlockSend(const float* data, int length, int remoteProcessId,
111  int tag, Request& req);
113 
115 
118  int NoBlockReceive(int* data, int length, int remoteProcessId,
119  int tag, Request& req);
120  int NoBlockReceive(unsigned long* data, int length,
121  int remoteProcessId, int tag, Request& req);
122  int NoBlockReceive(char* data, int length, int remoteProcessId,
123  int tag, Request& req);
124  int NoBlockReceive(float* data, int length, int remoteProcessId,
125  int tag, Request& req);
126 #ifdef VTK_USE_64BIT_IDS
127  int NoBlockReceive(vtkIdType* data, int length, int remoteProcessId,
128  int tag, Request& req);
129 #endif
130 
131 
132 
134 
136  virtual void Barrier();
137  virtual int BroadcastVoidArray(void *data, vtkIdType length, int type,
138  int srcProcessId);
139  virtual int GatherVoidArray(const void *sendBuffer, void *recvBuffer,
140  vtkIdType length, int type, int destProcessId);
141  virtual int GatherVVoidArray(const void *sendBuffer, void *recvBuffer,
142  vtkIdType sendLength, vtkIdType *recvLengths,
143  vtkIdType *offsets, int type, int destProcessId);
144  virtual int ScatterVoidArray(const void *sendBuffer, void *recvBuffer,
145  vtkIdType length, int type, int srcProcessId);
146  virtual int ScatterVVoidArray(const void *sendBuffer, void *recvBuffer,
147  vtkIdType *sendLengths, vtkIdType *offsets,
148  vtkIdType recvLength, int type,
149  int srcProcessId);
150  virtual int AllGatherVoidArray(const void *sendBuffer, void *recvBuffer,
151  vtkIdType length, int type);
152  virtual int AllGatherVVoidArray(const void *sendBuffer, void *recvBuffer,
153  vtkIdType sendLength, vtkIdType *recvLengths,
154  vtkIdType *offsets, int type);
155  virtual int ReduceVoidArray(const void *sendBuffer, void *recvBuffer,
156  vtkIdType length, int type,
157  int operation, int destProcessId);
158  virtual int ReduceVoidArray(const void *sendBuffer, void *recvBuffer,
159  vtkIdType length, int type,
160  Operation *operation, int destProcessId);
161  virtual int AllReduceVoidArray(const void *sendBuffer, void *recvBuffer,
162  vtkIdType length, int type,
163  int operation);
164  virtual int AllReduceVoidArray(const void *sendBuffer, void *recvBuffer,
165  vtkIdType length, int type,
166  Operation *operation);
168 
169 //BTX
170 
171  friend class vtkMPIController;
172 
173  vtkMPICommunicatorOpaqueComm *GetMPIComm()
174  {
175  return this->MPIComm;
176  }
177 //ETX
178 
179  static char* Allocate(size_t size);
180  static void Free(char* ptr);
181 
182 
184 
186  vtkSetClampMacro(UseSsend, int, 0, 1);
187  vtkGetMacro(UseSsend, int);
188  vtkBooleanMacro(UseSsend, int);
190 
192 
196  void CopyFrom(vtkMPICommunicator* source);
197 protected:
201 
202  // Obtain size and rank setting NumberOfProcesses and LocalProcessId Should
203  // not be called if the current communicator does not include this process
204  int InitializeNumberOfProcesses();
205 
207 
214  vtkSetMacro(KeepHandle, int);
215  vtkBooleanMacro(KeepHandle, int);
217 
218 
220 
221  void InitializeCopy(vtkMPICommunicator* source);
222 
229  void Duplicate(vtkMPICommunicator* source);
230 
232 
233  virtual int ReceiveDataInternal(
234  char* data, int length, int sizeoftype,
235  int remoteProcessId, int tag,
236  vtkMPICommunicatorReceiveDataInfo* info,
237  int useCopy, int& senderId);
239 
240  vtkMPICommunicatorOpaqueComm* MPIComm;
241 
244 
246  int UseSsend;
247  static int CheckForMPIError(int err);
248 
249 private:
250  vtkMPICommunicator(const vtkMPICommunicator&); // Not implemented.
251  void operator=(const vtkMPICommunicator&); // Not implemented.
252 };
253 
254 #endif
vtkMPICommunicatorOpaqueRequest * Req
static vtkMPICommunicator * WorldCommunicator
Class for creating user defined MPI communicators.
int vtkIdType
Definition: vtkType.h:255
vtkMPICommunicatorOpaqueComm * MPIComm
a simple class to control print indentation
Definition: vtkIndent.h:37
A subgroup of processes from a communicator.
Process communication using MPI.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
#define VTK_PARALLEL_EXPORT
Used to send/receive messages in a multiprocess environment.
vtkMPICommunicatorOpaqueComm * GetMPIComm()