VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkMPICommunicator.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00038 #ifndef vtkMPICommunicator_h 00039 #define vtkMPICommunicator_h 00040 00041 #include "vtkParallelMPIModule.h" // For export macro 00042 #include "vtkCommunicator.h" 00043 00044 class vtkMPIController; 00045 class vtkProcessGroup; 00046 00047 class vtkMPICommunicatorOpaqueComm; 00048 class vtkMPICommunicatorOpaqueRequest; 00049 class vtkMPICommunicatorReceiveDataInfo; 00050 00051 class VTKPARALLELMPI_EXPORT vtkMPICommunicator : public vtkCommunicator 00052 { 00053 public: 00054 //BTX 00055 00056 class VTKPARALLELMPI_EXPORT Request 00057 { 00058 public: 00059 Request(); 00060 Request( const Request& ); 00061 ~Request(); 00062 Request& operator = ( const Request& ); 00063 int Test(); 00064 void Cancel(); 00065 void Wait(); 00066 vtkMPICommunicatorOpaqueRequest* Req; 00067 }; 00068 00069 //ETX 00070 00071 vtkTypeMacro( vtkMPICommunicator,vtkCommunicator); 00072 void PrintSelf(ostream& os, vtkIndent indent); 00073 00075 static vtkMPICommunicator* New(); 00076 00079 static vtkMPICommunicator* GetWorldCommunicator(); 00080 00081 00085 int Initialize(vtkProcessGroup *group); 00086 00090 int SplitInitialize(vtkCommunicator *oldcomm, int color, int key); 00091 00093 00096 virtual int SendVoidArray(const void *data, vtkIdType length, int type, 00097 int remoteProcessId, int tag); 00098 virtual int ReceiveVoidArray(void *data, vtkIdType length, int type, 00099 int remoteProcessId, int tag); 00101 00103 00108 int NoBlockSend(const int* data, int length, int remoteProcessId, int tag, 00109 Request& req); 00110 int NoBlockSend(const unsigned long* data, int length, int remoteProcessId, 00111 int tag, Request& req); 00112 int NoBlockSend(const char* data, int length, int remoteProcessId, 00113 int tag, Request& req); 00114 int NoBlockSend(const unsigned char* data, int length, int remoteProcessId, 00115 int tag, Request& req); 00116 int NoBlockSend(const float* data, int length, int remoteProcessId, 00117 int tag, Request& req); 00118 int NoBlockSend(const double* data, int length, int remoteProcessId, 00119 int tag, Request& req); 00120 #ifdef VTK_USE_64BIT_IDS 00121 int NoBlockSend(const vtkIdType* data, int length, int remoteProcessId, 00122 int tag, Request& req); 00123 #endif 00124 00125 00127 00131 int NoBlockReceive(int* data, int length, int remoteProcessId, 00132 int tag, Request& req); 00133 int NoBlockReceive(unsigned long* data, int length, 00134 int remoteProcessId, int tag, Request& req); 00135 int NoBlockReceive(char* data, int length, int remoteProcessId, 00136 int tag, Request& req); 00137 int NoBlockReceive(unsigned char* data, int length, int remoteProcessId, 00138 int tag, Request& req); 00139 int NoBlockReceive(float* data, int length, int remoteProcessId, 00140 int tag, Request& req); 00141 int NoBlockReceive(double* data, int length, int remoteProcessId, 00142 int tag, Request& req); 00143 #ifdef VTK_USE_64BIT_IDS 00144 int NoBlockReceive(vtkIdType* data, int length, int remoteProcessId, 00145 int tag, Request& req); 00146 #endif 00147 00148 00149 00151 00154 virtual void Barrier(); 00155 virtual int BroadcastVoidArray(void *data, vtkIdType length, int type, 00156 int srcProcessId); 00157 virtual int GatherVoidArray(const void *sendBuffer, void *recvBuffer, 00158 vtkIdType length, int type, int destProcessId); 00159 virtual int GatherVVoidArray(const void *sendBuffer, void *recvBuffer, 00160 vtkIdType sendLength, vtkIdType *recvLengths, 00161 vtkIdType *offsets, int type, int destProcessId); 00162 virtual int ScatterVoidArray(const void *sendBuffer, void *recvBuffer, 00163 vtkIdType length, int type, int srcProcessId); 00164 virtual int ScatterVVoidArray(const void *sendBuffer, void *recvBuffer, 00165 vtkIdType *sendLengths, vtkIdType *offsets, 00166 vtkIdType recvLength, int type, 00167 int srcProcessId); 00168 virtual int AllGatherVoidArray(const void *sendBuffer, void *recvBuffer, 00169 vtkIdType length, int type); 00170 virtual int AllGatherVVoidArray(const void *sendBuffer, void *recvBuffer, 00171 vtkIdType sendLength, vtkIdType *recvLengths, 00172 vtkIdType *offsets, int type); 00173 virtual int ReduceVoidArray(const void *sendBuffer, void *recvBuffer, 00174 vtkIdType length, int type, 00175 int operation, int destProcessId); 00176 virtual int ReduceVoidArray(const void *sendBuffer, void *recvBuffer, 00177 vtkIdType length, int type, 00178 Operation *operation, int destProcessId); 00179 virtual int AllReduceVoidArray(const void *sendBuffer, void *recvBuffer, 00180 vtkIdType length, int type, 00181 int operation); 00182 virtual int AllReduceVoidArray(const void *sendBuffer, void *recvBuffer, 00183 vtkIdType length, int type, 00184 Operation *operation); 00186 00188 00195 int Iprobe(int source, int tag, int* flag, int* actualSource); 00196 int Iprobe(int source, int tag, int* flag, int* actualSource, 00197 int* type, int* size); 00198 int Iprobe(int source, int tag, int* flag, int* actualSource, 00199 unsigned long* type, int* size); 00200 int Iprobe(int source, int tag, int* flag, int* actualSource, 00201 const char* type, int* size); 00202 int Iprobe(int source, int tag, int* flag, int* actualSource, 00203 float* type, int* size); 00204 int Iprobe(int source, int tag, int* flag, int* actualSource, 00205 double* type, int* size); 00207 00210 int WaitAll(const int count, Request requests[]); 00211 00215 int WaitAny(const int count, Request requests[], int& idx); 00216 00218 00221 int WaitSome( 00222 const int count, Request requests[], int &NCompleted, int *completed ); 00224 00228 int TestAll( const int count, Request requests[], int& flag ); 00229 00231 int TestAny(const int count, Request requests[], int &idx, int &flag ); 00232 00234 00238 int TestSome(const int count,Request requests[], 00239 int& NCompleted,int *completed); 00240 //BTX 00242 00243 friend class vtkMPIController; 00244 00245 vtkMPICommunicatorOpaqueComm *GetMPIComm() 00246 { 00247 return this->MPIComm; 00248 } 00249 00250 int InitializeExternal(vtkMPICommunicatorOpaqueComm *comm); 00251 00252 //ETX 00253 00254 static char* Allocate(size_t size); 00255 static void Free(char* ptr); 00256 00257 00259 00261 vtkSetClampMacro(UseSsend, int, 0, 1); 00262 vtkGetMacro(UseSsend, int); 00263 vtkBooleanMacro(UseSsend, int); 00265 00267 00271 void CopyFrom(vtkMPICommunicator* source); 00272 protected: 00273 vtkMPICommunicator(); 00274 ~vtkMPICommunicator(); 00276 00277 // Obtain size and rank setting NumberOfProcesses and LocalProcessId Should 00278 // not be called if the current communicator does not include this process 00279 int InitializeNumberOfProcesses(); 00280 00282 00289 vtkSetMacro(KeepHandle, int); 00290 vtkBooleanMacro(KeepHandle, int); 00292 00293 00294 static vtkMPICommunicator* WorldCommunicator; 00295 00296 void InitializeCopy(vtkMPICommunicator* source); 00297 00304 void Duplicate(vtkMPICommunicator* source); 00305 00307 00308 virtual int ReceiveDataInternal( 00309 char* data, int length, int sizeoftype, 00310 int remoteProcessId, int tag, 00311 vtkMPICommunicatorReceiveDataInfo* info, 00312 int useCopy, int& senderId); 00314 00315 vtkMPICommunicatorOpaqueComm* MPIComm; 00316 00317 int Initialized; 00318 int KeepHandle; 00319 00320 int LastSenderId; 00321 int UseSsend; 00322 static int CheckForMPIError(int err); 00323 00324 private: 00325 vtkMPICommunicator(const vtkMPICommunicator&); // Not implemented. 00326 void operator=(const vtkMPICommunicator&); // Not implemented. 00327 }; 00328 00329 #endif