VTK
dox/Parallel/vtkMPIController.h
Go to the documentation of this file.
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 Initialize();
00085 
00088   virtual void Finalize() { this->Finalize(0); }
00089 
00090   virtual void Finalize(int finalizedExternally);
00091 
00094   virtual void SingleMethodExecute();
00095   
00099   virtual void MultipleMethodExecute();
00100 
00103   virtual void CreateOutputWindow();
00104 
00107   static char* ErrorString(int err);
00108 
00109 
00115   void SetCommunicator(vtkMPICommunicator* comm);
00116 
00117   virtual vtkMPIController *CreateSubController(vtkProcessGroup *group);
00118 
00119   virtual vtkMPIController *PartitionController(int localColor, int localKey);
00120 
00121 //BTX
00122 
00124 
00130   int NoBlockSend(const int* data, int length, int remoteProcessId, int tag,
00131                   vtkMPICommunicator::Request& req)
00132     { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend
00133         (data ,length, remoteProcessId, tag, req); }
00134   int NoBlockSend(const unsigned long* data, int length, int remoteProcessId,
00135                   int tag, vtkMPICommunicator::Request& req)
00136     { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend
00137         (data, length, remoteProcessId, tag, req); }
00138   int NoBlockSend(const char* data, int length, int remoteProcessId, 
00139                   int tag, vtkMPICommunicator::Request& req)
00140     { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend
00141         (data, length, remoteProcessId, tag, req); }
00142   int NoBlockSend(const float* data, int length, int remoteProcessId, 
00143                   int tag, vtkMPICommunicator::Request& req)
00144     { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend
00145         (data, length, remoteProcessId, tag, req); }
00146   int NoBlockSend(const double* data, int length, int remoteProcessId, 
00147                   int tag, vtkMPICommunicator::Request& req)
00148     { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend
00149         (data, length, remoteProcessId, tag, req); }
00151 
00153 
00158   int NoBlockReceive(int* data, int length, int remoteProcessId, 
00159                      int tag, vtkMPICommunicator::Request& req)
00160     { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
00161         (data, length, remoteProcessId, tag, req); }
00162   int NoBlockReceive(unsigned long* data, int length, 
00163                      int remoteProcessId, int tag, 
00164                      vtkMPICommunicator::Request& req)
00165     { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
00166         (data, length, remoteProcessId, tag, req); }
00167   int NoBlockReceive(char* data, int length, int remoteProcessId, 
00168                      int tag, vtkMPICommunicator::Request& req)
00169     { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
00170         (data, length, remoteProcessId, tag, req); }
00171   int NoBlockReceive(float* data, int length, int remoteProcessId, 
00172                      int tag, vtkMPICommunicator::Request& req)
00173     { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
00174         (data, length, remoteProcessId, tag, req); }
00175   int NoBlockReceive(double* data, int length, int remoteProcessId, 
00176                      int tag, vtkMPICommunicator::Request& req)
00177     { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
00178         (data, length, remoteProcessId, tag, req); }
00179 #ifdef VTK_USE_64BIT_IDS
00180   int NoBlockReceive(vtkIdType* data, int length, int remoteProcessId, 
00181                      int tag, vtkMPICommunicator::Request& req)
00182     { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
00183         (data, length, remoteProcessId, tag, req); }
00184 #endif
00185 
00186 
00188 
00195   int Iprobe(int source, int tag, int* flag, int* actualSource)
00196   { return ((vtkMPICommunicator*)this->Communicator)->Iprobe(
00197       source, tag, flag, actualSource); }
00198   int Iprobe(int source, int tag, int* flag, int* actualSource,
00199              int* type, int* size)
00200   { return ((vtkMPICommunicator*)this->Communicator)->Iprobe(
00201       source, tag, flag, actualSource, type, size); }
00202   int Iprobe(int source, int tag, int* flag, int* actualSource,
00203              unsigned long* type, int* size)
00204   { return ((vtkMPICommunicator*)this->Communicator)->Iprobe(
00205       source, tag, flag, actualSource, type, size); }
00206   int Iprobe(int source, int tag, int* flag, int* actualSource,
00207              const char* type, int* size)
00208   { return ((vtkMPICommunicator*)this->Communicator)->Iprobe(
00209       source, tag, flag, actualSource, type, size); }
00210   int Iprobe(int source, int tag, int* flag, int* actualSource,
00211              float* type, int* size)
00212   { return ((vtkMPICommunicator*)this->Communicator)->Iprobe(
00213       source, tag, flag, actualSource, type, size); }
00214   int Iprobe(int source, int tag, int* flag, int* actualSource,
00215              double* type, int* size)
00216   { return ((vtkMPICommunicator*)this->Communicator)->Iprobe(
00217       source, tag, flag, actualSource, type, size); }
00219 
00220 //ETX
00221 
00222   static const char* GetProcessorName();
00223 
00225 
00227   static void SetUseSsendForRMI(int use_send)
00228     { vtkMPIController::UseSsendForRMI = (use_send != 0)? 1: 0; }
00229   static int GetUseSsendForRMI() { return vtkMPIController::UseSsendForRMI; }
00230 //BTX
00231 protected:
00232   vtkMPIController();
00233   ~vtkMPIController();
00235 
00236   // Set the communicator to comm and call InitializeNumberOfProcesses()
00237   void InitializeCommunicator(vtkMPICommunicator* comm);
00238 
00239   // Duplicate the current communicator, creating RMICommunicator
00240   void InitializeRMICommunicator();
00241 
00243 
00246   virtual void TriggerRMIInternal(int remoteProcessId, 
00247     void* arg, int argLength, int rmiTag, bool propagate);
00249 
00250   // MPI communicator created when Initialize() called.
00251   // This is a copy of MPI_COMM_WORLD but uses a new
00252   // context, i.e. even if the tags are the same, the
00253   // RMI messages will not interfere with user level
00254   // messages.
00255   static vtkMPICommunicator* WorldRMICommunicator;
00256 
00257   friend class vtkMPIOutputWindow;
00258 
00259   // Initialize only once.
00260   static int Initialized;
00261 
00262   static char ProcessorName[];
00263 
00265 
00266   static int UseSsendForRMI;
00267 private:
00268   vtkMPIController(const vtkMPIController&);  // Not implemented.
00269   void operator=(const vtkMPIController&);  // Not implemented.
00270 //ETX
00271 };
00273 
00274 
00275 #endif
00276 
00277