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 =========================================================================*/
39 #ifndef vtkMPICommunicator_h
40 #define vtkMPICommunicator_h
41 
42 #include "vtkParallelMPIModule.h" // For export macro
43 #include "vtkCommunicator.h"
44 
45 class vtkMPIController;
46 class vtkProcessGroup;
47 
48 class vtkMPICommunicatorOpaqueComm;
49 class vtkMPICommunicatorOpaqueRequest;
50 class vtkMPICommunicatorReceiveDataInfo;
51 
52 class VTKPARALLELMPI_EXPORT vtkMPICommunicator : public vtkCommunicator
53 {
54 public:
55 
56  class VTKPARALLELMPI_EXPORT Request
57  {
58  public:
60  Request( const Request& );
62  Request& operator = ( const Request& );
63  int Test();
64  void Cancel();
65  void Wait();
66  vtkMPICommunicatorOpaqueRequest* Req;
67  };
68 
70  void PrintSelf(ostream& os, vtkIndent indent);
71 
76 
82 
83 
89 
95  int SplitInitialize(vtkCommunicator *oldcomm, int color, int key);
96 
98 
103  virtual int SendVoidArray(const void *data, vtkIdType length, int type,
104  int remoteProcessId, int tag);
105  virtual int ReceiveVoidArray(void *data, vtkIdType length, int type,
106  int remoteProcessId, int tag);
108 
110 
118  int NoBlockSend(const int* data, int length, int remoteProcessId, int tag,
119  Request& req);
120  int NoBlockSend(const unsigned long* data, int length, int remoteProcessId,
121  int tag, Request& req);
122  int NoBlockSend(const char* data, int length, int remoteProcessId,
123  int tag, Request& req);
124  int NoBlockSend(const unsigned char* data, int length, int remoteProcessId,
125  int tag, Request& req);
126  int NoBlockSend(const float* data, int length, int remoteProcessId,
127  int tag, Request& req);
128  int NoBlockSend(const double* data, int length, int remoteProcessId,
129  int tag, Request& req);
130 #ifdef VTK_USE_64BIT_IDS
131  int NoBlockSend(const vtkIdType* data, int length, int remoteProcessId,
132  int tag, Request& req);
133 #endif
135 
137 
144  int NoBlockReceive(int* data, int length, int remoteProcessId,
145  int tag, Request& req);
146  int NoBlockReceive(unsigned long* data, int length,
147  int remoteProcessId, int tag, Request& req);
148  int NoBlockReceive(char* data, int length, int remoteProcessId,
149  int tag, Request& req);
150  int NoBlockReceive(unsigned char* data, int length, int remoteProcessId,
151  int tag, Request& req);
152  int NoBlockReceive(float* data, int length, int remoteProcessId,
153  int tag, Request& req);
154  int NoBlockReceive(double* data, int length, int remoteProcessId,
155  int tag, Request& req);
156 #ifdef VTK_USE_64BIT_IDS
157  int NoBlockReceive(vtkIdType* data, int length, int remoteProcessId,
158  int tag, Request& req);
159 #endif
161 
162 
164 
169  virtual void Barrier();
170  virtual int BroadcastVoidArray(void *data, vtkIdType length, int type,
171  int srcProcessId);
172  virtual int GatherVoidArray(const void *sendBuffer, void *recvBuffer,
173  vtkIdType length, int type, int destProcessId);
174  virtual int GatherVVoidArray(const void *sendBuffer, void *recvBuffer,
175  vtkIdType sendLength, vtkIdType *recvLengths,
176  vtkIdType *offsets, int type, int destProcessId);
177  virtual int ScatterVoidArray(const void *sendBuffer, void *recvBuffer,
178  vtkIdType length, int type, int srcProcessId);
179  virtual int ScatterVVoidArray(const void *sendBuffer, void *recvBuffer,
180  vtkIdType *sendLengths, vtkIdType *offsets,
181  vtkIdType recvLength, int type,
182  int srcProcessId);
183  virtual int AllGatherVoidArray(const void *sendBuffer, void *recvBuffer,
184  vtkIdType length, int type);
185  virtual int AllGatherVVoidArray(const void *sendBuffer, void *recvBuffer,
186  vtkIdType sendLength, vtkIdType *recvLengths,
187  vtkIdType *offsets, int type);
188  virtual int ReduceVoidArray(const void *sendBuffer, void *recvBuffer,
189  vtkIdType length, int type,
190  int operation, int destProcessId);
191  virtual int ReduceVoidArray(const void *sendBuffer, void *recvBuffer,
192  vtkIdType length, int type,
193  Operation *operation, int destProcessId);
194  virtual int AllReduceVoidArray(const void *sendBuffer, void *recvBuffer,
195  vtkIdType length, int type,
196  int operation);
197  virtual int AllReduceVoidArray(const void *sendBuffer, void *recvBuffer,
198  vtkIdType length, int type,
199  Operation *operation);
201 
203 
212  int Iprobe(int source, int tag, int* flag, int* actualSource);
213  int Iprobe(int source, int tag, int* flag, int* actualSource,
214  int* type, int* size);
215  int Iprobe(int source, int tag, int* flag, int* actualSource,
216  unsigned long* type, int* size);
217  int Iprobe(int source, int tag, int* flag, int* actualSource,
218  const char* type, int* size);
219  int Iprobe(int source, int tag, int* flag, int* actualSource,
220  float* type, int* size);
221  int Iprobe(int source, int tag, int* flag, int* actualSource,
222  double* type, int* size);
224 
229  int WaitAll(const int count, Request requests[]);
230 
236  int WaitAny(const int count, Request requests[], int& idx);
237 
243  int WaitSome(
244  const int count, Request requests[], int &NCompleted, int *completed );
245 
251  int TestAll( const int count, Request requests[], int& flag );
252 
256  int TestAny(const int count, Request requests[], int &idx, int &flag );
257 
264  int TestSome(const int count,Request requests[],
265  int& NCompleted,int *completed);
266 
267  friend class vtkMPIController;
268 
269  vtkMPICommunicatorOpaqueComm *GetMPIComm()
270  {
271  return this->MPIComm;
272  }
273 
274  int InitializeExternal(vtkMPICommunicatorOpaqueComm *comm);
275 
276  static char* Allocate(size_t size);
277  static void Free(char* ptr);
278 
279 
281 
285  vtkSetClampMacro(UseSsend, int, 0, 1);
286  vtkGetMacro(UseSsend, int);
287  vtkBooleanMacro(UseSsend, int);
289 
298 
299 protected:
302 
303  // Obtain size and rank setting NumberOfProcesses and LocalProcessId Should
304  // not be called if the current communicator does not include this process
306 
308 
318  vtkSetMacro(KeepHandle, int);
319  vtkBooleanMacro(KeepHandle, int);
321 
322 
324 
326 
337 
341  virtual int ReceiveDataInternal(
342  char* data, int length, int sizeoftype,
343  int remoteProcessId, int tag,
344  vtkMPICommunicatorReceiveDataInfo* info,
345  int useCopy, int& senderId);
346 
347  vtkMPICommunicatorOpaqueComm* MPIComm;
348 
351 
353  int UseSsend;
354  static int CheckForMPIError(int err);
355 
356 private:
357  vtkMPICommunicator(const vtkMPICommunicator&) VTK_DELETE_FUNCTION;
358  void operator=(const vtkMPICommunicator&) VTK_DELETE_FUNCTION;
359 };
360 
361 #endif
A custom operation to use in a reduce command.
Used to send/receive messages in a multiprocess environment.
a simple class to control print indentation
Definition: vtkIndent.h:40
Request(const Request &)
vtkMPICommunicatorOpaqueRequest * Req
Class for creating user defined MPI communicators.
virtual int ReceiveVoidArray(void *data, vtkIdType length, int type, int remoteProcessId, int tag)
Subclasses have to supply this method to receive various arrays of data.
virtual int ScatterVVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType *sendLengths, vtkIdType *offsets, vtkIdType recvLength, int type, int srcProcessId)
int NoBlockReceive(double *data, int length, int remoteProcessId, int tag, Request &req)
virtual int AllReduceVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type, Operation *operation)
int NoBlockReceive(unsigned char *data, int length, int remoteProcessId, int tag, Request &req)
void InitializeCopy(vtkMPICommunicator *source)
static vtkMPICommunicator * WorldCommunicator
int InitializeNumberOfProcesses()
virtual int GatherVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type, int destProcessId)
int SplitInitialize(vtkCommunicator *oldcomm, int color, int key)
Used to initialize the communicator (i.e.
int InitializeExternal(vtkMPICommunicatorOpaqueComm *comm)
int Initialize(vtkProcessGroup *group)
Used to initialize the communicator (i.e.
virtual int ReceiveDataInternal(char *data, int length, int sizeoftype, int remoteProcessId, int tag, vtkMPICommunicatorReceiveDataInfo *info, int useCopy, int &senderId)
Implementation for receive data.
int NoBlockSend(const unsigned char *data, int length, int remoteProcessId, int tag, Request &req)
virtual int ReduceVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type, Operation *operation, int destProcessId)
static vtkMPICommunicator * GetWorldCommunicator()
Returns the singleton which behaves as the global communicator (MPI_COMM_WORLD)
int NoBlockSend(const char *data, int length, int remoteProcessId, int tag, Request &req)
int TestAny(const int count, Request requests[], int &idx, int &flag)
Check if at least one of the specified requests has completed.
virtual int AllReduceVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type, int operation)
int NoBlockReceive(int *data, int length, int remoteProcessId, int tag, Request &req)
This method receives data from a corresponding send (non-blocking).
int NoBlockSend(const float *data, int length, int remoteProcessId, int tag, Request &req)
vtkMPICommunicatorOpaqueComm * MPIComm
virtual void Barrier()
More efficient implementations of collective operations that use the equivalent MPI commands.
virtual int GatherVVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType sendLength, vtkIdType *recvLengths, vtkIdType *offsets, int type, int destProcessId)
virtual int AllGatherVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type)
int NoBlockSend(const int *data, int length, int remoteProcessId, int tag, Request &req)
This method sends data to another process (non-blocking).
int Iprobe(int source, int tag, int *flag, int *actualSource)
Nonblocking test for a message.
static void Free(char *ptr)
virtual int BroadcastVoidArray(void *data, vtkIdType length, int type, int srcProcessId)
Subclasses should reimplement these if they have a more efficient implementation.
int NoBlockReceive(unsigned long *data, int length, int remoteProcessId, int tag, Request &req)
int TestAll(const int count, Request requests[], int &flag)
Checks if the given communication request objects are complete.
int Iprobe(int source, int tag, int *flag, int *actualSource, int *type, int *size)
int WaitSome(const int count, Request requests[], int &NCompleted, int *completed)
Blocks until one or more of the specified requests in the given request request array completes.
virtual int ReduceVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type, int operation, int destProcessId)
vtkMPICommunicatorOpaqueComm * GetMPIComm()
int WaitAll(const int count, Request requests[])
Given the request objects of a set of non-blocking operations (send and/or receive) this method block...
void CopyFrom(vtkMPICommunicator *source)
Copies all the attributes of source, deleting previously stored data.
virtual int AllGatherVVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType sendLength, vtkIdType *recvLengths, vtkIdType *offsets, int type)
int TestSome(const int count, Request requests[], int &NCompleted, int *completed)
Checks the status of all the given request communication object handles.
int WaitAny(const int count, Request requests[], int &idx)
Blocks until one of the specified requests in the given request array completes.
int Iprobe(int source, int tag, int *flag, int *actualSource, unsigned long *type, int *size)
virtual int SendVoidArray(const void *data, vtkIdType length, int type, int remoteProcessId, int tag)
Performs the actual communication.
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
int NoBlockSend(const unsigned long *data, int length, int remoteProcessId, int tag, Request &req)
int NoBlockSend(const double *data, int length, int remoteProcessId, int tag, Request &req)
static char * Allocate(size_t size)
virtual int ScatterVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type, int srcProcessId)
int NoBlockReceive(char *data, int length, int remoteProcessId, int tag, Request &req)
int Iprobe(int source, int tag, int *flag, int *actualSource, float *type, int *size)
static int CheckForMPIError(int err)
static vtkMPICommunicator * New()
Creates an empty communicator.
void Duplicate(vtkMPICommunicator *source)
Copies all the attributes of source, deleting previously stored data EXCEPT the MPI communicator hand...
int NoBlockReceive(float *data, int length, int remoteProcessId, int tag, Request &req)
int Iprobe(int source, int tag, int *flag, int *actualSource, const char *type, int *size)
int Iprobe(int source, int tag, int *flag, int *actualSource, double *type, int *size)
Process communication using MPI.
A subgroup of processes from a communicator.
@ key
Definition: vtkX3D.h:257
@ info
Definition: vtkX3D.h:376
@ length
Definition: vtkX3D.h:393
@ type
Definition: vtkX3D.h:516
@ color
Definition: vtkX3D.h:221
@ size
Definition: vtkX3D.h:253
@ data
Definition: vtkX3D.h:315
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
int vtkIdType
Definition: vtkType.h:287