VTK
dox/Parallel/vtkMultiProcessController.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkMultiProcessController.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 =========================================================================*/
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 class vtkProcess;
00056 
00057 //BTX
00058 // The type of function that gets called when new processes are initiated.
00059 typedef void (*vtkProcessFunctionType)(vtkMultiProcessController *controller, 
00060                                        void *userData);
00061 
00062 // The type of function that gets called when an RMI is triggered.
00063 typedef void (*vtkRMIFunctionType)(void *localArg, 
00064                                    void *remoteArg, int remoteArgLength, 
00065                                    int remoteProcessId);
00066 //ETX
00067 
00068 
00069 class VTK_PARALLEL_EXPORT vtkMultiProcessController : public vtkObject
00070 {
00071 public:
00072   vtkTypeMacro(vtkMultiProcessController,vtkObject);
00073   void PrintSelf(ostream& os, vtkIndent indent);
00074 
00078   virtual void Initialize(int* vtkNotUsed(argc), char*** vtkNotUsed(argv))=0;
00079 
00081 
00084   virtual void Initialize(int* vtkNotUsed(argc), char*** vtkNotUsed(argv),
00085                           int initializedExternally)=0;
00087 
00090   virtual void Finalize()=0;
00091 
00095   virtual void Finalize(int finalizedExternally)=0;
00096 
00098 
00101   void SetNumberOfProcesses(int num);
00102   int GetNumberOfProcesses();
00104 
00105   //BTX
00109   void SetSingleMethod(vtkProcessFunctionType, void *data);
00110   
00112 
00115   void SetSingleProcessObject(vtkProcess *p);
00116   //ETX
00118 
00122   virtual void SingleMethodExecute() = 0;
00123   
00124   //BTX
00126 
00130   void SetMultipleMethod(int index, vtkProcessFunctionType, void *data); 
00131   //ETX
00133 
00137   virtual void MultipleMethodExecute() = 0;
00138 
00140   int GetLocalProcessId();
00141 
00146   static vtkMultiProcessController *GetGlobalController();
00147 
00150   virtual void CreateOutputWindow() = 0;
00151 
00153 
00163   virtual vtkMultiProcessController *CreateSubController(
00164                                                         vtkProcessGroup *group);
00166 
00168 
00177   virtual vtkMultiProcessController *PartitionController(int localColor,
00178                                                          int localKey);
00180   
00181   //------------------ RMIs --------------------
00182   //BTX
00193   unsigned long AddRMI(vtkRMIFunctionType, void *localArg, int tag);
00194   
00196   int RemoveFirstRMI(int tag);
00197 
00200   int RemoveRMI(unsigned long id);
00201 
00203 
00204   void RemoveRMI(vtkRMIFunctionType f, void *arg, int tag)
00205     {f = f; arg = arg; tag = tag; vtkErrorMacro("RemoveRMI Not Implemented Yet");};
00207 
00212   unsigned long AddRMICallback(vtkRMIFunctionType, void* localArg, int tag);
00213 
00217   void RemoveAllRMICallbacks(int tag);
00218 
00220   bool RemoveRMICallback(unsigned long id);
00221 
00222   //ETX
00223   
00225   void TriggerRMI(int remoteProcessId, void *arg, int argLength, int tag);
00226 
00229   void TriggerBreakRMIs();
00230 
00232 
00233   void TriggerRMI(int remoteProcessId, const char *arg, int tag) 
00234     { this->TriggerRMI(remoteProcessId, (void*)arg, 
00235                        static_cast<int>(strlen(arg))+1, tag); }
00237 
00239 
00240   void TriggerRMI(int remoteProcessId, int tag)
00241     { this->TriggerRMI(remoteProcessId, NULL, 0, tag); }
00243 
00245 
00251   void TriggerRMIOnAllChildren(void *arg, int argLength, int tag);
00252   void TriggerRMIOnAllChildren(const char *arg, int tag) 
00253     { 
00254     this->TriggerRMIOnAllChildren(
00255       (void*)arg, static_cast<int>(strlen(arg))+1, tag);
00256     }
00257   void TriggerRMIOnAllChildren(int tag)
00258     { 
00259     this->TriggerRMIOnAllChildren(NULL, 0, tag);
00260     }
00262 
00264 
00271   int ProcessRMIs(int reportErrors, int dont_loop = 0);
00272   int ProcessRMIs();
00274  
00276 
00279   vtkSetMacro(BreakFlag, int);
00280   vtkGetMacro(BreakFlag, int);
00282 
00284 
00286   vtkGetObjectMacro(Communicator, vtkCommunicator);
00288 
00290 
00291   static int GetBreakRMITag() { return BREAK_RMI_TAG; }
00292   static int GetRMITag() { return RMI_TAG; }
00293   static int GetRMIArgTag() { return RMI_ARG_TAG; }  
00295   
00296 //BTX
00297 
00298   enum Errors 
00299   {
00300     RMI_NO_ERROR,
00301     RMI_TAG_ERROR,
00302     RMI_ARG_ERROR
00303   };
00304 
00305   enum Consts 
00306   {
00307     ANY_SOURCE     = -1,
00308     INVALID_SOURCE = -2
00309   };
00310 
00311   enum Tags 
00312   {
00313     RMI_TAG        = 1,
00314     RMI_ARG_TAG    = 2,
00315     BREAK_RMI_TAG  = 3,
00316     XML_WRITER_DATA_INFO = 4
00317   };
00318 
00319 //ETX
00320 
00322   void Barrier();
00323 
00324   static void SetGlobalController(vtkMultiProcessController *controller);
00325 
00326   //------------------ Communication --------------------
00327   
00329 
00334   int Send(const int* data, vtkIdType length, int remoteProcessId, int tag);
00335   int Send(const unsigned int* data, vtkIdType length, int remoteProcessId, int tag);
00336   int Send(const unsigned long* data, vtkIdType length, int remoteProcessId, 
00337            int tag);
00338   int Send(const char* data, vtkIdType length, int remoteProcessId, int tag);
00339   int Send(const unsigned char* data, vtkIdType length, int remoteProcessId, int tag);
00340   int Send(const float* data, vtkIdType length, int remoteProcessId, int tag);
00341   int Send(const double* data, vtkIdType length, int remoteProcessId, int tag);
00342 #ifdef VTK_USE_64BIT_IDS
00343   int Send(const vtkIdType* data, vtkIdType length, int remoteProcessId, int tag);
00344 #endif
00345   int Send(vtkDataObject *data, int remoteId, int tag);
00346   int Send(vtkDataArray *data, int remoteId, int tag);
00348 
00349 //BTX
00351 
00356   int Send(const vtkMultiProcessStream& stream, int remoteId, int tag);
00357 //ETX
00359 
00361 
00369   int Receive(int* data, vtkIdType maxlength, int remoteProcessId, int tag);
00370   int Receive(unsigned int* data, vtkIdType maxlength, int remoteProcessId, int tag);
00371   int Receive(unsigned long* data, vtkIdType maxlength, int remoteProcessId, 
00372               int tag);
00373   int Receive(char* data, vtkIdType maxlength, int remoteProcessId, int tag);
00374   int Receive(unsigned char* data, vtkIdType maxlength, int remoteProcessId, int tag);
00375   int Receive(float* data, vtkIdType maxlength, int remoteProcessId, int tag);
00376   int Receive(double* data, vtkIdType maxlength, int remoteProcessId, int tag);
00377 #ifdef VTK_USE_64BIT_IDS
00378   int Receive(vtkIdType* data, vtkIdType maxlength, int remoteProcessId, int tag);
00379 #endif
00380   int Receive(vtkDataObject* data, int remoteId, int tag);
00381   int Receive(vtkDataArray* data, int remoteId, int tag);
00382 //BTX
00383   // Description:
00384   // Receive a stream from the other processes.
00385   int Receive(vtkMultiProcessStream& stream, int remoteId, int tag);
00386 //ETX
00387   vtkDataObject *ReceiveDataObject(int remoteId, int tag);
00389 
00397   vtkIdType GetCount();
00398 
00399 
00400   //---------------------- Collective Operations ----------------------
00401 
00403 
00406   int Broadcast(int *data, vtkIdType length, int srcProcessId) {
00407     return this->Communicator->Broadcast(data, length, srcProcessId);
00408   }
00409   int Broadcast(unsigned int *data, vtkIdType length, int srcProcessId) {
00410     return this->Communicator->Broadcast(data, length, srcProcessId);
00411   }
00412   int Broadcast(unsigned long *data, vtkIdType length, int srcProcessId) {
00413     return this->Communicator->Broadcast(data, length, srcProcessId);
00414   }
00415   int Broadcast(unsigned char *data, vtkIdType length, int srcProcessId) {
00416     return this->Communicator->Broadcast(data, length, srcProcessId);
00417   }
00418   int Broadcast(char *data, vtkIdType length, int srcProcessId) {
00419     return this->Communicator->Broadcast(data, length, srcProcessId);
00420   }
00421   int Broadcast(float *data, vtkIdType length, int srcProcessId) {
00422     return this->Communicator->Broadcast(data, length, srcProcessId);
00423   }
00424   int Broadcast(double *data, vtkIdType length, int srcProcessId) {
00425     return this->Communicator->Broadcast(data, length, srcProcessId);
00426   }
00427 #ifdef VTK_USE_64BIT_IDS
00428   int Broadcast(vtkIdType *data, vtkIdType length, int srcProcessId) {
00429     return this->Communicator->Broadcast(data, length, srcProcessId);
00430   }
00431 #endif
00432   int Broadcast(vtkDataObject *data, int srcProcessId) {
00433     return this->Communicator->Broadcast(data, srcProcessId);
00434   }
00435   int Broadcast(vtkDataArray *data, int srcProcessId) {
00436     return this->Communicator->Broadcast(data, srcProcessId);
00437   }
00438 //BTX
00439   int Broadcast(vtkMultiProcessStream& stream, int srcProcessId) {
00440     return this->Communicator->Broadcast(stream, srcProcessId);
00441   }
00442 //ETX
00444 
00446 
00454   int Gather(const int *sendBuffer, int *recvBuffer,
00455              vtkIdType length, int destProcessId) {
00456     return this->Communicator->Gather(sendBuffer, recvBuffer, length,
00457                                       destProcessId);
00458   }
00459   int Gather(const unsigned long *sendBuffer, unsigned long *recvBuffer,
00460              vtkIdType length, int destProcessId) {
00461     return this->Communicator->Gather(sendBuffer, recvBuffer, length,
00462                                       destProcessId);
00463   }
00464   int Gather(const unsigned char *sendBuffer, unsigned char *recvBuffer,
00465              vtkIdType length, int destProcessId) {
00466     return this->Communicator->Gather(sendBuffer, recvBuffer, length,
00467                                       destProcessId);
00468   }
00469   int Gather(const char *sendBuffer, char *recvBuffer,
00470              vtkIdType length, int destProcessId) {
00471     return this->Communicator->Gather(sendBuffer, recvBuffer, length,
00472                                       destProcessId);
00473   }
00474   int Gather(const float *sendBuffer, float *recvBuffer,
00475              vtkIdType length, int destProcessId) {
00476     return this->Communicator->Gather(sendBuffer, recvBuffer, length,
00477                                       destProcessId);
00478   }
00479   int Gather(const double *sendBuffer, double *recvBuffer,
00480              vtkIdType length, int destProcessId) {
00481     return this->Communicator->Gather(sendBuffer, recvBuffer, length,
00482                                       destProcessId);
00483   }
00484 #ifdef VTK_USE_64BIT_IDS
00485   int Gather(const vtkIdType *sendBuffer, vtkIdType *recvBuffer,
00486              vtkIdType length, int destProcessId) {
00487     return this->Communicator->Gather(sendBuffer, recvBuffer, length,
00488                                       destProcessId);
00489   }
00490 #endif
00491   int Gather(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer,
00492              int destProcessId) {
00493     return this->Communicator->Gather(sendBuffer, recvBuffer, destProcessId);
00494   }
00496 
00498 
00508   int GatherV(const int* sendBuffer, int* 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   }
00515   int GatherV(const unsigned long* sendBuffer, unsigned long* recvBuffer, 
00516               vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets,
00517               int destProcessId) {
00518     return this->Communicator->GatherV(sendBuffer, recvBuffer,
00519                                        sendLength, recvLengths,
00520                                        offsets, destProcessId);
00521   }
00522   int GatherV(const unsigned char* sendBuffer, unsigned char* recvBuffer, 
00523               vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets,
00524               int destProcessId) {
00525     return this->Communicator->GatherV(sendBuffer, recvBuffer,
00526                                        sendLength, recvLengths,
00527                                        offsets, destProcessId);
00528   }
00529   int GatherV(const char* sendBuffer, char* recvBuffer, 
00530               vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets,
00531               int destProcessId) {
00532     return this->Communicator->GatherV(sendBuffer, recvBuffer,
00533                                        sendLength, recvLengths,
00534                                        offsets, destProcessId);
00535   }
00536   int GatherV(const float* sendBuffer, float* recvBuffer, 
00537               vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets,
00538               int destProcessId) {
00539     return this->Communicator->GatherV(sendBuffer, recvBuffer,
00540                                        sendLength, recvLengths,
00541                                        offsets, destProcessId);
00542   }
00543   int GatherV(const double* sendBuffer, double* recvBuffer, 
00544               vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets,
00545               int destProcessId) {
00546     return this->Communicator->GatherV(sendBuffer, recvBuffer,
00547                                        sendLength, recvLengths,
00548                                        offsets, destProcessId);
00549   }
00550 #ifdef VTK_USE_64BIT_IDS
00551   int GatherV(const vtkIdType* sendBuffer, vtkIdType* recvBuffer, 
00552               vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets,
00553               int destProcessId) {
00554     return this->Communicator->GatherV(sendBuffer, recvBuffer,
00555                                        sendLength, recvLengths,
00556                                        offsets, destProcessId);
00557   }
00558 #endif
00559   int GatherV(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer,
00560               vtkIdType *recvLengths, vtkIdType *offsets, int destProcessId) {
00561     return this->Communicator->GatherV(sendBuffer, recvBuffer,
00562                                        recvLengths, offsets,
00563                                        destProcessId);
00564   }
00566 
00568 
00573   int GatherV(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer,
00574               int destProcessId) {
00575     return this->Communicator->GatherV(sendBuffer, recvBuffer, destProcessId);
00576   }
00578 
00580 
00585   int Scatter(const int *sendBuffer, int *recvBuffer,
00586               vtkIdType length, int srcProcessId) {
00587     return this->Communicator->Scatter(sendBuffer, recvBuffer, length,
00588                                        srcProcessId);
00589   }
00590   int Scatter(const unsigned long *sendBuffer, unsigned long *recvBuffer,
00591               vtkIdType length, int srcProcessId) {
00592     return this->Communicator->Scatter(sendBuffer, recvBuffer, length,
00593                                        srcProcessId);
00594   }
00595   int Scatter(const unsigned char *sendBuffer, unsigned char *recvBuffer,
00596               vtkIdType length, int srcProcessId) {
00597     return this->Communicator->Scatter(sendBuffer, recvBuffer, length,
00598                                        srcProcessId);
00599   }
00600   int Scatter(const char *sendBuffer, char *recvBuffer,
00601               vtkIdType length, int srcProcessId) {
00602     return this->Communicator->Scatter(sendBuffer, recvBuffer, length,
00603                                        srcProcessId);
00604   }
00605   int Scatter(const float *sendBuffer, float *recvBuffer,
00606               vtkIdType length, int srcProcessId) {
00607     return this->Communicator->Scatter(sendBuffer, recvBuffer, length,
00608                                        srcProcessId);
00609   }
00610   int Scatter(const double *sendBuffer, double *recvBuffer,
00611               vtkIdType length, int srcProcessId) {
00612     return this->Communicator->Scatter(sendBuffer, recvBuffer, length,
00613                                        srcProcessId);
00614   }
00615 #ifdef VTK_USE_64BIT_IDS
00616   int Scatter(const vtkIdType *sendBuffer, vtkIdType *recvBuffer,
00617               vtkIdType length, int srcProcessId) {
00618     return this->Communicator->Scatter(sendBuffer, recvBuffer, length,
00619                                        srcProcessId);
00620   }
00621 #endif
00622   int Scatter(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer,
00623               int srcProcessId) {
00624     return this->Communicator->Scatter(sendBuffer, recvBuffer, srcProcessId);
00625   }
00627 
00629 
00635   int ScatterV(const int *sendBuffer, int *recvBuffer,
00636                vtkIdType *sendLengths, vtkIdType *offsets,
00637                vtkIdType recvLength, int srcProcessId) {
00638     return this->Communicator->ScatterV(sendBuffer, recvBuffer,
00639                                         sendLengths, offsets, recvLength,
00640                                         srcProcessId);
00641   }
00642   int ScatterV(const unsigned long *sendBuffer, unsigned long *recvBuffer,
00643                vtkIdType *sendLengths, vtkIdType *offsets,
00644                vtkIdType recvLength, int srcProcessId) {
00645     return this->Communicator->ScatterV(sendBuffer, recvBuffer,
00646                                         sendLengths, offsets, recvLength,
00647                                         srcProcessId);
00648   }
00649   int ScatterV(const unsigned char *sendBuffer, unsigned char *recvBuffer,
00650                vtkIdType *sendLengths, vtkIdType *offsets,
00651                vtkIdType recvLength, int srcProcessId) {
00652     return this->Communicator->ScatterV(sendBuffer, recvBuffer,
00653                                         sendLengths, offsets, recvLength,
00654                                         srcProcessId);
00655   }
00656   int ScatterV(const char *sendBuffer, char *recvBuffer,
00657                vtkIdType *sendLengths, vtkIdType *offsets,
00658                vtkIdType recvLength, int srcProcessId) {
00659     return this->Communicator->ScatterV(sendBuffer, recvBuffer,
00660                                         sendLengths, offsets, recvLength,
00661                                         srcProcessId);
00662   }
00663   int ScatterV(const float *sendBuffer, float *recvBuffer,
00664                vtkIdType *sendLengths, vtkIdType *offsets,
00665                vtkIdType recvLength, int srcProcessId) {
00666     return this->Communicator->ScatterV(sendBuffer, recvBuffer,
00667                                         sendLengths, offsets, recvLength,
00668                                         srcProcessId);
00669   }
00670   int ScatterV(const double *sendBuffer, double *recvBuffer,
00671                vtkIdType *sendLengths, vtkIdType *offsets,
00672                vtkIdType recvLength, int srcProcessId) {
00673     return this->Communicator->ScatterV(sendBuffer, recvBuffer,
00674                                         sendLengths, offsets, recvLength,
00675                                         srcProcessId);
00676   }
00677 #ifdef VTK_USE_64BIT_IDS
00678   int ScatterV(const vtkIdType *sendBuffer, vtkIdType *recvBuffer,
00679                vtkIdType *sendLengths, vtkIdType *offsets,
00680                vtkIdType recvLength, int srcProcessId) {
00681     return this->Communicator->ScatterV(sendBuffer, recvBuffer,
00682                                         sendLengths, offsets, recvLength,
00683                                         srcProcessId);
00684   }
00685 #endif
00686 
00687 
00689 
00690   int AllGather(const int *sendBuffer, int *recvBuffer, vtkIdType length) {
00691     return this->Communicator->AllGather(sendBuffer, recvBuffer, length);
00692   }
00693   int AllGather(const unsigned long *sendBuffer,
00694                 unsigned long *recvBuffer, vtkIdType length) {
00695     return this->Communicator->AllGather(sendBuffer, recvBuffer, length);
00696   }
00697   int AllGather(const unsigned char *sendBuffer,
00698                 unsigned char *recvBuffer, vtkIdType length) {
00699     return this->Communicator->AllGather(sendBuffer, recvBuffer, length);
00700   }
00701   int AllGather(const char *sendBuffer, char *recvBuffer, vtkIdType length) {
00702     return this->Communicator->AllGather(sendBuffer, recvBuffer, length);
00703   }
00704   int AllGather(const float *sendBuffer, float *recvBuffer, vtkIdType length) {
00705     return this->Communicator->AllGather(sendBuffer, recvBuffer, length);
00706   }
00707   int AllGather(const double *sendBuffer,
00708                 double *recvBuffer, vtkIdType length) {
00709     return this->Communicator->AllGather(sendBuffer, recvBuffer, length);
00710   }
00711 #ifdef VTK_USE_64BIT_IDS
00712   int AllGather(const vtkIdType *sendBuffer, vtkIdType *recvBuffer,
00713                 vtkIdType length) {
00714     return this->Communicator->AllGather(sendBuffer, recvBuffer, length);
00715   }
00716 #endif
00717   int AllGather(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer) {
00718     return this->Communicator->AllGather(sendBuffer, recvBuffer);
00719   }
00721 
00723 
00724   int AllGatherV(const int* sendBuffer, int* recvBuffer, 
00725                  vtkIdType sendLength, vtkIdType* recvLengths,
00726                  vtkIdType* offsets) {
00727     return this->Communicator->AllGatherV(sendBuffer, recvBuffer,
00728                                           sendLength, recvLengths,
00729                                           offsets);
00730   }
00731   int AllGatherV(const unsigned long* sendBuffer, unsigned long* recvBuffer, 
00732                  vtkIdType sendLength, vtkIdType* recvLengths,
00733                  vtkIdType* offsets) {
00734     return this->Communicator->AllGatherV(sendBuffer, recvBuffer,
00735                                           sendLength, recvLengths,
00736                                           offsets);
00737   }
00738   int AllGatherV(const unsigned char* sendBuffer, unsigned char* recvBuffer, 
00739                  vtkIdType sendLength, vtkIdType* recvLengths,
00740                  vtkIdType* offsets) {
00741     return this->Communicator->AllGatherV(sendBuffer, recvBuffer,
00742                                           sendLength, recvLengths,
00743                                           offsets);
00744   }
00745   int AllGatherV(const char* sendBuffer, char* recvBuffer, 
00746                  vtkIdType sendLength, vtkIdType* recvLengths,
00747                  vtkIdType* offsets) {
00748     return this->Communicator->AllGatherV(sendBuffer, recvBuffer,
00749                                           sendLength, recvLengths,
00750                                           offsets);
00751   }
00752   int AllGatherV(const float* sendBuffer, float* recvBuffer, 
00753                  vtkIdType sendLength, vtkIdType* recvLengths,
00754                  vtkIdType* offsets) {
00755     return this->Communicator->AllGatherV(sendBuffer, recvBuffer,
00756                                           sendLength, recvLengths,
00757                                           offsets);
00758   }
00759   int AllGatherV(const double* sendBuffer, double* recvBuffer, 
00760                  vtkIdType sendLength, vtkIdType* recvLengths,
00761                  vtkIdType* offsets) {
00762     return this->Communicator->AllGatherV(sendBuffer, recvBuffer,
00763                                           sendLength, recvLengths,
00764                                           offsets);
00765   }
00766 #ifdef VTK_USE_64BIT_IDS
00767   int AllGatherV(const vtkIdType* sendBuffer, vtkIdType* recvBuffer, 
00768                  vtkIdType sendLength, vtkIdType* recvLengths,
00769                  vtkIdType* offsets) {
00770     return this->Communicator->AllGatherV(sendBuffer, recvBuffer,
00771                                           sendLength, recvLengths,
00772                                           offsets);
00773   }
00774 #endif
00775   int AllGatherV(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer,
00776                  vtkIdType *recvLengths, vtkIdType *offsets) {
00777     return this->Communicator->AllGatherV(sendBuffer, recvBuffer,
00778                                           recvLengths, offsets);
00779   }
00781 
00783 
00788   int AllGatherV(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer) {
00789     return this->Communicator->AllGatherV(sendBuffer, recvBuffer);
00790   }
00792 
00794 
00797   int Reduce(const int *sendBuffer, int *recvBuffer,
00798              vtkIdType length, int operation, int destProcessId) {
00799     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00800                                       operation, destProcessId);
00801   }
00802   int Reduce(const unsigned int *sendBuffer, unsigned int *recvBuffer,
00803              vtkIdType length, int operation, int destProcessId) {
00804     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00805                                       operation, destProcessId);
00806   }
00807   int Reduce(const unsigned long *sendBuffer, unsigned long *recvBuffer,
00808              vtkIdType length, int operation, int destProcessId) {
00809     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00810                                       operation, destProcessId);
00811   }
00812   int Reduce(const unsigned char *sendBuffer, unsigned char *recvBuffer,
00813              vtkIdType length, int operation, int destProcessId) {
00814     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00815                                       operation, destProcessId);
00816   }
00817   int Reduce(const char *sendBuffer, char *recvBuffer,
00818              vtkIdType length, int operation, int destProcessId) {
00819     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00820                                       operation, destProcessId);
00821   }
00822   int Reduce(const float *sendBuffer, float *recvBuffer,
00823              vtkIdType length, int operation, int destProcessId) {
00824     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00825                                       operation, destProcessId);
00826   }
00827   int Reduce(const double *sendBuffer, double *recvBuffer,
00828              vtkIdType length, int operation, int destProcessId) {
00829     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00830                                       operation, destProcessId);
00831   }
00832 #ifdef VTK_USE_64BIT_IDS
00833   int Reduce(const vtkIdType *sendBuffer, vtkIdType *recvBuffer,
00834              vtkIdType length, int operation, int destProcessId) {
00835     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00836                                       operation, destProcessId);
00837   }
00838 #endif
00839   int Reduce(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer,
00840              int operation, int destProcessId) {
00841     return this->Communicator->Reduce(sendBuffer, recvBuffer,
00842                                       operation, destProcessId);
00843   }
00845 
00846 //BTX
00848 
00851   int Reduce(const int *sendBuffer, int *recvBuffer,
00852              vtkIdType length, vtkCommunicator::Operation *operation,
00853              int destProcessId) {
00854     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00855                                       operation, destProcessId);
00856   }
00857   int Reduce(const unsigned long *sendBuffer, unsigned long *recvBuffer,
00858              vtkIdType length, vtkCommunicator::Operation *operation,
00859              int destProcessId) {
00860     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00861                                       operation, destProcessId);
00862   }
00863   int Reduce(const unsigned char *sendBuffer, unsigned char *recvBuffer,
00864              vtkIdType length, vtkCommunicator::Operation *operation,
00865              int destProcessId) {
00866     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00867                                       operation, destProcessId);
00868   }
00869   int Reduce(const char *sendBuffer, char *recvBuffer,
00870              vtkIdType length, vtkCommunicator::Operation *operation,
00871              int destProcessId) {
00872     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00873                                       operation, destProcessId);
00874   }
00875   int Reduce(const float *sendBuffer, float *recvBuffer,
00876              vtkIdType length, vtkCommunicator::Operation *operation,
00877              int destProcessId) {
00878     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00879                                       operation, destProcessId);
00880   }
00881   int Reduce(const double *sendBuffer, double *recvBuffer,
00882              vtkIdType length, vtkCommunicator::Operation *operation,
00883              int destProcessId) {
00884     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00885                                       operation, destProcessId);
00886   }
00887 #ifdef VTK_USE_64BIT_IDS
00888   int Reduce(const vtkIdType *sendBuffer, vtkIdType *recvBuffer,
00889              vtkIdType length, vtkCommunicator::Operation *operation,
00890              int destProcessId) {
00891     return this->Communicator->Reduce(sendBuffer, recvBuffer, length,
00892                                       operation, destProcessId);
00893   }
00894 #endif
00895   int Reduce(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer,
00896              vtkCommunicator::Operation *operation, int destProcessId) {
00897     return this->Communicator->Reduce(sendBuffer, recvBuffer,
00898                                       operation, destProcessId);
00899   }
00900 //ETX
00902 
00904 
00906   int AllReduce(const int *sendBuffer, int *recvBuffer,
00907                 vtkIdType length, int operation) {
00908     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00909                                          operation);
00910   }
00911   int AllReduce(const unsigned long *sendBuffer, unsigned long *recvBuffer,
00912                 vtkIdType length, int operation) {
00913     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00914                                          operation);
00915   }
00916   int AllReduce(const unsigned char *sendBuffer, unsigned char *recvBuffer,
00917                 vtkIdType length, int operation) {
00918     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00919                                          operation);
00920   }
00921   int AllReduce(const char *sendBuffer, char *recvBuffer,
00922                 vtkIdType length, int operation) {
00923     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00924                                          operation);
00925   }
00926   int AllReduce(const float *sendBuffer, float *recvBuffer,
00927                 vtkIdType length, int operation) {
00928     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00929                                          operation);
00930   }
00931   int AllReduce(const double *sendBuffer, double *recvBuffer,
00932                 vtkIdType length, int operation) {
00933     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00934                                          operation);
00935   }
00936 #ifdef VTK_USE_64BIT_IDS
00937   int AllReduce(const vtkIdType *sendBuffer, vtkIdType *recvBuffer,
00938                 vtkIdType length, int operation) {
00939     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00940                                          operation);
00941   }
00942 #endif
00943   int AllReduce(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer,
00944                 int operation) {
00945     return this->Communicator->AllReduce(sendBuffer, recvBuffer, operation);
00946   }
00947 //BTX
00948   int AllReduce(const int *sendBuffer, int *recvBuffer,
00949                 vtkIdType length, vtkCommunicator::Operation *operation) {
00950     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00951                                          operation);
00952   }
00953   int AllReduce(const unsigned long *sendBuffer, unsigned long *recvBuffer,
00954                 vtkIdType length, vtkCommunicator::Operation *operation) {
00955     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00956                                          operation);
00957   }
00958   int AllReduce(const unsigned char *sendBuffer, unsigned char *recvBuffer,
00959                 vtkIdType length, vtkCommunicator::Operation *operation) {
00960     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00961                                          operation);
00962   }
00963   int AllReduce(const char *sendBuffer, char *recvBuffer,
00964                 vtkIdType length, vtkCommunicator::Operation *operation) {
00965     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00966                                          operation);
00967   }
00968   int AllReduce(const float *sendBuffer, float *recvBuffer,
00969                 vtkIdType length, vtkCommunicator::Operation *operation) {
00970     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00971                                          operation);
00972   }
00973   int AllReduce(const double *sendBuffer, double *recvBuffer,
00974                 vtkIdType length, vtkCommunicator::Operation *operation) {
00975     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00976                                          operation);
00977   }
00978 #ifdef VTK_USE_64BIT_IDS
00979   int AllReduce(const vtkIdType *sendBuffer, vtkIdType *recvBuffer,
00980                 vtkIdType length, vtkCommunicator::Operation *operation) {
00981     return this->Communicator->AllReduce(sendBuffer, recvBuffer, length,
00982                                          operation);
00983   }
00984 #endif
00985   int AllReduce(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer,
00986                 vtkCommunicator::Operation *operation) {
00987     return this->Communicator->AllReduce(sendBuffer, recvBuffer, operation);
00988   }
00989 //ETX
00991 
00992 // Internally implemented RMI to break the process loop.
00993 
00994 protected:
00995   vtkMultiProcessController();
00996   ~vtkMultiProcessController();
00997 
00999 
01002   virtual void TriggerRMIInternal(int remoteProcessId, 
01003     void* arg, int argLength, int rmiTag, bool propagate);
01005 
01006   vtkProcessFunctionType      SingleMethod;
01007   void                       *SingleData;
01008 
01009   void GetMultipleMethod(int index, vtkProcessFunctionType &func, void *&data);
01010   
01011   // This is a flag that can be used by the ports to break
01012   // their update loop. (same as ProcessRMIs)
01013   int BreakFlag;
01014 
01015   void ProcessRMI(int remoteProcessId, void *arg, int argLength, int rmiTag);
01016 
01017   // This method implements "GetGlobalController".  
01018   // It needs to be virtual and static.
01019   virtual vtkMultiProcessController *GetLocalController();
01020 
01021   
01022   // This flag can force deep copies during send.
01023   int ForceDeepCopy;
01024 
01025   vtkOutputWindow* OutputWindow;
01026 
01027   // Note that since the communicators can be created differently
01028   // depending on the type of controller, the subclasses are
01029   // responsible of deleting them.
01030   vtkCommunicator* Communicator;
01031 
01032   // Communicator which is a copy of the current user
01033   // level communicator except the context; i.e. even if the tags 
01034   // are the same, the RMI messages will not interfere with user 
01035   // level messages. 
01036   // Note that since the communicators can be created differently
01037   // depending on the type of controller, the subclasses are
01038   // responsible of deleting them.
01039   vtkCommunicator* RMICommunicator;
01040 
01041 private:
01042   vtkMultiProcessController(const vtkMultiProcessController&);  // Not implemented.
01043   void operator=(const vtkMultiProcessController&);  // Not implemented.
01044 
01045   unsigned long RMICount;
01046 
01047 //BTX
01048   class vtkInternal;
01049   vtkInternal *Internal;
01050 //ETX
01051 };
01052 
01053 
01054 inline int vtkMultiProcessController::Send(vtkDataObject *data, 
01055                                            int remoteProcessId, int tag)
01056 {
01057   if (this->Communicator)
01058     {
01059     return this->Communicator->Send(data, remoteProcessId, tag);
01060     }
01061   else
01062     {
01063     return 0;
01064     }
01065 }
01066 
01067 inline int vtkMultiProcessController::Send(vtkDataArray *data, 
01068                                            int remoteProcessId, int tag)
01069 {
01070   if (this->Communicator)
01071     {
01072     return this->Communicator->Send(data, remoteProcessId, tag);
01073     }
01074   else
01075     {
01076     return 0;
01077     }
01078 }
01079 
01080 inline int vtkMultiProcessController::Send(const int* data, vtkIdType length, 
01081                                            int remoteProcessId, int tag)
01082 {
01083   if (this->Communicator)
01084     {
01085     return this->Communicator->Send(data, length, remoteProcessId, tag);
01086     }
01087   else
01088     {
01089     return 0;
01090     }
01091 }
01092 
01093 inline int vtkMultiProcessController::Send(const unsigned int* data, vtkIdType length, 
01094                                            int remoteProcessId, int tag)
01095 {
01096   if (this->Communicator)
01097     {
01098     return this->Communicator->Send(data, length, remoteProcessId, tag);
01099     }
01100   else
01101     {
01102     return 0;
01103     }
01104 }
01105 
01106 inline int vtkMultiProcessController::Send(const unsigned long* data, 
01107                                            vtkIdType length,
01108                                            int remoteProcessId,
01109                                            int tag)
01110 {
01111   if (this->Communicator)
01112     {
01113     return this->Communicator->Send(data, length, remoteProcessId, tag);
01114     }
01115   else
01116     {
01117     return 0;
01118     }
01119 }
01120 
01121 inline int vtkMultiProcessController::Send(const char* data, vtkIdType length, 
01122                                            int remoteProcessId, int tag)
01123 {
01124   if (this->Communicator)
01125     {
01126     return this->Communicator->Send(data, length, remoteProcessId, tag);
01127     }
01128   else
01129     {
01130     return 0;
01131     }
01132 }
01133 
01134 inline int vtkMultiProcessController::Send(const unsigned char* data,
01135                                            vtkIdType length, 
01136                                            int remoteProcessId, int tag)
01137 {
01138   if (this->Communicator)
01139     {
01140     return this->Communicator->Send(data, length, remoteProcessId, tag);
01141     }
01142   else
01143     {
01144     return 0;
01145     }
01146 }
01147 
01148 inline int vtkMultiProcessController::Send(const float* data, vtkIdType length, 
01149                                            int remoteProcessId, int tag)
01150 {
01151   if (this->Communicator)
01152     {
01153     return this->Communicator->Send(data, length, remoteProcessId, tag);
01154     }
01155   else
01156     {
01157     return 0;
01158     }
01159 }
01160 
01161 inline int vtkMultiProcessController::Send(const double* data, vtkIdType length,
01162                                            int remoteProcessId, int tag)
01163 {
01164   if (this->Communicator)
01165     {
01166     return this->Communicator->Send(data, length, remoteProcessId, tag);
01167     }
01168   else
01169     {
01170     return 0;
01171     }
01172 }
01173 
01174 #ifdef VTK_USE_64BIT_IDS
01175 inline int vtkMultiProcessController::Send(const vtkIdType* data,
01176                                            vtkIdType length, 
01177                                            int remoteProcessId, int tag)
01178 {
01179   if (this->Communicator)
01180     {
01181     return this->Communicator->Send(data, length, remoteProcessId, tag);
01182     }
01183   else
01184     {
01185     return 0;
01186     }
01187 }
01188 #endif
01189 
01190 inline int vtkMultiProcessController::Send(const vtkMultiProcessStream& stream,
01191   int remoteId, int tag)
01192 {
01193   if (this->Communicator)
01194     {
01195     return this->Communicator->Send(stream, remoteId, tag);
01196     }
01197   return 0;
01198 }
01199 
01200 inline int vtkMultiProcessController::Receive(vtkDataObject* data, 
01201                                               int remoteProcessId, int tag)
01202 {
01203   if (this->Communicator)
01204     {
01205     return this->Communicator->Receive(data, remoteProcessId, tag);
01206     }
01207   else
01208     {
01209     return 0;
01210     }
01211 }
01212 
01213 inline vtkDataObject* vtkMultiProcessController::ReceiveDataObject(
01214   int remoteProcessId, int tag)
01215 {
01216   if (this->Communicator)
01217     {
01218     return this->Communicator->ReceiveDataObject(remoteProcessId, tag);
01219     }
01220   else
01221     {
01222     return 0;
01223     }
01224 }
01225 
01226 inline int vtkMultiProcessController::Receive(vtkDataArray* data, 
01227                                               int remoteProcessId, int tag)
01228 {
01229   if (this->Communicator)
01230     {
01231     return this->Communicator->Receive(data, remoteProcessId, tag);
01232     }
01233   else
01234     {
01235     return 0;
01236     }
01237 }
01238 
01239 inline int vtkMultiProcessController::Receive(int* data, vtkIdType length, 
01240                                               int remoteProcessId, int tag)
01241 {
01242   if (this->Communicator)
01243     {
01244     return this->Communicator->Receive(data, length, remoteProcessId, tag);
01245     }
01246   else
01247     {
01248     return 0;
01249     }
01250 }
01251 
01252 inline int vtkMultiProcessController::Receive(unsigned int* data, vtkIdType length, 
01253                                               int remoteProcessId, int tag)
01254 {
01255   if (this->Communicator)
01256     {
01257     return this->Communicator->Receive(data, length, remoteProcessId, tag);
01258     }
01259   else
01260     {
01261     return 0;
01262     }
01263 }
01264 
01265 inline int vtkMultiProcessController::Receive(unsigned long* data, 
01266                                               vtkIdType length,
01267                                               int remoteProcessId, 
01268                                               int tag)
01269 {
01270   if (this->Communicator)
01271     {
01272     return this->Communicator->Receive(data, length, remoteProcessId, tag);
01273     }
01274   else
01275     {
01276     return 0;
01277     }
01278 }
01279 
01280 inline int vtkMultiProcessController::Receive(char* data, vtkIdType length, 
01281                                               int remoteProcessId, int tag)
01282 {
01283   if (this->Communicator)
01284     {
01285     return this->Communicator->Receive(data, length, remoteProcessId, tag);
01286     }
01287   else
01288     {
01289     return 0;
01290     }
01291 }
01292 
01293 inline int vtkMultiProcessController::Receive(unsigned char* data,
01294                                               vtkIdType length, 
01295                                               int remoteProcessId, int tag)
01296 {
01297   if (this->Communicator)
01298     {
01299     return this->Communicator->Receive(data, length, remoteProcessId, tag);
01300     }
01301   else
01302     {
01303     return 0;
01304     }
01305 }
01306 
01307 inline int vtkMultiProcessController::Receive(float* data, vtkIdType length, 
01308                                               int remoteProcessId, int tag)
01309 {
01310   if (this->Communicator)
01311     {
01312     return this->Communicator->Receive(data, length, remoteProcessId, tag);
01313     }
01314   else
01315     {
01316     return 0;
01317     }
01318 }
01319 
01320 inline int vtkMultiProcessController::Receive(double* data, vtkIdType length, 
01321                                               int remoteProcessId, int tag)
01322 {
01323   if (this->Communicator)
01324     {
01325     return this->Communicator->Receive(data, length, remoteProcessId, tag);
01326     }
01327   else
01328     {
01329     return 0;
01330     }
01331 }
01332 
01333 #ifdef VTK_USE_64BIT_IDS
01334 inline int vtkMultiProcessController::Receive(vtkIdType* data,
01335                                               vtkIdType length, 
01336                                               int remoteProcessId, int tag)
01337 {
01338   if (this->Communicator)
01339     {
01340     return this->Communicator->Receive(data, length, remoteProcessId, tag);
01341     }
01342   else
01343     {
01344     return 0;
01345     }
01346 }
01347 #endif
01348 
01349 
01350 inline int vtkMultiProcessController::Receive(vtkMultiProcessStream& stream,
01351   int remoteId, int tag)
01352 {
01353   if (this->Communicator)
01354     {
01355     return this->Communicator->Receive(stream, remoteId, tag);
01356     }
01357   return 0;
01358 }
01359 
01360 inline void vtkMultiProcessController::Barrier()
01361 {
01362   if (this->Communicator)
01363     {
01364     this->Communicator->Barrier();
01365     }
01366 }
01367 
01368 inline vtkIdType vtkMultiProcessController::GetCount()
01369 {
01370   if (this->Communicator)
01371     {
01372     return this->Communicator->GetCount();
01373     }
01374   return 0;
01375 }
01376 
01377 #endif