Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkMPICommunicator.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkMPICommunicator.h,v $
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 =========================================================================*/
00051 #ifndef __vtkMPICommunicator_h
00052 #define __vtkMPICommunicator_h
00053 
00054 #include "vtkCommunicator.h"
00055 
00056 class vtkMPIController;
00057 class vtkMPIGroup;
00058 
00059 class vtkMPICommunicatorOpaqueRequest;
00060 class vtkMPICommunicatorOpaqueComm;
00061 
00062 class VTK_PARALLEL_EXPORT vtkMPICommunicator : public vtkCommunicator
00063 {
00064 public:
00065   vtkTypeRevisionMacro( vtkMPICommunicator,vtkCommunicator);
00066   
00068   static vtkMPICommunicator* New();
00069 
00072   static vtkMPICommunicator* GetWorldCommunicator();
00073   
00074   virtual void PrintSelf(ostream& os, vtkIndent indent);
00075 
00080   int Initialize(vtkMPICommunicator* mpiComm, vtkMPIGroup* group);
00081 
00083 
00085   virtual int Send(int* data, int length, int remoteProcessId, int tag);
00086   virtual int Send(unsigned long* data, int length, int remoteProcessId,
00087                    int tag);
00088   virtual int Send(char* data, int length, int remoteProcessId, int tag);
00089   virtual int Send(unsigned char* data, int length, int remoteProcessId, 
00090                    int tag);
00091   virtual int Send(float* data, int length, int remoteProcessId, 
00092                    int tag);
00093   virtual int Send(double* data, int length, int remoteProcessId, 
00094                    int tag);
00095 #ifdef VTK_USE_64BIT_IDS
00096   virtual int Send(vtkIdType* data, int length, int remoteProcessId, 
00097                    int tag);
00099 #endif
00100   virtual int Send(vtkDataObject* data, int remoteProcessId, int tag)
00101     { return this->vtkCommunicator::Send(data, remoteProcessId, tag); }
00102   virtual int Send(vtkDataArray* data, int remoteProcessId, int tag)
00103     { return this->vtkCommunicator::Send(data, remoteProcessId, tag); }
00104 
00105 //BTX
00106 
00107   class VTK_PARALLEL_EXPORT Request
00108   {
00109   public:
00110     Request();
00111     ~Request();
00112     int Test();
00113     void Cancel();
00114     void Wait();
00115     vtkMPICommunicatorOpaqueRequest* Req;
00116   };
00117 
00118 //ETX
00119 
00121 
00125   int NoBlockSend(int* data, int length, int remoteProcessId, int tag,
00126                   Request& req);
00127   int NoBlockSend(unsigned long* data, int length, int remoteProcessId,
00128                   int tag, Request& req);
00129   int NoBlockSend(char* data, int length, int remoteProcessId, 
00130                   int tag, Request& req);
00131   int NoBlockSend(float* data, int length, int remoteProcessId, 
00132                   int tag, Request& req);
00134 
00136 
00138   virtual int Receive(int* data, int length, int remoteProcessId, 
00139                       int tag);
00140   virtual int Receive(unsigned long* data, int length, 
00141                       int remoteProcessId, int tag);
00142   virtual int Receive(char* data, int length, int remoteProcessId, 
00143                       int tag);
00144   virtual int Receive(unsigned char* data, int length, int remoteProcessId, 
00145                       int tag);
00146   virtual int Receive(float* data, int length, int remoteProcessId, 
00147                       int tag);
00148   virtual int Receive(double* data, int length, int remoteProcessId, 
00149                       int tag);
00150 #ifdef VTK_USE_64BIT_IDS
00151   virtual int Receive(vtkIdType* data, int length, int remoteProcessId, 
00152                       int tag);
00154 #endif
00155   virtual int Receive(vtkDataObject* data, int remoteProcessId, int tag)
00156     { return this->vtkCommunicator::Receive(data, remoteProcessId, tag); }
00157   virtual int Receive(vtkDataArray* data, int remoteProcessId, int tag)
00158     { return this->vtkCommunicator::Receive(data, remoteProcessId, tag); }
00159 
00161 
00164   int NoBlockReceive(int* data, int length, int remoteProcessId, 
00165                      int tag, Request& req);
00166   int NoBlockReceive(unsigned long* data, int length, 
00167                      int remoteProcessId, int tag, Request& req);
00168   int NoBlockReceive(char* data, int length, int remoteProcessId, 
00169                      int tag, Request& req);
00170   int NoBlockReceive(float* data, int length, int remoteProcessId, 
00171                      int tag, Request& req);
00173 
00174 
00176 
00177   int Broadcast(int* data          , int length, int root);
00178   int Broadcast(unsigned long* data, int length, int root);
00179   int Broadcast(char* data         , int length, int root);
00180   int Broadcast(float* data        , int length, int root);
00181   int Broadcast(double* data        , int length, int root);
00183 
00184   
00186 
00188   int Gather(int* data          , int* to          , int length, int root);
00189   int Gather(unsigned long* data, unsigned long* to, int length, int root);
00190   int Gather(char* data         , char* to         , int length, int root);
00191   int Gather(float* data        , float* to        , int length, int root);
00192   int Gather(double* data       , double* to       , int length, int root);
00194 
00196 
00203   int GatherV(int* data, int* to, 
00204               int sendlength, int* recvlengths, int* offsets, int root);
00205   int GatherV(unsigned long* data, unsigned long* to, 
00206               int sendlength, int* recvlengths, int* offsets, int root);
00207   int GatherV(char* data, char* to, 
00208               int sendlength, int* recvlengths, int* offsets, int root);
00209   int GatherV(float* data, float* to, 
00210               int sendlength, int* recvlengths, int* offsets, int root);
00211   int GatherV(double* data, double* to, 
00212               int sendlength, int* recvlengths, int* offsets, int root);
00214 
00215 
00217 
00221   int AllGather(int* data          , int* to          , int length);
00222   int AllGather(unsigned long* data, unsigned long* to, int length);
00223   int AllGather(char* data         , char* to         , int length);
00224   int AllGather(float* data        , float* to        , int length);
00225   int AllGather(double* data       , double* to       , int length);
00227   
00229 
00233   int AllGatherV(int* data, int* to, 
00234                  int sendlength, int* recvlengths, int* recvOffsets);
00235   int AllGatherV(unsigned long* data, unsigned long* to, 
00236                  int sendlength, int* recvlengths, int* recvOffsets);
00237   int AllGatherV(char* data, char* to, 
00238                  int sendlength, int* recvlengths, int* recvOffsets);
00239   int AllGatherV(float* data, float* to, 
00240                  int sendlength, int* recvlengths, int* recvOffsets);
00241   int AllGatherV(double* data, double* to, 
00242                  int sendlength, int* recvlengths, int* recvOffsets);
00244 
00246 
00247   int ReduceMax(int* data, int* to, int size, int root);
00248   int ReduceMax(unsigned long* data, unsigned long* to, int size, int root);
00249   int ReduceMax(float* data, float* to, int size, int root);
00250   int ReduceMax(double* data, double* to, int size, int root);
00252 
00253   int ReduceMin(int* data, int* to, int size, int root);
00254   int ReduceMin(unsigned long* data, unsigned long* to, int size, int root);
00255   int ReduceMin(float* data, float* to, int size, int root);
00256   int ReduceMin(double* data, double* to, int size, int root);
00257 
00258   int ReduceSum(int* data, int* to, int size, int root);
00259   int ReduceSum(unsigned long* data, unsigned long* to, int size, int root);
00260   int ReduceSum(float* data, float* to, int size, int root);
00261   int ReduceSum(double* data, double* to, int size, int root);
00262 
00263   int ReduceAnd(bool* data, bool* to, int size, int root);
00264   int ReduceOr(bool* data, bool* to, int size, int root);
00265 
00266 
00267 //BTX
00268 
00269   friend class vtkMPIController;
00270 
00271   vtkMPICommunicatorOpaqueComm *GetMPIComm()
00272     {
00273     return this->MPIComm;
00274     }
00275 //ETX
00276 
00277   static char* Allocate(size_t size);
00278   static void Free(char* ptr);
00279 
00280 
00281 protected:
00282   vtkMPICommunicator();
00283   ~vtkMPICommunicator();
00284 
00285   virtual void SetGroup(vtkMPIGroup*);
00286 
00288 
00295   vtkSetMacro(KeepHandle, int);
00296   vtkBooleanMacro(KeepHandle, int);
00298 
00299 
00300   static vtkMPICommunicator* WorldCommunicator;
00301 
00302   void InitializeCopy(vtkMPICommunicator* source);
00303 
00308   void CopyFrom(vtkMPICommunicator* source);
00309 
00316   void Duplicate(vtkMPICommunicator* source);
00317 
00318   vtkMPICommunicatorOpaqueComm* MPIComm;
00319   vtkMPIGroup* Group;
00320 
00321   int Initialized;
00322   int KeepHandle;
00323 
00324   static int CheckForMPIError(int err);
00325 
00326 private:
00327   vtkMPICommunicator(const vtkMPICommunicator&);  // Not implemented.
00328   void operator=(const vtkMPICommunicator&);  // Not implemented.
00329 };
00330 
00331 #endif