00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00042 #ifndef __vtkMPICommunicator_h
00043 #define __vtkMPICommunicator_h
00044
00045 #include "vtkCommunicator.h"
00046
00047 class vtkMPIController;
00048 class vtkMPIGroup;
00049
00050 class vtkMPICommunicatorOpaqueRequest;
00051 class vtkMPICommunicatorOpaqueComm;
00052
00053 class VTK_PARALLEL_EXPORT vtkMPICommunicator : public vtkCommunicator
00054 {
00055 public:
00056 vtkTypeRevisionMacro( vtkMPICommunicator,vtkCommunicator);
00057
00059 static vtkMPICommunicator* New();
00060
00063 static vtkMPICommunicator* GetWorldCommunicator();
00064
00065 virtual void PrintSelf(ostream& os, vtkIndent indent);
00066
00071 int Initialize(vtkMPICommunicator* mpiComm, vtkMPIGroup* group);
00072
00074
00076 virtual int Send(int* data, int length, int remoteProcessId, int tag);
00077 virtual int Send(unsigned long* data, int length, int remoteProcessId,
00078 int tag);
00079 virtual int Send(char* data, int length, int remoteProcessId, int tag);
00080 virtual int Send(unsigned char* data, int length, int remoteProcessId,
00081 int tag);
00082 virtual int Send(float* data, int length, int remoteProcessId,
00083 int tag);
00084 virtual int Send(double* data, int length, int remoteProcessId,
00085 int tag);
00086 #ifdef VTK_USE_64BIT_IDS
00087 virtual int Send(vtkIdType* data, int length, int remoteProcessId,
00088 int tag);
00090 #endif
00091 virtual int Send(vtkDataObject* data, int remoteProcessId, int tag)
00092 { return this->vtkCommunicator::Send(data, remoteProcessId, tag); }
00093 virtual int Send(vtkDataArray* data, int remoteProcessId, int tag)
00094 { return this->vtkCommunicator::Send(data, remoteProcessId, tag); }
00095
00096
00097
00098 class VTK_PARALLEL_EXPORT Request
00099 {
00100 public:
00101 Request();
00102 ~Request();
00103 int Test();
00104 void Cancel();
00105 void Wait();
00106 vtkMPICommunicatorOpaqueRequest* Req;
00107 };
00108
00109
00110
00112
00116 int NoBlockSend(int* data, int length, int remoteProcessId, int tag,
00117 Request& req);
00118 int NoBlockSend(unsigned long* data, int length, int remoteProcessId,
00119 int tag, Request& req);
00120 int NoBlockSend(char* data, int length, int remoteProcessId,
00121 int tag, Request& req);
00122 int NoBlockSend(float* data, int length, int remoteProcessId,
00123 int tag, Request& req);
00125
00127
00129 virtual int Receive(int* data, int length, int remoteProcessId,
00130 int tag);
00131 virtual int Receive(unsigned long* data, int length,
00132 int remoteProcessId, int tag);
00133 virtual int Receive(char* data, int length, int remoteProcessId,
00134 int tag);
00135 virtual int Receive(unsigned char* data, int length, int remoteProcessId,
00136 int tag);
00137 virtual int Receive(float* data, int length, int remoteProcessId,
00138 int tag);
00139 virtual int Receive(double* data, int length, int remoteProcessId,
00140 int tag);
00141 #ifdef VTK_USE_64BIT_IDS
00142 virtual int Receive(vtkIdType* data, int length, int remoteProcessId,
00143 int tag);
00145 #endif
00146 virtual int Receive(vtkDataObject* data, int remoteProcessId, int tag)
00147 { return this->vtkCommunicator::Receive(data, remoteProcessId, tag); }
00148 virtual int Receive(vtkDataArray* data, int remoteProcessId, int tag)
00149 { return this->vtkCommunicator::Receive(data, remoteProcessId, tag); }
00150
00152
00155 int NoBlockReceive(int* data, int length, int remoteProcessId,
00156 int tag, Request& req);
00157 int NoBlockReceive(unsigned long* data, int length,
00158 int remoteProcessId, int tag, Request& req);
00159 int NoBlockReceive(char* data, int length, int remoteProcessId,
00160 int tag, Request& req);
00161 int NoBlockReceive(float* data, int length, int remoteProcessId,
00162 int tag, Request& req);
00164
00165
00167
00168 int Broadcast(int* data , int length, int root);
00169 int Broadcast(unsigned long* data, int length, int root);
00170 int Broadcast(char* data , int length, int root);
00171 int Broadcast(float* data , int length, int root);
00172 int Broadcast(double* data , int length, int root);
00174
00175
00177
00179 int Gather(int* data , int* to , int length, int root);
00180 int Gather(unsigned long* data, unsigned long* to, int length, int root);
00181 int Gather(char* data , char* to , int length, int root);
00182 int Gather(float* data , float* to , int length, int root);
00183 int Gather(double* data , double* to , int length, int root);
00185
00187
00194 int GatherV(int* data, int* to,
00195 int sendlength, int* recvlengths, int* offsets, int root);
00196 int GatherV(unsigned long* data, unsigned long* to,
00197 int sendlength, int* recvlengths, int* offsets, int root);
00198 int GatherV(char* data, char* to,
00199 int sendlength, int* recvlengths, int* offsets, int root);
00200 int GatherV(float* data, float* to,
00201 int sendlength, int* recvlengths, int* offsets, int root);
00202 int GatherV(double* data, double* to,
00203 int sendlength, int* recvlengths, int* offsets, int root);
00205
00207
00208 int ReduceMax(int* data, int* to, int size, int root);
00209 int ReduceMax(long* data, long* to, int size, int root);
00210 int ReduceMax(float* data, float* to, int size, int root);
00211 int ReduceMax(double* data, double* to, int size, int root);
00213
00214 int ReduceMin(int* data, int* to, int size, int root);
00215 int ReduceMin(long* data, long* to, int size, int root);
00216 int ReduceMin(float* data, float* to, int size, int root);
00217 int ReduceMin(double* data, double* to, int size, int root);
00218
00219 int ReduceSum(int* data, int* to, int size, int root);
00220 int ReduceSum(long* data, long* to, int size, int root);
00221 int ReduceSum(float* data, float* to, int size, int root);
00222 int ReduceSum(double* data, double* to, int size, int root);
00223
00224 int ReduceAnd(bool* data, bool* to, int size, int root);
00225 int ReduceOr(bool* data, bool* to, int size, int root);
00226
00227
00228
00229
00230 friend class vtkMPIController;
00231
00232 vtkMPICommunicatorOpaqueComm* GetMPIComm()
00233 {
00234 return this->Comm;
00235 }
00236
00237
00238
00239 static char* Allocate(size_t size);
00240 static void Free(char* ptr);
00241
00242
00243 protected:
00244 vtkMPICommunicator();
00245 ~vtkMPICommunicator();
00246
00247 virtual void SetGroup(vtkMPIGroup*);
00248
00250
00257 vtkSetMacro(KeepHandle, int);
00258 vtkBooleanMacro(KeepHandle, int);
00260
00261
00262 static vtkMPICommunicator* WorldCommunicator;
00263
00264 void InitializeCopy(vtkMPICommunicator* source);
00265
00270 void CopyFrom(vtkMPICommunicator* source);
00271
00278 void Duplicate(vtkMPICommunicator* source);
00279
00280 vtkMPICommunicatorOpaqueComm* Comm;
00281 vtkMPIGroup* Group;
00282
00283 int Initialized;
00284 int KeepHandle;
00285
00286 static int CheckForMPIError(int err);
00287
00288 private:
00289 vtkMPICommunicator(const vtkMPICommunicator&);
00290 void operator=(const vtkMPICommunicator&);
00291 };
00292
00293
00294 #endif // __vtkMPICommunicator_h
00295
00296
00297
00298