00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00054 #ifndef __vtkMPICommunicator_h
00055 #define __vtkMPICommunicator_h
00056
00057 #include "vtkCommunicator.h"
00058
00059 class vtkMPIController;
00060 class vtkMPIGroup;
00061
00062 class vtkMPICommunicatorOpaqueRequest;
00063 class vtkMPICommunicatorOpaqueComm;
00064
00065 class VTK_PARALLEL_EXPORT vtkMPICommunicator : public vtkCommunicator
00066 {
00067 public:
00068 vtkTypeRevisionMacro( vtkMPICommunicator,vtkCommunicator);
00069
00071 static vtkMPICommunicator* New();
00072
00075 static vtkMPICommunicator* GetWorldCommunicator();
00076
00077 virtual void PrintSelf(ostream& os, vtkIndent indent);
00078
00083 int Initialize(vtkMPICommunicator* mpiComm, vtkMPIGroup* group);
00084
00086
00088 virtual int Send(int* data, int length, int remoteProcessId, int tag);
00089 virtual int Send(unsigned long* data, int length, int remoteProcessId,
00090 int tag);
00091 virtual int Send(char* data, int length, int remoteProcessId, int tag);
00092 virtual int Send(unsigned char* data, int length, int remoteProcessId,
00093 int tag);
00094 virtual int Send(float* data, int length, int remoteProcessId,
00095 int tag);
00096 virtual int Send(double* data, int length, int remoteProcessId,
00097 int tag);
00098 #ifdef VTK_USE_64BIT_IDS
00099 virtual int Send(vtkIdType* data, int length, int remoteProcessId,
00100 int tag);
00102 #endif
00103 virtual int Send(vtkDataObject* data, int remoteProcessId, int tag)
00104 { return this->vtkCommunicator::Send(data, remoteProcessId, tag); }
00105 virtual int Send(vtkDataArray* data, int remoteProcessId, int tag)
00106 { return this->vtkCommunicator::Send(data, remoteProcessId, tag); }
00107
00108
00109
00110 class VTK_PARALLEL_EXPORT Request
00111 {
00112 public:
00113 Request();
00114 ~Request();
00115 int Test();
00116 void Cancel();
00117 void Wait();
00118 vtkMPICommunicatorOpaqueRequest* Req;
00119 };
00120
00121
00122
00124
00128 int NoBlockSend(int* data, int length, int remoteProcessId, int tag,
00129 Request& req);
00130 int NoBlockSend(unsigned long* data, int length, int remoteProcessId,
00131 int tag, Request& req);
00132 int NoBlockSend(char* data, int length, int remoteProcessId,
00133 int tag, Request& req);
00134 int NoBlockSend(float* data, int length, int remoteProcessId,
00135 int tag, Request& req);
00137
00139
00141 virtual int Receive(int* data, int length, int remoteProcessId,
00142 int tag);
00143 virtual int Receive(unsigned long* data, int length,
00144 int remoteProcessId, int tag);
00145 virtual int Receive(char* data, int length, int remoteProcessId,
00146 int tag);
00147 virtual int Receive(unsigned char* data, int length, int remoteProcessId,
00148 int tag);
00149 virtual int Receive(float* data, int length, int remoteProcessId,
00150 int tag);
00151 virtual int Receive(double* data, int length, int remoteProcessId,
00152 int tag);
00153 #ifdef VTK_USE_64BIT_IDS
00154 virtual int Receive(vtkIdType* data, int length, int remoteProcessId,
00155 int tag);
00157 #endif
00158 virtual int Receive(vtkDataObject* data, int remoteProcessId, int tag)
00159 { return this->vtkCommunicator::Receive(data, remoteProcessId, tag); }
00160 virtual int Receive(vtkDataArray* data, int remoteProcessId, int tag)
00161 { return this->vtkCommunicator::Receive(data, remoteProcessId, tag); }
00162
00164
00167 int NoBlockReceive(int* data, int length, int remoteProcessId,
00168 int tag, Request& req);
00169 int NoBlockReceive(unsigned long* data, int length,
00170 int remoteProcessId, int tag, Request& req);
00171 int NoBlockReceive(char* data, int length, int remoteProcessId,
00172 int tag, Request& req);
00173 int NoBlockReceive(float* data, int length, int remoteProcessId,
00174 int tag, Request& req);
00176
00177
00179
00180 int Broadcast(int* data , int length, int root);
00181 int Broadcast(unsigned long* data, int length, int root);
00182 int Broadcast(char* data , int length, int root);
00183 int Broadcast(float* data , int length, int root);
00184 int Broadcast(double* data , int length, int root);
00186
00187
00189
00191 int Gather(int* data , int* to , int length, int root);
00192 int Gather(unsigned long* data, unsigned long* to, int length, int root);
00193 int Gather(char* data , char* to , int length, int root);
00194 int Gather(float* data , float* to , int length, int root);
00195 int Gather(double* data , double* to , int length, int root);
00197
00199
00206 int GatherV(int* data, int* to,
00207 int sendlength, int* recvlengths, int* offsets, int root);
00208 int GatherV(unsigned long* data, unsigned long* to,
00209 int sendlength, int* recvlengths, int* offsets, int root);
00210 int GatherV(char* data, char* to,
00211 int sendlength, int* recvlengths, int* offsets, int root);
00212 int GatherV(float* data, float* to,
00213 int sendlength, int* recvlengths, int* offsets, int root);
00214 int GatherV(double* data, double* to,
00215 int sendlength, int* recvlengths, int* offsets, int root);
00217
00219
00220 int ReduceMax(int* data, int* to, int size, int root);
00221 int ReduceMax(long* data, long* to, int size, int root);
00222 int ReduceMax(float* data, float* to, int size, int root);
00223 int ReduceMax(double* data, double* to, int size, int root);
00225
00226 int ReduceMin(int* data, int* to, int size, int root);
00227 int ReduceMin(long* data, long* to, int size, int root);
00228 int ReduceMin(float* data, float* to, int size, int root);
00229 int ReduceMin(double* data, double* to, int size, int root);
00230
00231 int ReduceSum(int* data, int* to, int size, int root);
00232 int ReduceSum(long* data, long* to, int size, int root);
00233 int ReduceSum(float* data, float* to, int size, int root);
00234 int ReduceSum(double* data, double* to, int size, int root);
00235
00236 int ReduceAnd(bool* data, bool* to, int size, int root);
00237 int ReduceOr(bool* data, bool* to, int size, int root);
00238
00239
00240
00241
00242 friend class vtkMPIController;
00243
00244 vtkMPICommunicatorOpaqueComm* GetMPIComm()
00245 {
00246 return this->Comm;
00247 }
00248
00249
00250
00251 static char* Allocate(size_t size);
00252 static void Free(char* ptr);
00253
00254
00255 protected:
00256 vtkMPICommunicator();
00257 ~vtkMPICommunicator();
00258
00259 virtual void SetGroup(vtkMPIGroup*);
00260
00262
00269 vtkSetMacro(KeepHandle, int);
00270 vtkBooleanMacro(KeepHandle, int);
00272
00273
00274 static vtkMPICommunicator* WorldCommunicator;
00275
00276 void InitializeCopy(vtkMPICommunicator* source);
00277
00282 void CopyFrom(vtkMPICommunicator* source);
00283
00290 void Duplicate(vtkMPICommunicator* source);
00291
00292 vtkMPICommunicatorOpaqueComm* Comm;
00293 vtkMPIGroup* Group;
00294
00295 int Initialized;
00296 int KeepHandle;
00297
00298 static int CheckForMPIError(int err);
00299
00300 private:
00301 vtkMPICommunicator(const vtkMPICommunicator&);
00302 void operator=(const vtkMPICommunicator&);
00303 };
00304
00305
00306 #endif // __vtkMPICommunicator_h
00307
00308
00309
00310