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 "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 //BTX 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 //ETX 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); 00129 #endif 00130 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 //BTX 00170 00171 friend class vtkMPIController; 00172 00173 vtkMPICommunicatorOpaqueComm *GetMPIComm() 00174 { 00175 return this->MPIComm; 00176 } 00177 //ETX 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 00192 00196 void CopyFrom(vtkMPICommunicator* source); 00197 protected: 00198 vtkMPICommunicator(); 00199 ~vtkMPICommunicator(); 00201 00202 // Obtain size and rank setting NumberOfProcesses and LocalProcessId Should 00203 // not be called if the current communicator does not include this process 00204 int InitializeNumberOfProcesses(); 00205 00207 00214 vtkSetMacro(KeepHandle, int); 00215 vtkBooleanMacro(KeepHandle, int); 00217 00218 00219 static vtkMPICommunicator* WorldCommunicator; 00220 00221 void InitializeCopy(vtkMPICommunicator* source); 00222 00229 void Duplicate(vtkMPICommunicator* source); 00230 00232 00233 virtual int ReceiveDataInternal( 00234 char* data, int length, int sizeoftype, 00235 int remoteProcessId, int tag, 00236 vtkMPICommunicatorReceiveDataInfo* info, 00237 int useCopy, int& senderId); 00239 00240 vtkMPICommunicatorOpaqueComm* MPIComm; 00241 00242 int Initialized; 00243 int KeepHandle; 00244 00245 int LastSenderId; 00246 int UseSsend; 00247 static int CheckForMPIError(int err); 00248 00249 private: 00250 vtkMPICommunicator(const vtkMPICommunicator&); // Not implemented. 00251 void operator=(const vtkMPICommunicator&); // Not implemented. 00252 }; 00253 00254 #endif