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
134 
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
160 
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
vtkMPICommunicator::Barrier
virtual void Barrier()
More efficient implementations of collective operations that use the equivalent MPI commands.
vtkMPICommunicator::CheckForMPIError
static int CheckForMPIError(int err)
vtkMPICommunicator::TestAll
int TestAll(const int count, Request requests[], int &flag)
Checks if the given communication request objects are complete.
vtkMPICommunicator::vtkMPICommunicator
vtkMPICommunicator()
vtkMPICommunicator::Duplicate
void Duplicate(vtkMPICommunicator *source)
Copies all the attributes of source, deleting previously stored data EXCEPT the MPI communicator hand...
vtkMPICommunicator::Request
Definition: vtkMPICommunicator.h:57
vtkMPICommunicator::WaitSome
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.
vtkMPICommunicator::NoBlockReceive
int NoBlockReceive(unsigned char *data, int length, int remoteProcessId, int tag, Request &req)
vtkMPICommunicator::NoBlockReceive
int NoBlockReceive(float *data, int length, int remoteProcessId, int tag, Request &req)
vtkMPICommunicator::~vtkMPICommunicator
~vtkMPICommunicator()
vtkMPICommunicator::Initialized
int Initialized
Definition: vtkMPICommunicator.h:349
vtkX3D::type
@ type
Definition: vtkX3D.h:516
vtkCommunicator
Used to send/receive messages in a multiprocess environment.
Definition: vtkCommunicator.h:54
vtkIdType
int vtkIdType
Definition: vtkType.h:287
vtkMPICommunicator::UseSsend
int UseSsend
Definition: vtkMPICommunicator.h:353
vtkMPICommunicator::Initialize
int Initialize(vtkProcessGroup *group)
Used to initialize the communicator (i.e.
vtkX3D::data
@ data
Definition: vtkX3D.h:315
vtkMPICommunicator::NoBlockSend
int NoBlockSend(const unsigned char *data, int length, int remoteProcessId, int tag, Request &req)
vtkCommunicator::Operation
A custom operation to use in a reduce command.
Definition: vtkCommunicator.h:108
vtkX3D::key
@ key
Definition: vtkX3D.h:257
vtkMPICommunicator::ScatterVoidArray
virtual int ScatterVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type, int srcProcessId)
vtkMPICommunicator::Request::Request
Request()
vtkMPICommunicator::AllReduceVoidArray
virtual int AllReduceVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type, Operation *operation)
vtkMPICommunicator::Request::Cancel
void Cancel()
vtkX3D::length
@ length
Definition: vtkX3D.h:393
vtkMPICommunicator::Request::Test
int Test()
vtkMPICommunicator::NoBlockSend
int NoBlockSend(const float *data, int length, int remoteProcessId, int tag, Request &req)
vtkMPICommunicator::GatherVoidArray
virtual int GatherVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type, int destProcessId)
vtkMPICommunicator::NoBlockReceive
int NoBlockReceive(char *data, int length, int remoteProcessId, int tag, Request &req)
vtkMPICommunicator::LastSenderId
int LastSenderId
Definition: vtkMPICommunicator.h:352
vtkMPICommunicator::BroadcastVoidArray
virtual int BroadcastVoidArray(void *data, vtkIdType length, int type, int srcProcessId)
Subclasses should reimplement these if they have a more efficient implementation.
vtkMPICommunicator
Class for creating user defined MPI communicators.
Definition: vtkMPICommunicator.h:53
vtkMPICommunicator::Allocate
static char * Allocate(size_t size)
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:822
vtkMPICommunicator::New
static vtkMPICommunicator * New()
Creates an empty communicator.
vtkMPICommunicator::WaitAny
int WaitAny(const int count, Request requests[], int &idx)
Blocks until one of the specified requests in the given request array completes.
vtkMPICommunicator::ReduceVoidArray
virtual int ReduceVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type, int operation, int destProcessId)
vtkX3D::color
@ color
Definition: vtkX3D.h:221
vtkMPICommunicator::NoBlockReceive
int NoBlockReceive(unsigned long *data, int length, int remoteProcessId, int tag, Request &req)
vtkMPICommunicator::Request::Request
Request(const Request &)
vtkMPICommunicator::SendVoidArray
virtual int SendVoidArray(const void *data, vtkIdType length, int type, int remoteProcessId, int tag)
Performs the actual communication.
vtkMPICommunicator::WaitAll
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...
vtkMPICommunicator::InitializeNumberOfProcesses
int InitializeNumberOfProcesses()
vtkMPICommunicator::Iprobe
int Iprobe(int source, int tag, int *flag, int *actualSource, float *type, int *size)
vtkMPICommunicator::InitializeCopy
void InitializeCopy(vtkMPICommunicator *source)
vtkMPICommunicator::AllGatherVVoidArray
virtual int AllGatherVVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType sendLength, vtkIdType *recvLengths, vtkIdType *offsets, int type)
vtkMPICommunicator::WorldCommunicator
static vtkMPICommunicator * WorldCommunicator
Definition: vtkMPICommunicator.h:319
vtkMPICommunicator::Iprobe
int Iprobe(int source, int tag, int *flag, int *actualSource)
Nonblocking test for a message.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkMPICommunicator::TestSome
int TestSome(const int count, Request requests[], int &NCompleted, int *completed)
Checks the status of all the given request communication object handles.
vtkMPICommunicator::AllReduceVoidArray
virtual int AllReduceVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type, int operation)
vtkX3D::size
@ size
Definition: vtkX3D.h:253
vtkMPICommunicator::Iprobe
int Iprobe(int source, int tag, int *flag, int *actualSource, unsigned long *type, int *size)
vtkMPICommunicator::Iprobe
int Iprobe(int source, int tag, int *flag, int *actualSource, int *type, int *size)
vtkMPICommunicator::NoBlockSend
int NoBlockSend(const int *data, int length, int remoteProcessId, int tag, Request &req)
This method sends data to another process (non-blocking).
vtkMPICommunicator::GetWorldCommunicator
static vtkMPICommunicator * GetWorldCommunicator()
Returns the singleton which behaves as the global communicator (MPI_COMM_WORLD)
vtkMPICommunicator::Request::Wait
void Wait()
vtkMPICommunicator::ReceiveDataInternal
virtual int ReceiveDataInternal(char *data, int length, int sizeoftype, int remoteProcessId, int tag, vtkMPICommunicatorReceiveDataInfo *info, int useCopy, int &senderId)
Implementation for receive data.
vtkMPICommunicator::NoBlockReceive
int NoBlockReceive(int *data, int length, int remoteProcessId, int tag, Request &req)
This method receives data from a corresponding send (non-blocking).
vtkMPICommunicator::ReduceVoidArray
virtual int ReduceVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type, Operation *operation, int destProcessId)
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkMPICommunicator::CopyFrom
void CopyFrom(vtkMPICommunicator *source)
Copies all the attributes of source, deleting previously stored data.
vtkMPICommunicator::NoBlockReceive
int NoBlockReceive(double *data, int length, int remoteProcessId, int tag, Request &req)
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkX3D::info
@ info
Definition: vtkX3D.h:376
vtkMPICommunicator::Free
static void Free(char *ptr)
vtkMPICommunicator::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkProcessGroup
A subgroup of processes from a communicator.
Definition: vtkProcessGroup.h:58
vtkMPICommunicator::TestAny
int TestAny(const int count, Request requests[], int &idx, int &flag)
Check if at least one of the specified requests has completed.
vtkMPICommunicator::InitializeExternal
int InitializeExternal(vtkMPICommunicatorOpaqueComm *comm)
vtkCommunicator.h
vtkMPICommunicator::Iprobe
int Iprobe(int source, int tag, int *flag, int *actualSource, double *type, int *size)
vtkMPICommunicator::KeepHandle
int KeepHandle
Definition: vtkMPICommunicator.h:350
vtkMPICommunicator::GatherVVoidArray
virtual int GatherVVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType sendLength, vtkIdType *recvLengths, vtkIdType *offsets, int type, int destProcessId)
vtkMPICommunicator::MPIComm
vtkMPICommunicatorOpaqueComm * MPIComm
Definition: vtkMPICommunicator.h:347
vtkMPICommunicator::GetMPIComm
vtkMPICommunicatorOpaqueComm * GetMPIComm()
Definition: vtkMPICommunicator.h:269
vtkMPICommunicator::AllGatherVoidArray
virtual int AllGatherVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type)
vtkMPICommunicator::ScatterVVoidArray
virtual int ScatterVVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType *sendLengths, vtkIdType *offsets, vtkIdType recvLength, int type, int srcProcessId)
vtkMPICommunicator::NoBlockSend
int NoBlockSend(const unsigned long *data, int length, int remoteProcessId, int tag, Request &req)
vtkMPIController
Process communication using MPI.
Definition: vtkMPIController.h:62
vtkMPICommunicator::ReceiveVoidArray
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.
vtkMPICommunicator::Request::Req
vtkMPICommunicatorOpaqueRequest * Req
Definition: vtkMPICommunicator.h:66
vtkMPICommunicator::Iprobe
int Iprobe(int source, int tag, int *flag, int *actualSource, const char *type, int *size)
vtkMPICommunicator::NoBlockSend
int NoBlockSend(const double *data, int length, int remoteProcessId, int tag, Request &req)
vtkMPICommunicator::SplitInitialize
int SplitInitialize(vtkCommunicator *oldcomm, int color, int key)
Used to initialize the communicator (i.e.
vtkMPICommunicator::Request::~Request
~Request()
vtkMPICommunicator::NoBlockSend
int NoBlockSend(const char *data, int length, int remoteProcessId, int tag, Request &req)