VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkMPIController.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 =========================================================================*/ 00048 #ifndef __vtkMPIController_h 00049 #define __vtkMPIController_h 00050 00051 #include "vtkParallelMPIModule.h" // For export macro 00052 #include "vtkMultiProcessController.h" 00053 // Do not remove this header file. This class contains methods 00054 // which take arguments defined in vtkMPICommunicator.h by 00055 // reference. 00056 #include "vtkMPICommunicator.h" // Needed for direct access to communicator 00057 00058 class vtkIntArray; 00059 00060 class VTKPARALLELMPI_EXPORT vtkMPIController : public vtkMultiProcessController 00061 { 00062 00063 public: 00064 00065 static vtkMPIController *New(); 00066 vtkTypeMacro(vtkMPIController,vtkMultiProcessController); 00067 void PrintSelf(ostream& os, vtkIndent indent); 00068 00070 00078 virtual void Initialize(int* argc, char*** argv) 00079 { this->Initialize(argc, argv, 0); } 00081 00082 virtual void Initialize(int* vtkNotUsed(argc), char*** vtkNotUsed(argv), 00083 int initializedExternally); 00084 00087 virtual void Initialize(); 00088 00091 virtual void Finalize() { this->Finalize(0); } 00092 00093 virtual void Finalize(int finalizedExternally); 00094 00097 virtual void SingleMethodExecute(); 00098 00102 virtual void MultipleMethodExecute(); 00103 00106 virtual void CreateOutputWindow(); 00107 00110 static char* ErrorString(int err); 00111 00112 00118 void SetCommunicator(vtkMPICommunicator* comm); 00119 00120 virtual vtkMPIController *CreateSubController(vtkProcessGroup *group); 00121 00122 virtual vtkMPIController *PartitionController(int localColor, int localKey); 00123 00124 //BTX 00125 00127 00133 int NoBlockSend(const int* data, int length, int remoteProcessId, int tag, 00134 vtkMPICommunicator::Request& req) 00135 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend 00136 (data ,length, remoteProcessId, tag, req); } 00137 int NoBlockSend(const unsigned long* data, int length, int remoteProcessId, 00138 int tag, vtkMPICommunicator::Request& req) 00139 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend 00140 (data, length, remoteProcessId, tag, req); } 00141 int NoBlockSend(const char* data, int length, int remoteProcessId, 00142 int tag, vtkMPICommunicator::Request& req) 00143 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend 00144 (data, length, remoteProcessId, tag, req); } 00145 int NoBlockSend( const unsigned char* data, int length, int remoteProcessId, 00146 int tag, vtkMPICommunicator::Request& req ) 00147 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend 00148 (data, length, remoteProcessId, tag, req);} 00149 int NoBlockSend(const float* data, int length, int remoteProcessId, 00150 int tag, vtkMPICommunicator::Request& req) 00151 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend 00152 (data, length, remoteProcessId, tag, req); } 00153 int NoBlockSend(const double* data, int length, int remoteProcessId, 00154 int tag, vtkMPICommunicator::Request& req) 00155 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend 00156 (data, length, remoteProcessId, tag, req); } 00158 00160 00165 int NoBlockReceive(int* data, int length, int remoteProcessId, 00166 int tag, vtkMPICommunicator::Request& req) 00167 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive 00168 (data, length, remoteProcessId, tag, req); } 00169 int NoBlockReceive(unsigned long* data, int length, 00170 int remoteProcessId, int tag, 00171 vtkMPICommunicator::Request& req) 00172 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive 00173 (data, length, remoteProcessId, tag, req); } 00174 int NoBlockReceive(char* data, int length, int remoteProcessId, 00175 int tag, vtkMPICommunicator::Request& req) 00176 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive 00177 (data, length, remoteProcessId, tag, req); } 00178 int NoBlockReceive(unsigned char* data, int length, int remoteProcessId, 00179 int tag, vtkMPICommunicator::Request& req) 00180 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive 00181 (data, length, remoteProcessId, tag, req); } 00182 int NoBlockReceive(float* data, int length, int remoteProcessId, 00183 int tag, vtkMPICommunicator::Request& req) 00184 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive 00185 (data, length, remoteProcessId, tag, req); } 00186 int NoBlockReceive(double* data, int length, int remoteProcessId, 00187 int tag, vtkMPICommunicator::Request& req) 00188 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive 00189 (data, length, remoteProcessId, tag, req); } 00190 #ifdef VTK_USE_64BIT_IDS 00191 int NoBlockReceive(vtkIdType* data, int length, int remoteProcessId, 00192 int tag, vtkMPICommunicator::Request& req) 00193 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive 00194 (data, length, remoteProcessId, tag, req); } 00195 #endif 00196 00197 00199 00206 int Iprobe(int source, int tag, int* flag, int* actualSource) 00207 { return ((vtkMPICommunicator*)this->Communicator)->Iprobe( 00208 source, tag, flag, actualSource); } 00209 int Iprobe(int source, int tag, int* flag, int* actualSource, 00210 int* type, int* size) 00211 { return ((vtkMPICommunicator*)this->Communicator)->Iprobe( 00212 source, tag, flag, actualSource, type, size); } 00213 int Iprobe(int source, int tag, int* flag, int* actualSource, 00214 unsigned long* type, int* size) 00215 { return ((vtkMPICommunicator*)this->Communicator)->Iprobe( 00216 source, tag, flag, actualSource, type, size); } 00217 int Iprobe(int source, int tag, int* flag, int* actualSource, 00218 const char* type, int* size) 00219 { return ((vtkMPICommunicator*)this->Communicator)->Iprobe( 00220 source, tag, flag, actualSource, type, size); } 00221 int Iprobe(int source, int tag, int* flag, int* actualSource, 00222 float* type, int* size) 00223 { return ((vtkMPICommunicator*)this->Communicator)->Iprobe( 00224 source, tag, flag, actualSource, type, size); } 00225 int Iprobe(int source, int tag, int* flag, int* actualSource, 00226 double* type, int* size) 00227 { return ((vtkMPICommunicator*)this->Communicator)->Iprobe( 00228 source, tag, flag, actualSource, type, size); } 00230 00232 00235 int WaitAll(const int count, vtkMPICommunicator::Request requests[]) 00236 { return ((vtkMPICommunicator*)this->Communicator)->WaitAll(count,requests);} 00238 00240 00244 int WaitAny(const int count,vtkMPICommunicator::Request requests[], int& idx) 00245 {return ((vtkMPICommunicator*)this->Communicator)->WaitAny(count,requests,idx);} 00247 00249 00252 int WaitSome( 00253 const int count, vtkMPICommunicator::Request requests[], 00254 vtkIntArray *completed ); 00256 00259 bool TestAll(const int count, vtkMPICommunicator::Request requests[] ); 00260 00265 bool TestAny(const int count,vtkMPICommunicator::Request requests[],int &idx); 00266 00268 00271 bool TestSome(const int count,vtkMPICommunicator::Request requests[], 00272 vtkIntArray *completed ); 00273 //ETX 00274 static const char* GetProcessorName(); 00276 00278 00280 static void SetUseSsendForRMI(int use_send) 00281 { vtkMPIController::UseSsendForRMI = (use_send != 0)? 1: 0; } 00282 static int GetUseSsendForRMI() { return vtkMPIController::UseSsendForRMI; } 00283 //BTX 00284 protected: 00285 vtkMPIController(); 00286 ~vtkMPIController(); 00288 00289 // Set the communicator to comm and call InitializeNumberOfProcesses() 00290 void InitializeCommunicator(vtkMPICommunicator* comm); 00291 00292 // Duplicate the current communicator, creating RMICommunicator 00293 void InitializeRMICommunicator(); 00294 00296 00299 virtual void TriggerRMIInternal(int remoteProcessId, 00300 void* arg, int argLength, int rmiTag, bool propagate); 00302 00303 // MPI communicator created when Initialize() called. 00304 // This is a copy of MPI_COMM_WORLD but uses a new 00305 // context, i.e. even if the tags are the same, the 00306 // RMI messages will not interfere with user level 00307 // messages. 00308 static vtkMPICommunicator* WorldRMICommunicator; 00309 00310 friend class vtkMPIOutputWindow; 00311 00312 // Initialize only once. 00313 static int Initialized; 00314 00315 static char ProcessorName[]; 00316 00318 00319 static int UseSsendForRMI; 00320 private: 00321 vtkMPIController(const vtkMPIController&); // Not implemented. 00322 void operator=(const vtkMPIController&); // Not implemented. 00323 //ETX 00324 }; 00326 00327 00328 #endif 00329 00330