VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Parallel/MPI/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 "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); }
00157 #ifdef VTK_USE_64BIT_IDS
00158   int NoBlockSend(const vtkIdType* data, int length, int remoteProcessId,
00159                   int tag, vtkMPICommunicator::Request& req)
00160     { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend
00161         (data, length, remoteProcessId, tag, req); }
00162 #endif
00163 
00164 
00166 
00171   int NoBlockReceive(int* 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(unsigned long* data, int length,
00176                      int remoteProcessId, int tag,
00177                      vtkMPICommunicator::Request& req)
00178     { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
00179         (data, length, remoteProcessId, tag, req); }
00180   int NoBlockReceive(char* data, int length, int remoteProcessId,
00181                      int tag, vtkMPICommunicator::Request& req)
00182     { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
00183         (data, length, remoteProcessId, tag, req); }
00184   int NoBlockReceive(unsigned char* data, int length, int remoteProcessId,
00185                        int tag, vtkMPICommunicator::Request& req)
00186       { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
00187           (data, length, remoteProcessId, tag, req); }
00188   int NoBlockReceive(float* data, int length, int remoteProcessId,
00189                      int tag, vtkMPICommunicator::Request& req)
00190     { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
00191         (data, length, remoteProcessId, tag, req); }
00192   int NoBlockReceive(double* data, int length, int remoteProcessId,
00193                      int tag, vtkMPICommunicator::Request& req)
00194     { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
00195         (data, length, remoteProcessId, tag, req); }
00196 #ifdef VTK_USE_64BIT_IDS
00197   int NoBlockReceive(vtkIdType* data, int length, int remoteProcessId,
00198                      int tag, vtkMPICommunicator::Request& req)
00199     { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
00200         (data, length, remoteProcessId, tag, req); }
00201 #endif
00202 
00203 
00205 
00212   int Iprobe(int source, int tag, int* flag, int* actualSource)
00213   { return ((vtkMPICommunicator*)this->Communicator)->Iprobe(
00214       source, tag, flag, actualSource); }
00215   int Iprobe(int source, int tag, int* flag, int* actualSource,
00216              int* type, int* size)
00217   { return ((vtkMPICommunicator*)this->Communicator)->Iprobe(
00218       source, tag, flag, actualSource, type, size); }
00219   int Iprobe(int source, int tag, int* flag, int* actualSource,
00220              unsigned long* type, int* size)
00221   { return ((vtkMPICommunicator*)this->Communicator)->Iprobe(
00222       source, tag, flag, actualSource, type, size); }
00223   int Iprobe(int source, int tag, int* flag, int* actualSource,
00224              const char* type, int* size)
00225   { return ((vtkMPICommunicator*)this->Communicator)->Iprobe(
00226       source, tag, flag, actualSource, type, size); }
00227   int Iprobe(int source, int tag, int* flag, int* actualSource,
00228              float* type, int* size)
00229   { return ((vtkMPICommunicator*)this->Communicator)->Iprobe(
00230       source, tag, flag, actualSource, type, size); }
00231   int Iprobe(int source, int tag, int* flag, int* actualSource,
00232              double* type, int* size)
00233   { return ((vtkMPICommunicator*)this->Communicator)->Iprobe(
00234       source, tag, flag, actualSource, type, size); }
00236 
00238 
00241   int WaitAll(const int count, vtkMPICommunicator::Request requests[])
00242   { return ((vtkMPICommunicator*)this->Communicator)->WaitAll(count,requests);}
00244 
00246 
00250   int WaitAny(const int count,vtkMPICommunicator::Request requests[], int& idx)
00251   {return ((vtkMPICommunicator*)this->Communicator)->WaitAny(count,requests,idx);}
00253 
00255 
00258   int WaitSome(
00259       const int count, vtkMPICommunicator::Request requests[],
00260       vtkIntArray *completed );
00262 
00265   bool TestAll(const int count, vtkMPICommunicator::Request requests[] );
00266 
00271   bool TestAny(const int count,vtkMPICommunicator::Request requests[],int &idx);
00272 
00274 
00277   bool TestSome(const int count,vtkMPICommunicator::Request requests[],
00278                 vtkIntArray *completed );
00279 //ETX
00280   static const char* GetProcessorName();
00282 
00284 
00286   static void SetUseSsendForRMI(int use_send)
00287     { vtkMPIController::UseSsendForRMI = (use_send != 0)? 1: 0; }
00288   static int GetUseSsendForRMI() { return vtkMPIController::UseSsendForRMI; }
00289 //BTX
00290 protected:
00291   vtkMPIController();
00292   ~vtkMPIController();
00294 
00295   // Set the communicator to comm and call InitializeNumberOfProcesses()
00296   void InitializeCommunicator(vtkMPICommunicator* comm);
00297 
00298   // Duplicate the current communicator, creating RMICommunicator
00299   void InitializeRMICommunicator();
00300 
00302 
00305   virtual void TriggerRMIInternal(int remoteProcessId,
00306     void* arg, int argLength, int rmiTag, bool propagate);
00308 
00309   // MPI communicator created when Initialize() called.
00310   // This is a copy of MPI_COMM_WORLD but uses a new
00311   // context, i.e. even if the tags are the same, the
00312   // RMI messages will not interfere with user level
00313   // messages.
00314   static vtkMPICommunicator* WorldRMICommunicator;
00315 
00316   friend class vtkMPIOutputWindow;
00317 
00318   // Initialize only once.
00319   static int Initialized;
00320 
00321   static char ProcessorName[];
00322 
00324 
00325   static int UseSsendForRMI;
00326 private:
00327   vtkMPIController(const vtkMPIController&);  // Not implemented.
00328   void operator=(const vtkMPIController&);  // Not implemented.
00329 //ETX
00330 };
00332 
00333 
00334 #endif
00335 
00336