VTK  9.2.6
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 "vtkCommunicator.h"
43#include "vtkParallelMPIModule.h" // For export macro
44
46class vtkProcessGroup;
47
48class vtkMPICommunicatorOpaqueComm;
49class vtkMPICommunicatorOpaqueRequest;
50class vtkMPICommunicatorReceiveDataInfo;
51
52class VTKPARALLELMPI_EXPORT vtkMPICommunicator : public vtkCommunicator
53{
54public:
55 class VTKPARALLELMPI_EXPORT Request
56 {
57 public:
62 int Test();
63 void Cancel();
64 void Wait();
65 vtkMPICommunicatorOpaqueRequest* Req;
66 };
67
69 void PrintSelf(ostream& os, vtkIndent indent) override;
70
75
81
87
93 int SplitInitialize(vtkCommunicator* oldcomm, int color, int key);
94
96
102 const void* data, vtkIdType length, int type, int remoteProcessId, int tag) override;
104 void* data, vtkIdType length, int type, int remoteProcessId, int tag) override;
106
108
116 int NoBlockSend(const int* data, int length, int remoteProcessId, int tag, Request& req);
118 const unsigned long* data, int length, int remoteProcessId, int tag, Request& req);
119 int NoBlockSend(const char* data, int length, int remoteProcessId, int tag, Request& req);
121 const unsigned char* data, int length, int remoteProcessId, int tag, Request& req);
122 int NoBlockSend(const float* data, int length, int remoteProcessId, int tag, Request& req);
123 int NoBlockSend(const double* data, int length, int remoteProcessId, int tag, Request& req);
124#ifdef VTK_USE_64BIT_IDS
125 int NoBlockSend(const vtkIdType* data, int length, int remoteProcessId, int tag, Request& req);
126#endif
128
130
137 int NoBlockReceive(int* data, int length, int remoteProcessId, int tag, Request& req);
138 int NoBlockReceive(unsigned long* data, int length, int remoteProcessId, int tag, Request& req);
139 int NoBlockReceive(char* data, int length, int remoteProcessId, int tag, Request& req);
140 int NoBlockReceive(unsigned char* data, int length, int remoteProcessId, int tag, Request& req);
141 int NoBlockReceive(float* data, int length, int remoteProcessId, int tag, Request& req);
142 int NoBlockReceive(double* data, int length, int remoteProcessId, int tag, Request& req);
143#ifdef VTK_USE_64BIT_IDS
144 int NoBlockReceive(vtkIdType* data, int length, int remoteProcessId, int tag, Request& req);
145#endif
147
149
154 void Barrier() override;
155 int BroadcastVoidArray(void* data, vtkIdType length, int type, int srcProcessId) override;
156 int GatherVoidArray(const void* sendBuffer, void* recvBuffer, vtkIdType length, int type,
157 int destProcessId) override;
158 int GatherVVoidArray(const void* sendBuffer, void* recvBuffer, vtkIdType sendLength,
159 vtkIdType* recvLengths, vtkIdType* offsets, int type, int destProcessId) override;
160 int ScatterVoidArray(const void* sendBuffer, void* recvBuffer, vtkIdType length, int type,
161 int srcProcessId) override;
162 int ScatterVVoidArray(const void* sendBuffer, void* recvBuffer, vtkIdType* sendLengths,
163 vtkIdType* offsets, vtkIdType recvLength, int type, int srcProcessId) override;
165 const void* sendBuffer, void* recvBuffer, vtkIdType length, int type) override;
166 int AllGatherVVoidArray(const void* sendBuffer, void* recvBuffer, vtkIdType sendLength,
167 vtkIdType* recvLengths, vtkIdType* offsets, int type) override;
168 int ReduceVoidArray(const void* sendBuffer, void* recvBuffer, vtkIdType length, int type,
169 int operation, int destProcessId) override;
170 int ReduceVoidArray(const void* sendBuffer, void* recvBuffer, vtkIdType length, int type,
171 Operation* operation, int destProcessId) override;
173 const void* sendBuffer, void* recvBuffer, vtkIdType length, int type, int operation) override;
174 int AllReduceVoidArray(const void* sendBuffer, void* recvBuffer, vtkIdType length, int type,
175 Operation* operation) override;
177
179
188 int Iprobe(int source, int tag, int* flag, int* actualSource);
189 int Iprobe(int source, int tag, int* flag, int* actualSource, int* type, int* size);
190 int Iprobe(int source, int tag, int* flag, int* actualSource, unsigned long* type, int* size);
191 int Iprobe(int source, int tag, int* flag, int* actualSource, const char* type, int* size);
192 int Iprobe(int source, int tag, int* flag, int* actualSource, float* type, int* size);
193 int Iprobe(int source, int tag, int* flag, int* actualSource, double* type, int* size);
195
200 int WaitAll(const int count, Request requests[]);
201
207 int WaitAny(const int count, Request requests[], int& idx) VTK_SIZEHINT(requests, count);
208
214 int WaitSome(const int count, Request requests[], int& NCompleted, int* completed)
215 VTK_SIZEHINT(requests, count);
216
222 int TestAll(const int count, Request requests[], int& flag) VTK_SIZEHINT(requests, count);
223
227 int TestAny(const int count, Request requests[], int& idx, int& flag)
228 VTK_SIZEHINT(requests, count);
229
236 int TestSome(const int count, Request requests[], int& NCompleted, int* completed)
237 VTK_SIZEHINT(requests, count);
238
239 friend class vtkMPIController;
240
241 vtkMPICommunicatorOpaqueComm* GetMPIComm() { return this->MPIComm; }
242
243 int InitializeExternal(vtkMPICommunicatorOpaqueComm* comm);
244
245 static char* Allocate(size_t size);
246 static void Free(char* ptr);
247
249
253 vtkSetClampMacro(UseSsend, int, 0, 1);
254 vtkGetMacro(UseSsend, int);
255 vtkBooleanMacro(UseSsend, int);
257
266
267protected:
270
271 // Obtain size and rank setting NumberOfProcesses and LocalProcessId Should
272 // not be called if the current communicator does not include this process
274
276
286 vtkSetMacro(KeepHandle, int);
287 vtkBooleanMacro(KeepHandle, int);
289
291
293
304
308 virtual int ReceiveDataInternal(char* data, int length, int sizeoftype, int remoteProcessId,
309 int tag, vtkMPICommunicatorReceiveDataInfo* info, int useCopy, int& senderId);
310
311 vtkMPICommunicatorOpaqueComm* MPIComm;
312
315
318 static int CheckForMPIError(int err);
319
320private:
321 vtkMPICommunicator(const vtkMPICommunicator&) = delete;
322 void operator=(const vtkMPICommunicator&) = delete;
323};
324
325#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
Request & operator=(const Request &)
Class for creating user defined MPI communicators.
int NoBlockReceive(double *data, int length, int remoteProcessId, int tag, Request &req)
This method receives data from a corresponding send (non-blocking).
int NoBlockReceive(unsigned char *data, int length, int remoteProcessId, int tag, Request &req)
This method receives data from a corresponding send (non-blocking).
void InitializeCopy(vtkMPICommunicator *source)
static vtkMPICommunicator * WorldCommunicator
int InitializeNumberOfProcesses()
int SplitInitialize(vtkCommunicator *oldcomm, int color, int key)
Used to initialize the communicator (i.e.
int InitializeExternal(vtkMPICommunicatorOpaqueComm *comm)
static vtkMPICommunicator * New()
Creates an empty communicator.
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)
This method sends data to another process (non-blocking).
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)
This method sends data to another process (non-blocking).
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.
int TestAny(const int count, Request requests[], int &idx, int &flag)
Check if at least one of the specified requests has completed.
static char * Allocate(size_t size)
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)
This method sends data to another process (non-blocking).
void Barrier() override
More efficient implementations of collective operations that use the equivalent MPI commands.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkMPICommunicatorOpaqueComm * MPIComm
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.
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.
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.
int SendVoidArray(const void *data, vtkIdType length, int type, int remoteProcessId, int tag) override
Performs the actual communication.
static void Free(char *ptr)
int NoBlockReceive(unsigned long *data, int length, int remoteProcessId, int tag, Request &req)
This method receives data from a corresponding send (non-blocking).
int AllGatherVoidArray(const void *sendBuffer, void *recvBuffer, vtkIdType length, int type) override
More efficient implementations of collective operations that use the equivalent MPI commands.
int TestAll(const int count, Request requests[], int &flag)
Checks if the given communication request objects are complete.
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.
int Iprobe(int source, int tag, int *flag, int *actualSource, int *type, int *size)
Nonblocking test for a message.
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.
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.
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.
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)
Nonblocking test for a message.
int ReceiveVoidArray(void *data, vtkIdType length, int type, int remoteProcessId, int tag) override
Performs the actual communication.
int NoBlockSend(const unsigned long *data, int length, int remoteProcessId, int tag, Request &req)
This method sends data to another process (non-blocking).
int NoBlockSend(const double *data, int length, int remoteProcessId, int tag, Request &req)
This method sends data to another process (non-blocking).
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.
int BroadcastVoidArray(void *data, vtkIdType length, int type, int srcProcessId) override
More efficient implementations of collective operations that use the equivalent MPI commands.
int NoBlockReceive(char *data, int length, int remoteProcessId, int tag, Request &req)
This method receives data from a corresponding send (non-blocking).
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() override
int Iprobe(int source, int tag, int *flag, int *actualSource, float *type, int *size)
Nonblocking test for a message.
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.
static int CheckForMPIError(int err)
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.
vtkMPICommunicatorOpaqueComm * GetMPIComm()
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)
This method receives data from a corresponding send (non-blocking).
int Iprobe(int source, int tag, int *flag, int *actualSource, const char *type, int *size)
Nonblocking test for a message.
int Iprobe(int source, int tag, int *flag, int *actualSource, double *type, int *size)
Nonblocking test for a message.
Process communication using MPI.
A subgroup of processes from a communicator.
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
int vtkIdType
Definition: vtkType.h:332
#define VTK_SIZEHINT(...)