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 vtkProcessGroup;
00045
00046 class vtkMPICommunicatorOpaqueComm;
00047 class vtkMPICommunicatorOpaqueRequest;
00048 class vtkMPICommunicatorReceiveDataInfo;
00049
00050 class VTK_PARALLEL_EXPORT vtkMPICommunicator : public vtkCommunicator
00051 {
00052 public:
00053
00054
00055 class VTK_PARALLEL_EXPORT Request
00056 {
00057 public:
00058 Request();
00059 Request( const Request& );
00060 ~Request();
00061 Request& operator = ( const Request& );
00062 int Test();
00063 void Cancel();
00064 void Wait();
00065 vtkMPICommunicatorOpaqueRequest* Req;
00066 };
00067
00068
00069
00070 vtkTypeMacro( vtkMPICommunicator,vtkCommunicator);
00071 void PrintSelf(ostream& os, vtkIndent indent);
00072
00074 static vtkMPICommunicator* New();
00075
00078 static vtkMPICommunicator* GetWorldCommunicator();
00079
00080
00084 int Initialize(vtkProcessGroup *group);
00085
00088 int SplitInitialize(vtkCommunicator *oldcomm, int color, int key);
00089
00091
00093 virtual int SendVoidArray(const void *data, vtkIdType length, int type,
00094 int remoteProcessId, int tag);
00095 virtual int ReceiveVoidArray(void *data, vtkIdType length, int type,
00096 int remoteProcessId, int tag);
00098
00100
00104 int NoBlockSend(const int* data, int length, int remoteProcessId, int tag,
00105 Request& req);
00106 int NoBlockSend(const unsigned long* data, int length, int remoteProcessId,
00107 int tag, Request& req);
00108 int NoBlockSend(const char* data, int length, int remoteProcessId,
00109 int tag, Request& req);
00110 int NoBlockSend(const float* data, int length, int remoteProcessId,
00111 int tag, Request& req);
00113
00115
00118 int NoBlockReceive(int* data, int length, int remoteProcessId,
00119 int tag, Request& req);
00120 int NoBlockReceive(unsigned long* data, int length,
00121 int remoteProcessId, int tag, Request& req);
00122 int NoBlockReceive(char* data, int length, int remoteProcessId,
00123 int tag, Request& req);
00124 int NoBlockReceive(float* data, int length, int remoteProcessId,
00125 int tag, Request& req);
00126 #ifdef VTK_USE_64BIT_IDS
00127 int NoBlockReceive(vtkIdType* data, int length, int remoteProcessId,
00128 int tag, Request& req);
00130 #endif
00131
00132
00134
00136 virtual void Barrier();
00137 virtual int BroadcastVoidArray(void *data, vtkIdType length, int type,
00138 int srcProcessId);
00139 virtual int GatherVoidArray(const void *sendBuffer, void *recvBuffer,
00140 vtkIdType length, int type, int destProcessId);
00141 virtual int GatherVVoidArray(const void *sendBuffer, void *recvBuffer,
00142 vtkIdType sendLength, vtkIdType *recvLengths,
00143 vtkIdType *offsets, int type, int destProcessId);
00144 virtual int ScatterVoidArray(const void *sendBuffer, void *recvBuffer,
00145 vtkIdType length, int type, int srcProcessId);
00146 virtual int ScatterVVoidArray(const void *sendBuffer, void *recvBuffer,
00147 vtkIdType *sendLengths, vtkIdType *offsets,
00148 vtkIdType recvLength, int type,
00149 int srcProcessId);
00150 virtual int AllGatherVoidArray(const void *sendBuffer, void *recvBuffer,
00151 vtkIdType length, int type);
00152 virtual int AllGatherVVoidArray(const void *sendBuffer, void *recvBuffer,
00153 vtkIdType sendLength, vtkIdType *recvLengths,
00154 vtkIdType *offsets, int type);
00155 virtual int ReduceVoidArray(const void *sendBuffer, void *recvBuffer,
00156 vtkIdType length, int type,
00157 int operation, int destProcessId);
00158 virtual int ReduceVoidArray(const void *sendBuffer, void *recvBuffer,
00159 vtkIdType length, int type,
00160 Operation *operation, int destProcessId);
00161 virtual int AllReduceVoidArray(const void *sendBuffer, void *recvBuffer,
00162 vtkIdType length, int type,
00163 int operation);
00164 virtual int AllReduceVoidArray(const void *sendBuffer, void *recvBuffer,
00165 vtkIdType length, int type,
00166 Operation *operation);
00168
00169
00170
00171 friend class vtkMPIController;
00172
00173 vtkMPICommunicatorOpaqueComm *GetMPIComm()
00174 {
00175 return this->MPIComm;
00176 }
00177
00178
00179 static char* Allocate(size_t size);
00180 static void Free(char* ptr);
00181
00182
00184
00186 vtkSetClampMacro(UseSsend, int, 0, 1);
00187 vtkGetMacro(UseSsend, int);
00188 vtkBooleanMacro(UseSsend, int);
00190
00195 void CopyFrom(vtkMPICommunicator* source);
00196 protected:
00197 vtkMPICommunicator();
00198 ~vtkMPICommunicator();
00199
00200
00201
00202 int InitializeNumberOfProcesses();
00203
00205
00212 vtkSetMacro(KeepHandle, int);
00213 vtkBooleanMacro(KeepHandle, int);
00215
00216
00217 static vtkMPICommunicator* WorldCommunicator;
00218
00219 void InitializeCopy(vtkMPICommunicator* source);
00220
00227 void Duplicate(vtkMPICommunicator* source);
00228
00230
00231 virtual int ReceiveDataInternal(
00232 char* data, int length, int sizeoftype,
00233 int remoteProcessId, int tag,
00234 vtkMPICommunicatorReceiveDataInfo* info,
00235 int useCopy, int& senderId);
00237
00238 vtkMPICommunicatorOpaqueComm* MPIComm;
00239
00240 int Initialized;
00241 int KeepHandle;
00242
00243 int LastSenderId;
00244 int UseSsend;
00245 static int CheckForMPIError(int err);
00246
00247 private:
00248 vtkMPICommunicator(const vtkMPICommunicator&);
00249 void operator=(const vtkMPICommunicator&);
00250 };
00251
00252 #endif