dox/Parallel/vtkMultiProcessController.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkMultiProcessController.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 =========================================================================*/
00040 #ifndef __vtkMultiProcessController_h
00041 #define __vtkMultiProcessController_h
00042 
00043 #include "vtkObject.h"
00044 
00045 #include "vtkCommunicator.h" // Needed for direct access to communicator
00046 
00047 class vtkCollection;
00048 class vtkDataObject;
00049 class vtkDataSet;
00050 class vtkImageData;
00051 class vtkMultiProcessController;
00052 class vtkMultiProcessStream;
00053 class vtkOutputWindow;
00054 class vtkProcessGroup;
00055 
00056 //BTX
00057 // The type of function that gets called when new processes are initiated.
00058 typedef void (*vtkProcessFunctionType)(vtkMultiProcessController *controller, 
00059                                        void *userData);
00060 
00061 // The type of function that gets called when an RMI is triggered.
00062 typedef void (*vtkRMIFunctionType)(void *localArg, 
00063                                    void *remoteArg, int remoteArgLength, 
00064                                    int remoteProcessId);
00065 //ETX
00066 
00067 
00068 class VTK_PARALLEL_EXPORT vtkMultiProcessController : public vtkObject
00069 {
00070 public:
00071   vtkTypeRevisionMacro(vtkMultiProcessController,vtkObject);
00072   void PrintSelf(ostream& os, vtkIndent indent);
00073 
00077   virtual void Initialize(int* vtkNotUsed(argc), char*** vtkNotUsed(argv))=0;
00078 
00080 
00083   virtual void Initialize(int* vtkNotUsed(argc), char*** vtkNotUsed(argv),
00084                           int initializedExternally)=0;
00086 
00089   virtual void Finalize()=0;
00090 
00094   virtual void Finalize(int finalizedExternally)=0;
00095 
00097 
00100   void SetNumberOfProcesses(int num);
00101   int GetNumberOfProcesses();
00103 
00104   //BTX
00106 
00109   void SetSingleMethod(vtkProcessFunctionType, void *data);
00110   //ETX
00112 
00116   virtual void SingleMethodExecute() = 0;
00117   
00118   //BTX
00120 
00124   void SetMultipleMethod(int index, vtkProcessFunctionType, void *data); 
00125   //ETX
00127 
00131   virtual void MultipleMethodExecute() = 0;
00132 
00134   int GetLocalProcessId();
00135 
00140   static vtkMultiProcessController *GetGlobalController();
00141 
00144   virtual void CreateOutputWindow() = 0;
00145 
00147 
00157   virtual vtkMultiProcessController *CreateSubController(
00158                                                         vtkProcessGroup *group);
00160   
00161   //------------------ RMIs --------------------
00162   //BTX
00173   unsigned long AddRMI(vtkRMIFunctionType, void *localArg, int tag);
00174   
00176   int RemoveFirstRMI(int tag);
00177 
00180   int RemoveRMI(unsigned long id);
00181 
00183 
00184   void RemoveRMI(vtkRMIFunctionType f, void *arg, int tag)
00185     {f = f; arg = arg; tag = tag; vtkErrorMacro("RemoveRMI Not Implemented Yet");};
00186   //ETX
00188   
00190   void TriggerRMI(int remoteProcessId, void *arg, int argLength, int tag);
00191 
00194   void TriggerBreakRMIs();
00195 
00197 
00198   void TriggerRMI(int remoteProcessId, const char *arg, int tag) 
00199     { this->TriggerRMI(remoteProcessId, (void*)arg, 
00200                        static_cast<int>(strlen(arg))+1, tag); }
00202 
00204 
00205   void TriggerRMI(int remoteProcessId, int tag)
00206     { this->TriggerRMI(remoteProcessId, NULL, 0, tag); }
00208 
00210 
00216   void TriggerRMIOnAllChildren(void *arg, int argLength, int tag);
00217   void TriggerRMIOnAllChildren(const char *arg, int tag) 
00218     { 
00219     this->TriggerRMIOnAllChildren(
00220       (void*)arg, static_cast<int>(strlen(arg))+1, tag);
00221     }
00222   void TriggerRMIOnAllChildren(int tag)
00223     { 
00224     this->TriggerRMIOnAllChildren(NULL, 0, tag);
00225     }
00227 
00229 
00236   int ProcessRMIs(int reportErrors, int dont_loop = 0);
00237   int ProcessRMIs();
00239  
00241 
00244   vtkSetMacro(BreakFlag, int);
00245   vtkGetMacro(BreakFlag, int);
00247 
00249 
00251   vtkGetObjectMacro(Communicator, vtkCommunicator);
00253 
00255 
00256   static int GetBreakRMITag() { return BREAK_RMI_TAG; }
00257   static int GetRMITag() { return RMI_TAG; }
00258   static int GetRMIArgTag() { return RMI_ARG_TAG; }  
00260   
00261 //BTX
00262 
00263   enum Errors 
00264   {
00265     RMI_NO_ERROR,
00266     RMI_TAG_ERROR,
00267     RMI_ARG_ERROR
00268   };
00269 
00270   enum Consts 
00271   {
00272     MAX_PROCESSES  = 8192,
00273     ANY_SOURCE     = -1,
00274     INVALID_SOURCE = -2
00275   };
00276 
00277   enum Tags 
00278   {
00279     RMI_TAG        = 1,
00280     RMI_ARG_TAG    = 2,
00281     BREAK_RMI_TAG  = 3,
00282     XML_WRITER_DATA_INFO = 4
00283   };
00284 
00285 //ETX
00286 
00288   void Barrier();
00289 
00290   static void SetGlobalController(vtkMultiProcessController *controller);
00291 
00292   //------------------ Communication --------------------
00293   
00295 
00297   int Send(const int* data, vtkIdType length, int remoteProcessId, int tag);
00298   int Send(const unsigned int* data, vtkIdType length, int remoteProcessId, int tag);
00299   int Send(const unsigned long* data, vtkIdType length, int remoteProcessId, 
00300            int tag);
00301   int Send(const char* data, vtkIdType length, int remoteProcessId, int tag);
00302   int Send(const unsigned char* data, vtkIdType length, int remoteProcessId, int tag);
00303   int Send(const float* data, vtkIdType length, int remoteProcessId, int tag);
00304   int Send(const double* data, vtkIdType length, int remoteProcessId, int tag);
00305 #ifdef VTK_USE_64BIT_IDS
00306   int Send(const vtkIdType* data, vtkIdType length, int remoteProcessId, int tag);
00308 #endif
00309   int Send(vtkDataObject *data, int remoteId, int tag);
00310   int Send(vtkDataArray *data, int remoteId, int tag);
00311 
00312 //BTX
00318   int Send(const vtkMultiProcessStream& stream, int remoteId, int tag);
00319 //ETX
00320 
00322 
00330   int Receive(int* data, vtkIdType maxlength, int remoteProcessId, int tag);
00331   int Receive(unsigned int* data, vtkIdType maxlength, int remoteProcessId, int tag);
00332   int Receive(unsigned long* data, vtkIdType maxlength, int remoteProcessId, 
00333               int tag);
00334   int Receive(char* data, vtkIdType maxlength, int remoteProcessId, int tag);
00335   int Receive(unsigned char* data, vtkIdType maxlength, int remoteProcessId, int tag);
00336   int Receive(float* data, vtkIdType maxlength, int remoteProcessId, int tag);
00337   int Receive(double* data, vtkIdType maxlength, int remoteProcessId, int tag);
00338 #ifdef VTK_USE_64BIT_IDS
00339   int Receive(vtkIdType* data, vtkIdType maxlength, int remoteProcessId, int tag);
00341 #endif
00342   int Receive(vtkDataObject* data, int remoteId, int tag);
00343   int Receive(vtkDataArray* data, int remoteId, int tag);
00344 //BTX
00346   int Receive(vtkMultiProcessStream& stream, int remoteId, int tag);
00347 //ETX
00348   vtkDataObject *ReceiveDataObject(int remoteId, int tag);
00349 
00357   vtkIdType GetCount();
00358 
00359 
00360   //---------------------- Collective Operations ----------------------
00361 
00363 
00366   int Broadcast(int *data, vtkIdType length, int srcProcessId) {
00367     return this->Communicator->Broadcast(data, length, srcProcessId);
00368   }
00369   int Broadcast(unsigned long *data, vtkIdType length, int srcProcessId) {
00370     return this->Communicator->Broadcast(data, length, srcProcessId);
00371   }
00372   int Broadcast(unsigned char *data, vtkIdType length, int srcProcessId) {
00373     return this->Communicator->Broadcast(data, length, srcProcessId);
00374   }
00375   int Broadcast(char *data, vtkIdType length, int srcProcessId) {
00376     return this->Communicator->Broadcast(data, length, srcProcessId);
00377   }
00378   int Broadcast(float *data, vtkIdType length, int srcProcessId) {
00379     return this->Communicator->Broadcast(data, length, srcProcessId);
00380   }
00381   int Broadcast(double *data, vtkIdType length, int srcProcessId) {
00382     return this->Communicator->Broadcast(data, length, srcProcessId);
00383   }
00384 #ifdef VTK_USE_64BIT_IDS
00385   int Broadcast(vtkIdType *data, vtkIdType length, int srcProcessId) {
00386     return this->Communicator->Broadcast(data, length, srcProcessId);
00387   }
00389 #endif
00390   int Broadcast(vtkDataObject *data, int srcProcessId) {
00391     return this->Communicator->Broadcast(data, srcProcessId);
00392   }
00393   int Broadcast(vtkDataArray *data, int srcProcessId) {
00394     return this->Communicator->Broadcast(data, srcProcessId);
00395   }
00396 //BTX
00397   int Broadcast(vtkMultiProcessStream& stream, int srcProcessId) {
00398     return this->Communicator->Broadcast(stream, srcProcessId);
00399   }
00400 //ETX
00401 
00403 
00411   int Gather(const int *sendBuffer, int *recvBuffer,
00412              vtkIdType length, int destProcessId) {
00413     return this->Communicator->Gather(sendBuffer, recvBuffer, length,
00414                                       destProcessId);
00415   }
00416   int Gather(const unsigned long *sendBuffer, unsigned long *recvBuffer,
00417              vtkIdType length, int destProcessId) {
00418     return this->Communicator->Gather(sendBuffer, recvBuffer, length,
00419                                       destProcessId);
00420   }
00421   int Gather(const unsigned char *sendBuffer, unsigned char *recvBuffer,
00422              vtkIdType length, int destProcessId) {
00423     return this->Communicator->Gather(sendBuffer, recvBuffer, length,
00424                                       destProcessId);
00425   }
00426   int Gather(const char *sendBuffer, char *recvBuffer,
00427              vtkIdType length, int destProcessId) {
00428     return this->Communicator->Gather(sendBuffer, recvBuffer, length,
00429                                       destProcessId);
00430   }
00431   int Gather(const float *sendBuffer, float *recvBuffer,
00432              vtkIdType length, int destProcessId) {
00433     return this->Communicator->Gather(sendBuffer, recvBuffer, length,
00434                                       destProcessId);
00435   }
00436   int Gather(const double *sendBuffer, double *recvBuffer,
00437              vtkIdType length, int destProcessId) {
00438     return this->Communicator->Gather(sendBuffer, recvBuffer, length,
00439                                       destProcessId);
00440   }
00441 #ifdef VTK_USE_64BIT_IDS
00442   int Gather(const vtkIdType *sendBuffer, vtkIdType *recvBuffer,
00443              vtkIdType length, int destProcessId) {
00444     return this->Communicator->Gather(sendBuffer, recvBuffer, length,
00445                                       destProcessId);
00446   }
00448 #endif
00449   int Gather(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer,
00450              int destProcessId) {
00451     return this->Communicator->Gather(sendBuffer, recvBuffer, destProcessId);
00452   }
00453 
00455 
00465   int GatherV(const int* sendBuffer, int* recvBuffer, 
00466               vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets,
00467               int destProcessId) {
00468     return this->Communicator->GatherV(sendBuffer, recvBuffer,
00469                                        sendLength, recvLengths,
00470                                        offsets, destProcessId);
00471   }
00472   int GatherV(const unsigned long* sendBuffer, unsigned long* recvBuffer, 
00473               vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets,
00474               int destProcessId) {
00475     return this->Communicator->GatherV(sendBuffer, recvBuffer,
00476                                        sendLength, recvLengths,
00477                                        offsets, destProcessId);
00478   }
00479   int GatherV(const unsigned char* sendBuffer, unsigned char* recvBuffer, 
00480               vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets,
00481               int destProcessId) {
00482     return this->Communicator->GatherV(sendBuffer, recvBuffer,
00483                                        sendLength, recvLengths,
00484                                        offsets, destProcessId);
00485   }
00486   int GatherV(const char* sendBuffer, char* recvBuffer, 
00487               vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets,
00488               int destProcessId) {
00489     return this->Communicator->GatherV(sendBuffer, recvBuffer,
00490                                        sendLength, recvLengths,
00491                                        offsets, destProcessId);
00492   }
00493   int GatherV(const float* sendBuffer, float* recvBuffer, 
00494               vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets,
00495               int destProcessId) {
00496     return this->Communicator->GatherV(sendBuffer, recvBuffer,
00497                                        sendLength, recvLengths,
00498                                        offsets, destProcessId);
00499   }
00500   int GatherV(const double* sendBuffer, double* recvBuffer, 
00501               vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets,
00502               int destProcessId) {
00503     return this->Communicator->GatherV(sendBuffer, recvBuffer,
00504                                        sendLength, recvLengths,
00505                                        offsets, destProcessId);
00506   }
00507 #ifdef VTK_USE_64BIT_IDS
00508   int GatherV(const vtkIdType* sendBuffer, vtkIdType* recvBuffer, 
00509               vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets,
00510               int destProcessId) {
00511     return this->Communicator->GatherV(sendBuffer, recvBuffer,
00512                                        sendLength, recvLengths,
00513                                        offsets, destProcessId);
00514   }
00516 #endif
00517 
00519 
00524   int Scatter(const int *sendBuffer, int *recvBuffer,
00525               vtkIdType length, int srcProcessId) {
00526     return this->Communicator->Scatter(sendBuffer, recvBuffer, length,
00527                                        srcProcessId);
00528   }
00529   int Scatter(const unsigned long *sendBuffer, unsigned long *recvBuffer,
00530               vtkIdType length, int srcProcessId) {
00531     return this->Communicator->Scatter(sendBuffer, recvBuffer, length,
00532                                        srcProcessId);
00533   }
00534   int Scatter(const unsigned char *sendBuffer, unsigned char *recvBuffer,
00535               vtkIdType length, int srcProcessId) {
00536     return this->Communicator->Scatter(sendBuffer, recvBuffer, length,
00537                                        srcProcessId);
00538   }
00539   int Scatter(const char *sendBuffer, char *recvBuffer,
00540               vtkIdType length, int srcProcessId) {
00541     return this->Communicator->Scatter(sendBuffer, recvBuffer, length,
00542                                        srcProcessId);
00543   }
00544   int Scatter(const float *sendBuffer, float *recvBuffer,
00545               vtkIdType length, int srcProcessId) {
00546     return this->Communicator->Scatter(sendBuffer, recvBuffer, length,
00547                                        srcProcessId);
00548   }
00549   int Scatter(const double *sendBuffer, double *recvBuffer,
00550               vtkIdType length, int srcProcessId) {
00551     return this->Communicator->Scatter(sendBuffer, recvBuffer, length,
00552                                        srcProcessId);
00553   }
00554 #ifdef VTK_USE_64BIT_IDS
00555   int Scatter(const vtkIdType *sendBuffer, vtkIdType *recvBuffer,
00556               vtkIdType length, int srcProcessId) {
00557     return this->Communicator->Scatter(sendBuffer, recvBuffer, length,
00558                                        srcProcessId);
00559   }
00561 #endif
00562   int Scatter(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer,
00563               int srcProcessId) {
00564     return this->Communicator->Scatter(sendBuffer, recvBuffer, srcProcessId);
00565   }
00566 
00568 
00574   int ScatterV(const int *sendBuffer, int *recvBuffer,
00575                vtkIdType *sendLengths, vtkIdType *offsets,
00576                vtkIdType recvLength, int srcProcessId) {
00577     return this->Communicator->ScatterV(sendBuffer, recvBuffer,
00578                                         sendLengths, offsets, recvLength,
00579                                         srcProcessId);
00580   }
00581   int ScatterV(const unsigned long *sendBuffer, unsigned long *recvBuffer,
00582                vtkIdType *sendLengths, vtkIdType *offsets,
00583                vtkIdType recvLength, int srcProcessId) {
00584     return this->Communicator->ScatterV(sendBuffer, recvBuffer,
00585                                         sendLengths, offsets, recvLength,
00586                                         srcProcessId);
00587   }
00588   int ScatterV(const unsigned char *sendBuffer, unsigned char *recvBuffer,
00589                vtkIdType *sendLengths, vtkIdType *offsets,
00590                vtkIdType recvLength, int srcProcessId) {
00591     return this->Communicator->ScatterV(sendBuffer, recvBuffer,
00592                                         sendLengths, offsets, recvLength,
00593                                         srcProcessId);
00594   }
00595   int ScatterV(const char *sendBuffer, char *recvBuffer,
00596                vtkIdType *sendLengths, vtkIdType *offsets,
00597                vtkIdType recvLength, int srcProcessId) {
00598     return this->Communicator->ScatterV(sendBuffer, recvBuffer,
00599                                         sendLengths, offsets, recvLength,
00600                                         srcProcessId);
00601   }
00602   int ScatterV(const float *sendBuffer, float *recvBuffer,
00603                vtkIdType *sendLengths, vtkIdType *offsets,
00604                vtkIdType recvLength, int srcProcessId) {
00605     return this->Communicator->ScatterV(sendBuffer, recvBuffer,
00606                                         sendLengths, offsets, recvLength,
00607                                         srcProcessId);
00608   }
00609   int ScatterV(const double *sendBuffer, double *recvBuffer,
00610                vtkIdType *sendLengths, vtkIdType *offsets,
00611                vtkIdType recvLength, int srcProcessId) {
00612     return this->Communicator->ScatterV(sendBuffer, recvBuffer,
00613                                         sendLengths, offsets, recvLength,
00614                                         srcProcessId);
00615   }
00616 #ifdef VTK_USE_64BIT_IDS
00617   int ScatterV(const vtkIdType *sendBuffer, vtkIdType *recvBuffer,
00618                vtkIdType *sendLengths, vtkIdType *offsets,
00619                vtkIdType recvLength, int srcProcessId) {
00620     return this->Communicator->ScatterV(sendBuffer, recvBuffer,
00621                                         sendLengths, offsets, recvLength,
00622                                         srcProcessId);
00623   }
00625 #endif
00626 
00628 
00629   int AllGather(const int *sendBuffer, int *recvBuffer, vtkIdType length) {
00630     return this->Communicator->AllGather(sendBuffer, recvBuffer, length);
00631   }
00632   int AllGather(const unsigned long *sendBuffer,
00633                 unsigned long *recvBuffer, vtkIdType length) {
00634     return this->Communicator->AllGather(sendBuffer, recvBuffer, length);
00635   }
00636   int AllGather(const unsigned char *sendBuffer,
00637                 unsigned char *recvBuffer, vtkIdType length) {
00638     return this->Communicator->AllGather(sendBuffer, recvBuffer, length);
00639   }
00640   int AllGather(const char *sendBuffer, char *recvBuffer, vtkIdType length) {
00641     return this->Communicator->AllGather(sendBuffer, recvBuffer, length);
00642   }
00643   int AllGather(const float *sendBuffer, float *recvBuffer, vtkIdType length) {
00644     return this->Communicator->AllGather(sendBuffer, recvBuffer, length);
00645   }
00646   int AllGather(const double *sendBuffer,
00647                 double *recvBuffer, vtkIdType length) {
00648     return this->Communicator->AllGather(sendBuffer, recvBuffer, length);
00649   }
00650 #ifdef VTK_USE_64BIT_IDS
00651   int AllGather(const vtkIdType *sendBuffer, vtkIdType *recvBuffer,
00652                 vtkIdType length) {
00653     return this->Communicator->AllGather(sendBuffer, recvBuffer, length);
00654   }
00656 #endif
00657   int AllGather(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer) {
00658     return this->Communicator->AllGather(sendBuffer, recvBuffer);
00659   }
00660 
00662 
00663   int AllGatherV(const int* sendBuffer, int* recvBuffer, 
00664                  vtkIdType sendLength, vtkIdType* recvLengths,
00665                  vtkIdType* offsets) {
00666     return this->Communicator->AllGatherV(sendBuffer, recvBuffer,
00667                                           sendLength, recvLengths,
00668                                           offsets);
00669   }
00670   int AllGatherV(const unsigned long* sendBuffer, unsigned long* recvBuffer, 
00671                  vtkIdType sendLength, vtkIdType* recvLengths,
00672                  vtkIdType* offsets) {
00673     return this->Communicator->AllGatherV(sendBuffer, recvBuffer,
00674                                           sendLength, recvLengths,
00675                                           offsets);
00676   }
00677   int AllGatherV(const unsigned char* sendBuffer, unsigned char* recvBuffer, 
00678                  vtkIdType sendLength, vtkIdType* recvLengths,
00679                  vtkIdType* offsets) {
00680     return this->Communicator->AllGatherV(sendBuffer, recvBuffer,
00681                                           sendLength, recvLengths,
00682                                           offsets);
00683   }
00684   int AllGatherV(const char* sendBuffer, char* recvBuffer, 
00685                  vtkIdType sendLength, vtkIdType* recvLengths,
00686                  vtkIdType* offsets) {
00687     return this->Communicator->AllGatherV(sendBuffer, recvBuffer,
00688                                           sendLength, recvLengths,
00689                                           offsets);
00690   }
00691   int AllGatherV(const float* sendBuffer, float* recvBuffer, 
00692                  vtkIdType sendLength, vtkIdType* recvLengths,
00693                  vtkIdType* offsets) {
00694     return this->Communicator->AllGatherV(sendBuffer, recvBuffer,
00695                                           sendLength, recvLengths,
00696                                           offsets);
00697   }
00698   int AllGatherV(const double* sendBuffer, double* recvBuffer, 
00699                  vtkIdType sendLength, vtkIdType* recvLengths,
00700                  vtkIdType* offsets) {
00701     return this->Communicator->AllGatherV(sendBuffer, recvBuffer,
00702                                           sendLength, recvLengths,
00703                                           offsets);
00704   }
00705 #ifdef VTK_USE_64BIT_IDS
00706   int AllGatherV(const vtkIdType* sendBuffer, vtkIdType* recvBuffer, 
00707                  vtkIdType sendLength, vtkIdType* recvLengths,
00708                  vtkIdType* offsets) {
00709     return this->Communicator->AllGatherV(sendBuffer, recvBuffer,
00710                                           sendLength, recvLengths,
00711                                           offsets);
00712   }
00714 #endif
00715 
00717 
00720   int Reduce(const int *sendBuffer, int *recvBuffer,
00721              vtkIdType length, int operation, int destProcessId) {
00722     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00723                                       operation, destProcessId);
00724   }
00725   int Reduce(const unsigned long *sendBuffer, unsigned long *recvBuffer,
00726              vtkIdType length, int operation, int destProcessId) {
00727     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00728                                       operation, destProcessId);
00729   }
00730   int Reduce(const unsigned char *sendBuffer, unsigned char *recvBuffer,
00731              vtkIdType length, int operation, int destProcessId) {
00732     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00733                                       operation, destProcessId);
00734   }
00735   int Reduce(const char *sendBuffer, char *recvBuffer,
00736              vtkIdType length, int operation, int destProcessId) {
00737     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00738                                       operation, destProcessId);
00739   }
00740   int Reduce(const float *sendBuffer, float *recvBuffer,
00741              vtkIdType length, int operation, int destProcessId) {
00742     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00743                                       operation, destProcessId);
00744   }
00745   int Reduce(const double *sendBuffer, double *recvBuffer,
00746              vtkIdType length, int operation, int destProcessId) {
00747     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00748                                       operation, destProcessId);
00749   }
00750 #ifdef VTK_USE_64BIT_IDS
00751   int Reduce(const vtkIdType *sendBuffer, vtkIdType *recvBuffer,
00752              vtkIdType length, int operation, int destProcessId) {
00753     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00754                                       operation, destProcessId);
00755   }
00757 #endif
00758   int Reduce(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer,
00759              int operation, int destProcessId) {
00760     return this->Communicator->Reduce(sendBuffer, recvBuffer,
00761                                       operation, destProcessId);
00762   }
00763 
00764 //BTX
00766 
00769   int Reduce(const int *sendBuffer, int *recvBuffer,
00770              vtkIdType length, vtkCommunicator::Operation *operation,
00771              int destProcessId) {
00772     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00773                                       operation, destProcessId);
00774   }
00775   int Reduce(const unsigned long *sendBuffer, unsigned long *recvBuffer,
00776              vtkIdType length, vtkCommunicator::Operation *operation,
00777              int destProcessId) {
00778     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00779                                       operation, destProcessId);
00780   }
00781   int Reduce(const unsigned char *sendBuffer, unsigned char *recvBuffer,
00782              vtkIdType length, vtkCommunicator::Operation *operation,
00783              int destProcessId) {
00784     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00785                                       operation, destProcessId);
00786   }
00787   int Reduce(const char *sendBuffer, char *recvBuffer,
00788              vtkIdType length, vtkCommunicator::Operation *operation,
00789              int destProcessId) {
00790     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00791                                       operation, destProcessId);
00792   }
00793   int Reduce(const float *sendBuffer, float *recvBuffer,
00794              vtkIdType length, vtkCommunicator::Operation *operation,
00795              int destProcessId) {
00796     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00797                                       operation, destProcessId);
00798   }
00799   int Reduce(const double *sendBuffer, double *recvBuffer,
00800              vtkIdType length, vtkCommunicator::Operation *operation,
00801              int destProcessId) {
00802     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00803                                       operation, destProcessId);
00804   }
00805 #ifdef VTK_USE_64BIT_IDS
00806   int Reduce(const vtkIdType *sendBuffer, vtkIdType *recvBuffer,
00807              vtkIdType length, vtkCommunicator::Operation *operation,
00808              int destProcessId) {
00809     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00810                                       operation, destProcessId);
00811   }
00813 #endif
00814   int Reduce(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer,
00815              vtkCommunicator::Operation *operation, int destProcessId) {
00816     return this->Communicator->Reduce(sendBuffer, recvBuffer,
00817                                       operation, destProcessId);
00818   }
00819 //ETX
00820 
00822 
00824   int AllReduce(const int *sendBuffer, int *recvBuffer,
00825                 vtkIdType length, int operation) {
00826     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00827                                          operation);
00828   }
00829   int AllReduce(const unsigned long *sendBuffer, unsigned long *recvBuffer,
00830                 vtkIdType length, int operation) {
00831     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00832                                          operation);
00833   }
00834   int AllReduce(const unsigned char *sendBuffer, unsigned char *recvBuffer,
00835                 vtkIdType length, int operation) {
00836     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00837                                          operation);
00838   }
00839   int AllReduce(const char *sendBuffer, char *recvBuffer,
00840                 vtkIdType length, int operation) {
00841     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00842                                          operation);
00843   }
00844   int AllReduce(const float *sendBuffer, float *recvBuffer,
00845                 vtkIdType length, int operation) {
00846     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00847                                          operation);
00848   }
00849   int AllReduce(const double *sendBuffer, double *recvBuffer,
00850                 vtkIdType length, int operation) {
00851     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00852                                          operation);
00853   }
00854 #ifdef VTK_USE_64BIT_IDS
00855   int AllReduce(const vtkIdType *sendBuffer, vtkIdType *recvBuffer,
00856                 vtkIdType length, int operation) {
00857     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00858                                          operation);
00859   }
00861 #endif
00862   int AllReduce(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer,
00863                 int operation) {
00864     return this->Communicator->AllReduce(sendBuffer, recvBuffer, operation);
00865   }
00866 //BTX
00867   int AllReduce(const int *sendBuffer, int *recvBuffer,
00868                 vtkIdType length, vtkCommunicator::Operation *operation) {
00869     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00870                                          operation);
00871   }
00872   int AllReduce(const unsigned long *sendBuffer, unsigned long *recvBuffer,
00873                 vtkIdType length, vtkCommunicator::Operation *operation) {
00874     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00875                                          operation);
00876   }
00877   int AllReduce(const unsigned char *sendBuffer, unsigned char *recvBuffer,
00878                 vtkIdType length, vtkCommunicator::Operation *operation) {
00879     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00880                                          operation);
00881   }
00882   int AllReduce(const char *sendBuffer, char *recvBuffer,
00883                 vtkIdType length, vtkCommunicator::Operation *operation) {
00884     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00885                                          operation);
00886   }
00887   int AllReduce(const float *sendBuffer, float *recvBuffer,
00888                 vtkIdType length, vtkCommunicator::Operation *operation) {
00889     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00890                                          operation);
00891   }
00892   int AllReduce(const double *sendBuffer, double *recvBuffer,
00893                 vtkIdType length, vtkCommunicator::Operation *operation) {
00894     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00895                                          operation);
00896   }
00897 #ifdef VTK_USE_64BIT_IDS
00898   int AllReduce(const vtkIdType *sendBuffer, vtkIdType *recvBuffer,
00899                 vtkIdType length, vtkCommunicator::Operation *operation) {
00900     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00901                                          operation);
00902   }
00903 #endif
00904   int AllReduce(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer,
00905                 vtkCommunicator::Operation *operation) {
00906     return this->Communicator->AllReduce(sendBuffer, recvBuffer, operation);
00907   }
00908 //ETX
00909 
00910 // Internally implemented RMI to break the process loop.
00911 
00912 protected:
00913   vtkMultiProcessController();
00914   ~vtkMultiProcessController();
00915 
00917 
00920   virtual void TriggerRMIInternal(int remoteProcessId, 
00921     void* arg, int argLength, int rmiTag, bool propagate);
00923   
00924   vtkProcessFunctionType      SingleMethod;
00925   void                       *SingleData;
00926   vtkProcessFunctionType      MultipleMethod[MAX_PROCESSES];
00927   void                       *MultipleData[MAX_PROCESSES];  
00928   
00929   vtkCollection *RMIs;
00930   
00931   // This is a flag that can be used by the ports to break
00932   // their update loop. (same as ProcessRMIs)
00933   int BreakFlag;
00934 
00935   void ProcessRMI(int remoteProcessId, void *arg, int argLength, int rmiTag);
00936 
00937   // This method implements "GetGlobalController".  
00938   // It needs to be virtual and static.
00939   virtual vtkMultiProcessController *GetLocalController();
00940 
00941   
00942   // This flag can force deep copies during send.
00943   int ForceDeepCopy;
00944 
00945   vtkOutputWindow* OutputWindow;
00946 
00947   // Note that since the communicators can be created differently
00948   // depending on the type of controller, the subclasses are
00949   // responsible of deleting them.
00950   vtkCommunicator* Communicator;
00951 
00952   // Communicator which is a copy of the current user
00953   // level communicator except the context; i.e. even if the tags 
00954   // are the same, the RMI messages will not interfere with user 
00955   // level messages. 
00956   // Note that since the communicators can be created differently
00957   // depending on the type of controller, the subclasses are
00958   // responsible of deleting them.
00959   vtkCommunicator* RMICommunicator;
00960 
00961 private:
00962   vtkMultiProcessController(const vtkMultiProcessController&);  // Not implemented.
00963   void operator=(const vtkMultiProcessController&);  // Not implemented.
00964 
00965   unsigned long RMICount;
00966 };
00967 
00968 
00969 inline int vtkMultiProcessController::Send(vtkDataObject *data, 
00970                                            int remoteProcessId, int tag)
00971 {
00972   if (this->Communicator)
00973     {
00974     return this->Communicator->Send(data, remoteProcessId, tag);
00975     }
00976   else
00977     {
00978     return 0;
00979     }
00980 }
00981 
00982 inline int vtkMultiProcessController::Send(vtkDataArray *data, 
00983                                            int remoteProcessId, int tag)
00984 {
00985   if (this->Communicator)
00986     {
00987     return this->Communicator->Send(data, remoteProcessId, tag);
00988     }
00989   else
00990     {
00991     return 0;
00992     }
00993 }
00994 
00995 inline int vtkMultiProcessController::Send(const int* data, vtkIdType length, 
00996                                            int remoteProcessId, int tag)
00997 {
00998   if (this->Communicator)
00999     {
01000     return this->Communicator->Send(data, length, remoteProcessId, tag);
01001     }
01002   else
01003     {
01004     return 0;
01005     }
01006 }
01007 
01008 inline int vtkMultiProcessController::Send(const unsigned int* data, vtkIdType length, 
01009                                            int remoteProcessId, int tag)
01010 {
01011   if (this->Communicator)
01012     {
01013     return this->Communicator->Send(data, length, remoteProcessId, tag);
01014     }
01015   else
01016     {
01017     return 0;
01018     }
01019 }
01020 
01021 inline int vtkMultiProcessController::Send(const unsigned long* data, 
01022                                            vtkIdType length,
01023                                            int remoteProcessId,
01024                                            int tag)
01025 {
01026   if (this->Communicator)
01027     {
01028     return this->Communicator->Send(data, length, remoteProcessId, tag);
01029     }
01030   else
01031     {
01032     return 0;
01033     }
01034 }
01035 
01036 inline int vtkMultiProcessController::Send(const char* data, vtkIdType length, 
01037                                            int remoteProcessId, int tag)
01038 {
01039   if (this->Communicator)
01040     {
01041     return this->Communicator->Send(data, length, remoteProcessId, tag);
01042     }
01043   else
01044     {
01045     return 0;
01046     }
01047 }
01048 
01049 inline int vtkMultiProcessController::Send(const unsigned char* data,
01050                                            vtkIdType length, 
01051                                            int remoteProcessId, int tag)
01052 {
01053   if (this->Communicator)
01054     {
01055     return this->Communicator->Send(data, length, remoteProcessId, tag);
01056     }
01057   else
01058     {
01059     return 0;
01060     }
01061 }
01062 
01063 inline int vtkMultiProcessController::Send(const float* data, vtkIdType length, 
01064                                            int remoteProcessId, int tag)
01065 {
01066   if (this->Communicator)
01067     {
01068     return this->Communicator->Send(data, length, remoteProcessId, tag);
01069     }
01070   else
01071     {
01072     return 0;
01073     }
01074 }
01075 
01076 inline int vtkMultiProcessController::Send(const double* data, vtkIdType length,
01077                                            int remoteProcessId, int tag)
01078 {
01079   if (this->Communicator)
01080     {
01081     return this->Communicator->Send(data, length, remoteProcessId, tag);
01082     }
01083   else
01084     {
01085     return 0;
01086     }
01087 }
01088 
01089 #ifdef VTK_USE_64BIT_IDS
01090 inline int vtkMultiProcessController::Send(const vtkIdType* data,
01091                                            vtkIdType length, 
01092                                            int remoteProcessId, int tag)
01093 {
01094   if (this->Communicator)
01095     {
01096     return this->Communicator->Send(data, length, remoteProcessId, tag);
01097     }
01098   else
01099     {
01100     return 0;
01101     }
01102 }
01103 #endif
01104 
01105 inline int vtkMultiProcessController::Send(const vtkMultiProcessStream& stream,
01106   int remoteId, int tag)
01107 {
01108   if (this->Communicator)
01109     {
01110     return this->Communicator->Send(stream, remoteId, tag);
01111     }
01112   return 0;
01113 }
01114 
01115 inline int vtkMultiProcessController::Receive(vtkDataObject* data, 
01116                                               int remoteProcessId, int tag)
01117 {
01118   if (this->Communicator)
01119     {
01120     return this->Communicator->Receive(data, remoteProcessId, tag);
01121     }
01122   else
01123     {
01124     return 0;
01125     }
01126 }
01127 
01128 inline vtkDataObject* vtkMultiProcessController::ReceiveDataObject(
01129