00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00038 #ifndef __vtkMPICommunicator_h
00039 #define __vtkMPICommunicator_h
00040
00041 #include "vtkCommunicator.h"
00042
00043 class vtkMPIController;
00044 class vtkMPIGroup;
00045 class vtkProcessGroup;
00046
00047 class vtkMPICommunicatorOpaqueRequest;
00048 class vtkMPICommunicatorOpaqueComm;
00049
00050 class VTK_PARALLEL_EXPORT vtkMPICommunicator : public vtkCommunicator
00051 {
00052 public:
00053 vtkTypeRevisionMacro( vtkMPICommunicator,vtkCommunicator);
00054
00056 static vtkMPICommunicator* New();
00057
00060 static vtkMPICommunicator* GetWorldCommunicator();
00061
00062 virtual void PrintSelf(ostream& os, vtkIndent indent);
00063
00067 int Initialize(vtkProcessGroup *group);
00068
00070 VTK_LEGACY(int Initialize(vtkMPICommunicator* mpiComm, vtkMPIGroup* group));
00071
00073
00075 virtual int SendVoidArray(const void *data, vtkIdType length, int type,
00076 int remoteProcessId, int tag);
00077 virtual int ReceiveVoidArray(void *data, vtkIdType length, int type,
00078 int remoteProcessId, int tag);
00080
00081
00082
00083 class VTK_PARALLEL_EXPORT Request
00084 {
00085 public:
00086 Request();
00087 Request( const Request& );
00088 ~Request();
00089 Request& operator = ( const Request& );
00090 int Test();
00091 void Cancel();
00092 void Wait();
00093 vtkMPICommunicatorOpaqueRequest* Req;
00094 };
00095
00096
00097
00099
00103 int NoBlockSend(const int* data, int length, int remoteProcessId, int tag,
00104 Request& req);
00105 int NoBlockSend(const unsigned long* data, int length, int remoteProcessId,
00106 int tag, Request& req);
00107 int NoBlockSend(const char* data, int length, int remoteProcessId,
00108 int tag, Request& req);
00109 int NoBlockSend(const float* data, int length, int remoteProcessId,
00110 int tag, Request& req);
00112
00114
00117 int NoBlockReceive(int* data, int length, int remoteProcessId,
00118 int tag, Request& req);
00119 int NoBlockReceive(unsigned long* data, int length,
00120 int remoteProcessId, int tag, Request& req);
00121 int NoBlockReceive(char* data, int length, int remoteProcessId,
00122 int tag, Request& req);
00123 int NoBlockReceive(float* data, int length, int remoteProcessId,
00124 int tag, Request& req);
00125 #ifdef VTK_USE_64BIT_IDS
00126 int NoBlockReceive(vtkIdType* data, int length, int remoteProcessId,
00127 int tag, Request& req);
00129 #endif
00130
00131
00133
00135 virtual void Barrier();
00136 virtual int BroadcastVoidArray(void *data, vtkIdType length, int type,
00137 int srcProcessId);
00138 virtual int GatherVoidArray(const void *sendBuffer, void *recvBuffer,
00139 vtkIdType length, int type, int destProcessId);
00140 virtual int GatherVVoidArray(const void *sendBuffer, void *recvBuffer,
00141 vtkIdType sendLength, vtkIdType *recvLengths,
00142 vtkIdType *offsets, int type, int destProcessId);
00143 virtual int ScatterVoidArray(const void *sendBuffer, void *recvBuffer,
00144 vtkIdType length, int type, int srcProcessId);
00145 virtual int ScatterVVoidArray(const void *sendBuffer, void *recvBuffer,
00146 vtkIdType *sendLengths, vtkIdType *offsets,
00147 vtkIdType recvLength, int type,
00148 int srcProcessId);
00149 virtual int AllGatherVoidArray(const void *sendBuffer, void *recvBuffer,
00150 vtkIdType length, int type);
00151 virtual int AllGatherVVoidArray(const void *sendBuffer, void *recvBuffer,
00152 vtkIdType sendLength, vtkIdType *recvLengths,
00153 vtkIdType *offsets, int type);
00154 virtual int ReduceVoidArray(const void *sendBuffer, void *recvBuffer,
00155 vtkIdType length, int type,
00156 int operation, int destProcessId);
00157 virtual int ReduceVoidArray(const void *sendBuffer, void *recvBuffer,
00158 vtkIdType length, int type,
00159 Operation *operation, int destProcessId);
00160 virtual int AllReduceVoidArray(const void *sendBuffer, void *recvBuffer,
00161 vtkIdType length, int type,
00162 int operation);
00163 virtual int AllReduceVoidArray(const void *sendBuffer, void *recvBuffer,
00164 vtkIdType length, int type,
00165 Operation *operation);
00167
00169
00170 VTK_LEGACY(int ReduceMax(int* data, int* to, int size, int root));
00171 VTK_LEGACY(int ReduceMax(unsigned long* data, unsigned long* to, int size, int root));
00172 VTK_LEGACY(int ReduceMax(float* data, float* to, int size, int root));
00173 VTK_LEGACY(int ReduceMax(double* data, double* to, int size, int root));
00175
00176 VTK_LEGACY(int ReduceMin(int* data, int* to, int size, int root));
00177 VTK_LEGACY(int ReduceMin(unsigned long* data, unsigned long* to, int size, int root));
00178 VTK_LEGACY(int ReduceMin(float* data, float* to, int size, int root));
00179 VTK_LEGACY(int ReduceMin(double* data, double* to, int size, int root));
00180
00181 VTK_LEGACY(int ReduceSum(int* data, int* to, int size, int root));
00182 VTK_LEGACY(int ReduceSum(unsigned long* data, unsigned long* to, int size, int root));
00183 VTK_LEGACY(int ReduceSum(float* data, float* to, int size, int root));
00184 VTK_LEGACY(int ReduceSum(double* data, double* to, int size, int root));
00185
00186
00187 VTK_LEGACY(int ReduceAnd(bool* data, bool* to, int size, int root));
00188 VTK_LEGACY(int ReduceOr(bool* data, bool* to, int size, int root));
00189
00190
00191
00192
00193 friend class vtkMPIController;
00194
00195 vtkMPICommunicatorOpaqueComm *GetMPIComm()
00196 {
00197 return this->MPIComm;
00198 }
00199
00200
00201 static char* Allocate(size_t size);
00202 static void Free(char* ptr);
00203
00204
00205 protected:
00206 vtkMPICommunicator();
00207 ~vtkMPICommunicator();
00208
00209
00210
00211 int InitializeNumberOfProcesses();
00212
00214
00221 vtkSetMacro(KeepHandle, int);
00222 vtkBooleanMacro(KeepHandle, int);
00224
00225
00226 static vtkMPICommunicator* WorldCommunicator;
00227
00228 void InitializeCopy(vtkMPICommunicator* source);
00229
00234 void CopyFrom(vtkMPICommunicator* source);
00235
00242 void Duplicate(vtkMPICommunicator* source);
00243
00244 vtkMPICommunicatorOpaqueComm* MPIComm;
00245
00246 int Initialized;
00247 int KeepHandle;
00248
00249 int LastSenderId;
00250
00251 static int CheckForMPIError(int err);
00252
00253 private:
00254 vtkMPICommunicator(const vtkMPICommunicator&);
00255 void operator=(const vtkMPICommunicator&);
00256 };
00257
00258 #endif