VTK  9.0.20210418
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 =========================================================================*/
36 #ifndef vtkMPICommunicator_h
37 #define vtkMPICommunicator_h
38 
39 #include "vtkCommunicator.h"
40 #include "vtkParallelMPIModule.h" // For export macro
41 
42 class vtkMPIController;
43 class vtkProcessGroup;
44 
45 class vtkMPICommunicatorOpaqueComm;
46 class vtkMPICommunicatorOpaqueRequest;
47 class vtkMPICommunicatorReceiveDataInfo;
48 
49 class VTKPARALLELMPI_EXPORT vtkMPICommunicator : public vtkCommunicator
50 {
51 public:
52  class VTKPARALLELMPI_EXPORT Request
53  {
54  public:
56  Request(const Request&);
59  int Test();
60  void Cancel();
61  void Wait();
62  vtkMPICommunicatorOpaqueRequest* Req;
63  };
64 
66  void PrintSelf(ostream& os, vtkIndent indent) override;
67 
72 
78 
84 
90  int SplitInitialize(vtkCommunicator* oldcomm, int color, int key);
91 
93 
99  const void* data, vtkIdType length, int type, int remoteProcessId, int tag) override;
101  void* data, vtkIdType length, int type, int remoteProcessId, int tag) override;
103 
105 
113  int NoBlockSend(const int* data, int length, int remoteProcessId, int tag, Request& req);
115  const unsigned long* data, int length, int remoteProcessId, int tag, Request& req);
116  int NoBlockSend(const char* data, int length, int remoteProcessId, int tag, Request& req);
118  const unsigned char* data, int length, int remoteProcessId, int tag, Request& req);
119  int NoBlockSend(const float* data, int length, int remoteProcessId, int tag, Request& req);
120  int NoBlockSend(const double* data, int length, int remoteProcessId, int tag, Request& req);
121 #ifdef VTK_USE_64BIT_IDS
122  int NoBlockSend(const vtkIdType* data, int length, int remoteProcessId, int tag, Request& req);
123 #endif
124 
127 
134  int NoBlockReceive(int* data, int length, int remoteProcessId, int tag, Request& req);
135  int NoBlockReceive(unsigned long* data, int length, int remoteProcessId, int tag, Request& req);
136  int NoBlockReceive(char* data, int length, int remoteProcessId, int tag, Request& req);
137  int NoBlockReceive(unsigned char* data, int length, int remoteProcessId, int tag, Request& req);
138  int NoBlockReceive(float* data, int length, int remoteProcessId, int tag, Request& req);
139  int NoBlockReceive(double* data, int length, int remoteProcessId, int tag, Request& req);
140 #ifdef VTK_USE_64BIT_IDS
141  int NoBlockReceive(vtkIdType* data, int length, int remoteProcessId, int tag, Request& req);
142 #endif
143 
146 
151  void Barrier() override;
152  int BroadcastVoidArray(void* data, vtkIdType length, int type, int srcProcessId) override;
153  int GatherVoidArray(const void* sendBuffer, void* recvBuffer, vtkIdType length, int type,
154  int destProcessId) override;
155  int GatherVVoidArray(const void* sendBuffer, void* recvBuffer, vtkIdType sendLength,
156  vtkIdType* recvLengths, vtkIdType* offsets, int type, int destProcessId) override;
157  int ScatterVoidArray(const void* sendBuffer, void* recvBuffer, vtkIdType length, int type,
158  int srcProcessId) override;
159  int ScatterVVoidArray(const void* sendBuffer, void* recvBuffer, vtkIdType* sendLengths,
160  vtkIdType* offsets, vtkIdType recvLength, int type, int srcProcessId) override;
162  const void* sendBuffer, void* recvBuffer, vtkIdType length, int type) override;
163  int AllGatherVVoidArray(const void* sendBuffer, void* recvBuffer, vtkIdType sendLength,
164  vtkIdType* recvLengths, vtkIdType* offsets, int type) override;
165  int ReduceVoidArray(const void* sendBuffer, void* recvBuffer, vtkIdType length, int type,
166  int operation, int destProcessId) override;
167  int ReduceVoidArray(const void* sendBuffer, void* recvBuffer, vtkIdType length, int type,
168  Operation* operation, int destProcessId) override;
170  const void* sendBuffer, void* recvBuffer, vtkIdType length, int type, int operation) override;
171  int AllReduceVoidArray(const void* sendBuffer, void* recvBuffer, vtkIdType length, int type,
172  Operation* operation) override;
174 
176 
185  int Iprobe(int source, int tag, int* flag, int* actualSource);
186  int Iprobe(int source, int tag, int* flag, int* actualSource, int* type, int* size);
187  int Iprobe(int source, int tag, int* flag, int* actualSource, unsigned long* type, int* size);
188  int Iprobe(int source, int tag, int* flag, int* actualSource, const char* type, int* size);
189  int Iprobe(int source, int tag, int* flag, int* actualSource, float* type, int* size);
190  int Iprobe(int source, int tag, int* flag, int* actualSource, double* type, int* size);
192 
197  int WaitAll(const int count, Request requests[]);
198 
204  int WaitAny(const int count, Request requests[], int& idx) VTK_SIZEHINT(requests, count);
205 
211  int WaitSome(const int count, Request requests[], int& NCompleted, int* completed)
212  VTK_SIZEHINT(requests, count);
213 
219  int TestAll(const int count, Request requests[], int& flag) VTK_SIZEHINT(requests, count);
220 
224  int TestAny(const int count, Request requests[], int& idx, int& flag)
225  VTK_SIZEHINT(requests, count);
226 
233  int TestSome(const int count, Request requests[], int& NCompleted, int* completed)
234  VTK_SIZEHINT(requests, count);
235 
236  friend class vtkMPIController;
237 
238  vtkMPICommunicatorOpaqueComm* GetMPIComm() { return this->MPIComm; }
239 
240  int InitializeExternal(vtkMPICommunicatorOpaqueComm* comm);
241 
242  static char* Allocate(size_t size);
243  static void Free(char* ptr);
244 
246 
250  vtkSetClampMacro(UseSsend, int, 0, 1);
251  vtkGetMacro(UseSsend, int);
252  vtkBooleanMacro(UseSsend, int);
254 
263 
264 protected:
267 
268  // Obtain size and rank setting NumberOfProcesses and LocalProcessId Should
269  // not be called if the current communicator does not include this process
271 
273 
283  vtkSetMacro(KeepHandle, int);
284  vtkBooleanMacro(KeepHandle, int);
286 
288 
290 
301 
305  virtual int ReceiveDataInternal(char* data, int length, int sizeoftype, int remoteProcessId,
306  int tag, vtkMPICommunicatorReceiveDataInfo* info, int useCopy, int& senderId);
307 
308  vtkMPICommunicatorOpaqueComm* MPIComm;
309 
312 
314  int UseSsend;
315  static int CheckForMPIError(int err);
316 
317 private:
318  vtkMPICommunicator(const vtkMPICommunicator&) = delete;
319  void operator=(const vtkMPICommunicator&) = delete;
320 };
321 
322 #endif
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::Barrier
void Barrier() override
More efficient implementations of collective operations that use the equivalent MPI commands.
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:53
vtkMPICommunicator::AllGatherVVoidArray
int AllGatherVVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType sendLength, vtkIdType *recvLengths, vtkIdType *offsets, int type) override
More efficient implementations of collective operations that use the equivalent MPI commands.
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)
This method receives data from a corresponding send (non-blocking).
vtkMPICommunicator::NoBlockReceive
int NoBlockReceive(float *data, int length, int remoteProcessId, int tag, Request &req)
This method receives data from a corresponding send (non-blocking).
vtkMPICommunicator::Initialized
int Initialized
Definition: vtkMPICommunicator.h:310
vtkX3D::type
@ type
Definition: vtkX3D.h:522
vtkCommunicator
Used to send/receive messages in a multiprocess environment.
Definition: vtkCommunicator.h:51
vtkIdType
int vtkIdType
Definition: vtkType.h:338
vtkMPICommunicator::UseSsend
int UseSsend
Definition: vtkMPICommunicator.h:314
vtkMPICommunicator::Initialize
int Initialize(vtkProcessGroup *group)
Used to initialize the communicator (i.e.
vtkX3D::data
@ data
Definition: vtkX3D.h:321
vtkMPICommunicator::NoBlockSend
int NoBlockSend(const unsigned char *data, int length, int remoteProcessId, int tag, Request &req)
This method sends data to another process (non-blocking).
vtkCommunicator::Operation
A custom operation to use in a reduce command.
Definition: vtkCommunicator.h:104
vtkX3D::key
@ key
Definition: vtkX3D.h:263
vtkMPICommunicator::Request::Request
Request()
vtkMPICommunicator::Request::Cancel
void Cancel()
vtkX3D::length
@ length
Definition: vtkX3D.h:399
vtkMPICommunicator::Request::Test
int Test()
vtkMPICommunicator::NoBlockSend
int NoBlockSend(const float *data, int length, int remoteProcessId, int tag, Request &req)
This method sends data to another process (non-blocking).
vtkMPICommunicator::ReduceVoidArray
int ReduceVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type, int operation, int destProcessId) override
More efficient implementations of collective operations that use the equivalent MPI commands.
vtkMPICommunicator::NoBlockReceive
int NoBlockReceive(char *data, int length, int remoteProcessId, int tag, Request &req)
This method receives data from a corresponding send (non-blocking).
vtkMPICommunicator::LastSenderId
int LastSenderId
Definition: vtkMPICommunicator.h:313
vtkMPICommunicator::AllGatherVoidArray
int AllGatherVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type) override
More efficient implementations of collective operations that use the equivalent MPI commands.
vtkMPICommunicator
Class for creating user defined MPI communicators.
Definition: vtkMPICommunicator.h:50
vtkMPICommunicator::Allocate
static char * Allocate(size_t size)
vtkMPICommunicator::ScatterVoidArray
int ScatterVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type, int srcProcessId) override
More efficient implementations of collective operations that use the equivalent MPI commands.
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.
vtkX3D::color
@ color
Definition: vtkX3D.h:227
vtkMPICommunicator::NoBlockReceive
int NoBlockReceive(unsigned long *data, int length, int remoteProcessId, int tag, Request &req)
This method receives data from a corresponding send (non-blocking).
vtkMPICommunicator::Request::Request
Request(const Request &)
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:48
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)
Nonblocking test for a message.
vtkMPICommunicator::InitializeCopy
void InitializeCopy(vtkMPICommunicator *source)
vtkMPICommunicator::ReceiveVoidArray
int ReceiveVoidArray(void *data, vtkIdType length, int type, int remoteProcessId, int tag) override
Performs the actual communication.
vtkMPICommunicator::WorldCommunicator
static vtkMPICommunicator * WorldCommunicator
Definition: vtkMPICommunicator.h:284
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:34
vtkMPICommunicator::~vtkMPICommunicator
~vtkMPICommunicator() override
vtkMPICommunicator::TestSome
int TestSome(const int count, Request requests[], int &NCompleted, int *completed)
Checks the status of all the given request communication object handles.
vtkX3D::size
@ size
Definition: vtkX3D.h:259
vtkMPICommunicator::Iprobe
int Iprobe(int source, int tag, int *flag, int *actualSource, unsigned long *type, int *size)
Nonblocking test for a message.
vtkMPICommunicator::Iprobe
int Iprobe(int source, int tag, int *flag, int *actualSource, int *type, int *size)
Nonblocking test for a message.
vtkMPICommunicator::GatherVVoidArray
int GatherVVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType sendLength, vtkIdType *recvLengths, vtkIdType *offsets, int type, int destProcessId) override
More efficient implementations of collective operations that use the equivalent MPI commands.
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::AllReduceVoidArray
int AllReduceVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type, int operation) override
More efficient implementations of collective operations that use the equivalent MPI commands.
vtkMPICommunicator::Request::operator=
Request & operator=(const Request &)
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)
This method receives data from a corresponding send (non-blocking).
vtkMPICommunicator::ScatterVVoidArray
int ScatterVVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType *sendLengths, vtkIdType *offsets, vtkIdType recvLength, int type, int srcProcessId) override
More efficient implementations of collective operations that use the equivalent MPI commands.
vtkX3D::info
@ info
Definition: vtkX3D.h:382
vtkMPICommunicator::Free
static void Free(char *ptr)
vtkMPICommunicator::ReduceVoidArray
int ReduceVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type, Operation *operation, int destProcessId) override
More efficient implementations of collective operations that use the equivalent MPI commands.
vtkProcessGroup
A subgroup of processes from a communicator.
Definition: vtkProcessGroup.h:55
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)
Nonblocking test for a message.
vtkMPICommunicator::KeepHandle
int KeepHandle
Definition: vtkMPICommunicator.h:311
vtkMPICommunicator::GatherVoidArray
int GatherVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type, int destProcessId) override
More efficient implementations of collective operations that use the equivalent MPI commands.
vtkMPICommunicator::MPIComm
vtkMPICommunicatorOpaqueComm * MPIComm
Definition: vtkMPICommunicator.h:308
vtkMPICommunicator::GetMPIComm
vtkMPICommunicatorOpaqueComm * GetMPIComm()
Definition: vtkMPICommunicator.h:238
vtkMPICommunicator::AllReduceVoidArray
int AllReduceVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type, Operation *operation) override
More efficient implementations of collective operations that use the equivalent MPI commands.
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:959
vtkMPICommunicator::NoBlockSend
int NoBlockSend(const unsigned long *data, int length, int remoteProcessId, int tag, Request &req)
This method sends data to another process (non-blocking).
vtkMPIController
Process communication using MPI.
Definition: vtkMPIController.h:56
vtkMPICommunicator::Request::Req
vtkMPICommunicatorOpaqueRequest * Req
Definition: vtkMPICommunicator.h:62
vtkMPICommunicator::Iprobe
int Iprobe(int source, int tag, int *flag, int *actualSource, const char *type, int *size)
Nonblocking test for a message.
vtkMPICommunicator::NoBlockSend
int NoBlockSend(const double *data, int length, int remoteProcessId, int tag, Request &req)
This method sends data to another process (non-blocking).
vtkMPICommunicator::SplitInitialize
int SplitInitialize(vtkCommunicator *oldcomm, int color, int key)
Used to initialize the communicator (i.e.
vtkMPICommunicator::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkMPICommunicator::Request::~Request
~Request()
vtkMPICommunicator::NoBlockSend
int NoBlockSend(const char *data, int length, int remoteProcessId, int tag, Request &req)
This method sends data to another process (non-blocking).
vtkMPICommunicator::SendVoidArray
int SendVoidArray(const void *data, vtkIdType length, int type, int remoteProcessId, int tag) override
Performs the actual communication.
vtkMPICommunicator::BroadcastVoidArray
int BroadcastVoidArray(void *data, vtkIdType length, int type, int srcProcessId) override
More efficient implementations of collective operations that use the equivalent MPI commands.