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 "vtkMultiProcessController.h" 00052 // Do not remove this header file. This class contains methods 00053 // which take arguments defined in vtkMPICommunicator.h by 00054 // reference. 00055 #include "vtkMPICommunicator.h" // Needed for direct access to communicator 00056 00057 class VTK_PARALLEL_EXPORT vtkMPIController : public vtkMultiProcessController 00058 { 00059 00060 public: 00061 00062 static vtkMPIController *New(); 00063 vtkTypeMacro(vtkMPIController,vtkMultiProcessController); 00064 void PrintSelf(ostream& os, vtkIndent indent); 00065 00067 00075 virtual void Initialize(int* argc, char*** argv) 00076 { this->Initialize(argc, argv, 0); } 00078 00079 virtual void Initialize(int* vtkNotUsed(argc), char*** vtkNotUsed(argv), 00080 int initializedExternally); 00081 00084 virtual void Finalize() { this->Finalize(0); } 00085 00086 virtual void Finalize(int finalizedExternally); 00087 00090 virtual void SingleMethodExecute(); 00091 00095 virtual void MultipleMethodExecute(); 00096 00099 virtual void CreateOutputWindow(); 00100 00103 static char* ErrorString(int err); 00104 00105 00111 void SetCommunicator(vtkMPICommunicator* comm); 00112 00113 virtual vtkMPIController *CreateSubController(vtkProcessGroup *group); 00114 00115 virtual vtkMPIController *PartitionController(int localColor, int localKey); 00116 00117 //BTX 00118 00120 00125 int NoBlockSend(const int* data, int length, int remoteProcessId, int tag, 00126 vtkMPICommunicator::Request& req) 00127 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend 00128 (data ,length, remoteProcessId, tag, req); } 00129 int NoBlockSend(const unsigned long* data, int length, int remoteProcessId, 00130 int tag, vtkMPICommunicator::Request& req) 00131 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend 00132 (data, length, remoteProcessId, tag, req); } 00133 int NoBlockSend(const char* data, int length, int remoteProcessId, 00134 int tag, vtkMPICommunicator::Request& req) 00135 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend 00136 (data, length, remoteProcessId, tag, req); } 00137 int NoBlockSend(const float* data, int length, int remoteProcessId, 00138 int tag, vtkMPICommunicator::Request& req) 00139 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend 00140 (data, length, remoteProcessId, tag, req); } 00142 00144 00148 int NoBlockReceive(int* data, int length, int remoteProcessId, 00149 int tag, vtkMPICommunicator::Request& req) 00150 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive 00151 (data, length, remoteProcessId, tag, req); } 00152 int NoBlockReceive(unsigned long* data, int length, 00153 int remoteProcessId, int tag, 00154 vtkMPICommunicator::Request& req) 00155 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive 00156 (data, length, remoteProcessId, tag, req); } 00157 int NoBlockReceive(char* data, int length, int remoteProcessId, 00158 int tag, vtkMPICommunicator::Request& req) 00159 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive 00160 (data, length, remoteProcessId, tag, req); } 00161 int NoBlockReceive(float* data, int length, int remoteProcessId, 00162 int tag, vtkMPICommunicator::Request& req) 00163 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive 00164 (data, length, remoteProcessId, tag, req); } 00165 #ifdef VTK_USE_64BIT_IDS 00166 int NoBlockReceive(vtkIdType* data, int length, int remoteProcessId, 00167 int tag, vtkMPICommunicator::Request& req) 00168 { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive 00169 (data, length, remoteProcessId, tag, req); } 00171 #endif 00172 00173 //ETX 00174 00175 static const char* GetProcessorName(); 00176 00178 00180 static void SetUseSsendForRMI(int use_send) 00181 { vtkMPIController::UseSsendForRMI = (use_send != 0)? 1: 0; } 00182 static int GetUseSsendForRMI() { return vtkMPIController::UseSsendForRMI; } 00184 //BTX 00185 protected: 00186 vtkMPIController(); 00187 ~vtkMPIController(); 00188 00189 // Set the communicator to comm and call InitializeNumberOfProcesses() 00190 void InitializeCommunicator(vtkMPICommunicator* comm); 00191 00192 // Duplicate the current communicator, creating RMICommunicator 00193 void InitializeRMICommunicator(); 00194 00196 00199 virtual void TriggerRMIInternal(int remoteProcessId, 00200 void* arg, int argLength, int rmiTag, bool propagate); 00202 00203 // MPI communicator created when Initialize() called. 00204 // This is a copy of MPI_COMM_WORLD but uses a new 00205 // context, i.e. even if the tags are the same, the 00206 // RMI messages will not interfere with user level 00207 // messages. 00208 static vtkMPICommunicator* WorldRMICommunicator; 00209 00210 friend class vtkMPIOutputWindow; 00211 00212 // Initialize only once. 00213 static int Initialized; 00214 00215 static char ProcessorName[]; 00216 00218 static int UseSsendForRMI; 00219 private: 00220 vtkMPIController(const vtkMPIController&); // Not implemented. 00221 void operator=(const vtkMPIController&); // Not implemented. 00222 //ETX 00223 }; 00224 00225 00226 #endif 00227 00228