VTK
|
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 =========================================================================*/ 00054 #ifndef vtkMultiProcessController_h 00055 #define vtkMultiProcessController_h 00056 00057 #include "vtkParallelCoreModule.h" // For export macro 00058 #include "vtkObject.h" 00059 00060 #include "vtkCommunicator.h" // Needed for direct access to communicator 00061 00062 class vtkCollection; 00063 class vtkDataObject; 00064 class vtkDataSet; 00065 class vtkImageData; 00066 class vtkMultiProcessController; 00067 class vtkMultiProcessStream; 00068 class vtkOutputWindow; 00069 class vtkProcessGroup; 00070 class vtkProcess; 00071 00072 //BTX 00073 // The type of function that gets called when new processes are initiated. 00074 typedef void (*vtkProcessFunctionType)(vtkMultiProcessController *controller, 00075 void *userData); 00076 00077 // The type of function that gets called when an RMI is triggered. 00078 typedef void (*vtkRMIFunctionType)(void *localArg, 00079 void *remoteArg, int remoteArgLength, 00080 int remoteProcessId); 00081 //ETX 00082 00083 00084 class VTKPARALLELCORE_EXPORT vtkMultiProcessController : public vtkObject 00085 { 00086 public: 00087 vtkTypeMacro(vtkMultiProcessController,vtkObject); 00088 void PrintSelf(ostream& os, vtkIndent indent); 00089 00093 virtual void Initialize(int* vtkNotUsed(argc), char*** vtkNotUsed(argv))=0; 00094 00096 00099 virtual void Initialize(int* vtkNotUsed(argc), char*** vtkNotUsed(argv), 00100 int initializedExternally)=0; 00102 00105 virtual void Finalize()=0; 00106 00110 virtual void Finalize(int finalizedExternally)=0; 00111 00113 00116 void SetNumberOfProcesses(int num); 00117 int GetNumberOfProcesses(); 00119 00120 //BTX 00124 void SetSingleMethod(vtkProcessFunctionType, void *data); 00125 00127 00130 void SetSingleProcessObject(vtkProcess *p); 00131 //ETX 00133 00137 virtual void SingleMethodExecute() = 0; 00138 00139 //BTX 00141 00145 void SetMultipleMethod(int index, vtkProcessFunctionType, void *data); 00146 //ETX 00148 00152 virtual void MultipleMethodExecute() = 0; 00153 00155 int GetLocalProcessId(); 00156 00161 static vtkMultiProcessController *GetGlobalController(); 00162 00165 virtual void CreateOutputWindow() = 0; 00166 00168 00177 virtual vtkMultiProcessController *CreateSubController( 00178 vtkProcessGroup *group); 00180 00182 00191 virtual vtkMultiProcessController *PartitionController(int localColor, 00192 int localKey); 00194 00195 //------------------ RMIs -------------------- 00196 //BTX 00207 virtual unsigned long AddRMI(vtkRMIFunctionType, void *localArg, int tag); 00208 00210 virtual int RemoveFirstRMI(int tag); 00211 00214 virtual int RemoveRMI(unsigned long id); 00215 00217 00218 virtual void RemoveRMI(vtkRMIFunctionType f, void *arg, int tag) 00219 {(void)f; (void)arg; (void)tag; vtkErrorMacro("RemoveRMI Not Implemented Yet");}; 00221 00226 virtual unsigned long AddRMICallback(vtkRMIFunctionType, void* localArg, int tag); 00227 00231 virtual void RemoveAllRMICallbacks(int tag); 00232 00234 virtual bool RemoveRMICallback(unsigned long id); 00235 00236 //ETX 00237 00239 void TriggerRMI(int remoteProcessId, void *arg, int argLength, int tag); 00240 00243 void TriggerBreakRMIs(); 00244 00246 00247 void TriggerRMI(int remoteProcessId, const char *arg, int tag) 00248 { this->TriggerRMI(remoteProcessId, (void*)arg, 00249 static_cast<int>(strlen(arg))+1, tag); } 00251 00253 00254 void TriggerRMI(int remoteProcessId, int tag) 00255 { this->TriggerRMI(remoteProcessId, NULL, 0, tag); } 00257 00259 00265 void TriggerRMIOnAllChildren(void *arg, int argLength, int tag); 00266 void TriggerRMIOnAllChildren(const char *arg, int tag) 00267 { 00268 this->TriggerRMIOnAllChildren( 00269 (void*)arg, static_cast<int>(strlen(arg))+1, tag); 00270 } 00271 void TriggerRMIOnAllChildren(int tag) 00272 { 00273 this->TriggerRMIOnAllChildren(NULL, 0, tag); 00274 } 00275 void BroadcastTriggerRMIOnAllChildren(void* arg, int argLength, int tag); 00277 00279 00286 int ProcessRMIs(int reportErrors, int dont_loop = 0); 00287 int ProcessRMIs(); 00288 int BroadcastProcessRMIs(int reportErrors, int dont_loop=0); 00290 00292 00295 vtkSetMacro(BreakFlag, int); 00296 vtkGetMacro(BreakFlag, int); 00298 00300 00303 vtkSetMacro(BroadcastTriggerRMI,bool); 00304 vtkGetMacro(BroadcastTriggerRMI,bool); 00305 vtkBooleanMacro(BroadcastTriggerRMI,bool); 00307 00309 00311 vtkGetObjectMacro(Communicator, vtkCommunicator); 00313 00315 00316 static int GetBreakRMITag() { return BREAK_RMI_TAG; } 00317 static int GetRMITag() { return RMI_TAG; } 00318 static int GetRMIArgTag() { return RMI_ARG_TAG; } 00320 00321 //BTX 00322 00323 enum Errors 00324 { 00325 RMI_NO_ERROR, 00326 RMI_TAG_ERROR, 00327 RMI_ARG_ERROR 00328 }; 00329 00330 enum Consts 00331 { 00332 ANY_SOURCE = -1, 00333 INVALID_SOURCE = -2 00334 }; 00335 00336 enum Tags 00337 { 00338 RMI_TAG = 1, 00339 RMI_ARG_TAG = 2, 00340 BREAK_RMI_TAG = 3, 00341 XML_WRITER_DATA_INFO = 4 00342 }; 00343 00344 //ETX 00345 00347 void Barrier(); 00348 00349 static void SetGlobalController(vtkMultiProcessController *controller); 00350 00351 //------------------ Communication -------------------- 00352 00354 00359 int Send(const int* data, vtkIdType length, int remoteProcessId, int tag); 00360 int Send(const unsigned int* data, vtkIdType length, int remoteProcessId, int tag); 00361 int Send(const unsigned long* data, vtkIdType length, int remoteProcessId, 00362 int tag); 00363 int Send(const char* data, vtkIdType length, int remoteProcessId, int tag); 00364 int Send(const unsigned char* data, vtkIdType length, int remoteProcessId, int tag); 00365 int Send(const float* data, vtkIdType length, int remoteProcessId, int tag); 00366 int Send(const double* data, vtkIdType length, int remoteProcessId, int tag); 00367 #ifdef VTK_USE_64BIT_IDS 00368 int Send(const vtkIdType* data, vtkIdType length, int remoteProcessId, int tag); 00369 #endif 00370 int Send(vtkDataObject *data, int remoteId, int tag); 00371 int Send(vtkDataArray *data, int remoteId, int tag); 00373 00374 //BTX 00376 00381 int Send(const vtkMultiProcessStream& stream, int remoteId, int tag); 00382 //ETX 00384 00386 00394 int Receive(int* data, vtkIdType maxlength, int remoteProcessId, int tag); 00395 int Receive(unsigned int* data, vtkIdType maxlength, int remoteProcessId, int tag); 00396 int Receive(unsigned long* data, vtkIdType maxlength, int remoteProcessId, 00397 int tag); 00398 int Receive(char* data, vtkIdType maxlength, int remoteProcessId, int tag); 00399 int Receive(unsigned char* data, vtkIdType maxlength, int remoteProcessId, int tag); 00400 int Receive(float* data, vtkIdType maxlength, int remoteProcessId, int tag); 00401 int Receive(double* data, vtkIdType maxlength, int remoteProcessId, int tag); 00402 #ifdef VTK_USE_64BIT_IDS 00403 int Receive(vtkIdType* data, vtkIdType maxlength, int remoteProcessId, int tag); 00404 #endif 00405 int Receive(vtkDataObject* data, int remoteId, int tag); 00406 int Receive(vtkDataArray* data, int remoteId, int tag); 00407 //BTX 00409 00410 00411 int Receive(vtkMultiProcessStream& stream, int remoteId, int tag); 00412 //ETX 00413 vtkDataObject *ReceiveDataObject(int remoteId, int tag); 00415 00423 vtkIdType GetCount(); 00424 00425 00426 //---------------------- Collective Operations ---------------------- 00427 00429 00432 int Broadcast(int *data, vtkIdType length, int srcProcessId) { 00433 return this->Communicator->Broadcast(data, length, srcProcessId); 00434 } 00435 int Broadcast(unsigned int *data, vtkIdType length, int srcProcessId) { 00436 return this->Communicator->Broadcast(data, length, srcProcessId); 00437 } 00438 int Broadcast(unsigned long *data, vtkIdType length, int srcProcessId) { 00439 return this->Communicator->Broadcast(data, length, srcProcessId); 00440 } 00441 int Broadcast(unsigned char *data, vtkIdType length, int srcProcessId) { 00442 return this->Communicator->Broadcast(data, length, srcProcessId); 00443 } 00444 int Broadcast(char *data, vtkIdType length, int srcProcessId) { 00445 return this->Communicator->Broadcast(data, length, srcProcessId); 00446 } 00447 int Broadcast(float *data, vtkIdType length, int srcProcessId) { 00448 return this->Communicator->Broadcast(data, length, srcProcessId); 00449 } 00450 int Broadcast(double *data, vtkIdType length, int srcProcessId) { 00451 return this->Communicator->Broadcast(data, length, srcProcessId); 00452 } 00453 #ifdef VTK_USE_64BIT_IDS 00454 int Broadcast(vtkIdType *data, vtkIdType length, int srcProcessId) { 00455 return this->Communicator->Broadcast(data, length, srcProcessId); 00456 } 00457 #endif 00458 int Broadcast(vtkDataObject *data, int srcProcessId) { 00459 return this->Communicator->Broadcast(data, srcProcessId); 00460 } 00461 int Broadcast(vtkDataArray *data, int srcProcessId) { 00462 return this->Communicator->Broadcast(data, srcProcessId); 00463 } 00464 //BTX 00465 int Broadcast(vtkMultiProcessStream& stream, int srcProcessId) { 00466 return this->Communicator->Broadcast(stream, srcProcessId); 00467 } 00468 //ETX 00470 00472 00480 int Gather(const int *sendBuffer, int *recvBuffer, 00481 vtkIdType length, int destProcessId) { 00482 return this->Communicator->Gather(sendBuffer, recvBuffer, length, 00483 destProcessId); 00484 } 00485 int Gather(const unsigned long *sendBuffer, unsigned long *recvBuffer, 00486 vtkIdType length, int destProcessId) { 00487 return this->Communicator->Gather(sendBuffer, recvBuffer, length, 00488 destProcessId); 00489 } 00490 int Gather(const unsigned char *sendBuffer, unsigned char *recvBuffer, 00491 vtkIdType length, int destProcessId) { 00492 return this->Communicator->Gather(sendBuffer, recvBuffer, length, 00493 destProcessId); 00494 } 00495 int Gather(const char *sendBuffer, char *recvBuffer, 00496 vtkIdType length, int destProcessId) { 00497 return this->Communicator->Gather(sendBuffer, recvBuffer, length, 00498 destProcessId); 00499 } 00500 int Gather(const float *sendBuffer, float *recvBuffer, 00501 vtkIdType length, int destProcessId) { 00502 return this->Communicator->Gather(sendBuffer, recvBuffer, length, 00503 destProcessId); 00504 } 00505 int Gather(const double *sendBuffer, double *recvBuffer, 00506 vtkIdType length, int destProcessId) { 00507 return this->Communicator->Gather(sendBuffer, recvBuffer, length, 00508 destProcessId); 00509 } 00510 #ifdef VTK_USE_64BIT_IDS 00511 int Gather(const vtkIdType *sendBuffer, vtkIdType *recvBuffer, 00512 vtkIdType length, int destProcessId) { 00513 return this->Communicator->Gather(sendBuffer, recvBuffer, length, 00514 destProcessId); 00515 } 00516 #endif 00517 int Gather(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer, 00518 int destProcessId) { 00519 return this->Communicator->Gather(sendBuffer, recvBuffer, destProcessId); 00520 } 00522 00524 00534 int GatherV(const int* sendBuffer, int* recvBuffer, 00535 vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets, 00536 int destProcessId) { 00537 return this->Communicator->GatherV(sendBuffer, recvBuffer, 00538 sendLength, recvLengths, 00539 offsets, destProcessId); 00540 } 00541 int GatherV(const unsigned long* sendBuffer, unsigned long* recvBuffer, 00542 vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets, 00543 int destProcessId) { 00544 return this->Communicator->GatherV(sendBuffer, recvBuffer, 00545 sendLength, recvLengths, 00546 offsets, destProcessId); 00547 } 00548 int GatherV(const unsigned char* sendBuffer, unsigned char* recvBuffer, 00549 vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets, 00550 int destProcessId) { 00551 return this->Communicator->GatherV(sendBuffer, recvBuffer, 00552 sendLength, recvLengths, 00553 offsets, destProcessId); 00554 } 00555 int GatherV(const char* sendBuffer, char* recvBuffer, 00556 vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets, 00557 int destProcessId) { 00558 return this->Communicator->GatherV(sendBuffer, recvBuffer, 00559 sendLength, recvLengths, 00560 offsets, destProcessId); 00561 } 00562 int GatherV(const float* sendBuffer, float* recvBuffer, 00563 vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets, 00564 int destProcessId) { 00565 return this->Communicator->GatherV(sendBuffer, recvBuffer, 00566 sendLength, recvLengths, 00567 offsets, destProcessId); 00568 } 00569 int GatherV(const double* sendBuffer, double* recvBuffer, 00570 vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets, 00571 int destProcessId) { 00572 return this->Communicator->GatherV(sendBuffer, recvBuffer, 00573 sendLength, recvLengths, 00574 offsets, destProcessId); 00575 } 00576 #ifdef VTK_USE_64BIT_IDS 00577 int GatherV(const vtkIdType* sendBuffer, vtkIdType* recvBuffer, 00578 vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets, 00579 int destProcessId) { 00580 return this->Communicator->GatherV(sendBuffer, recvBuffer, 00581 sendLength, recvLengths, 00582 offsets, destProcessId); 00583 } 00584 #endif 00585 int GatherV(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer, 00586 vtkIdType *recvLengths, vtkIdType *offsets, int destProcessId) { 00587 return this->Communicator->GatherV(sendBuffer, recvBuffer, 00588 recvLengths, offsets, 00589 destProcessId); 00590 } 00592 00594 00599 int GatherV(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer, 00600 int destProcessId) { 00601 return this->Communicator->GatherV(sendBuffer, recvBuffer, destProcessId); 00602 } 00604 00606 00611 int Scatter(const int *sendBuffer, int *recvBuffer, 00612 vtkIdType length, int srcProcessId) { 00613 return this->Communicator->Scatter(sendBuffer, recvBuffer, length, 00614 srcProcessId); 00615 } 00616 int Scatter(const unsigned long *sendBuffer, unsigned long *recvBuffer, 00617 vtkIdType length, int srcProcessId) { 00618 return this->Communicator->Scatter(sendBuffer, recvBuffer, length, 00619 srcProcessId); 00620 } 00621 int Scatter(const unsigned char *sendBuffer, unsigned char *recvBuffer, 00622 vtkIdType length, int srcProcessId) { 00623 return this->Communicator->Scatter(sendBuffer, recvBuffer, length, 00624 srcProcessId); 00625 } 00626 int Scatter(const char *sendBuffer, char *recvBuffer, 00627 vtkIdType length, int srcProcessId) { 00628 return this->Communicator->Scatter(sendBuffer, recvBuffer, length, 00629 srcProcessId); 00630 } 00631 int Scatter(const float *sendBuffer, float *recvBuffer, 00632 vtkIdType length, int srcProcessId) { 00633 return this->Communicator->Scatter(sendBuffer, recvBuffer, length, 00634 srcProcessId); 00635 } 00636 int Scatter(const double *sendBuffer, double *recvBuffer, 00637 vtkIdType length, int srcProcessId) { 00638 return this->Communicator->Scatter(sendBuffer, recvBuffer, length, 00639 srcProcessId); 00640 } 00641 #ifdef VTK_USE_64BIT_IDS 00642 int Scatter(const vtkIdType *sendBuffer, vtkIdType *recvBuffer, 00643 vtkIdType length, int srcProcessId) { 00644 return this->Communicator->Scatter(sendBuffer, recvBuffer, length, 00645 srcProcessId); 00646 } 00647 #endif 00648 int Scatter(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer, 00649 int srcProcessId) { 00650 return this->Communicator->Scatter(sendBuffer, recvBuffer, srcProcessId); 00651 } 00653 00655 00661 int ScatterV(const int *sendBuffer, int *recvBuffer, 00662 vtkIdType *sendLengths, vtkIdType *offsets, 00663 vtkIdType recvLength, int srcProcessId) { 00664 return this->Communicator->ScatterV(sendBuffer, recvBuffer, 00665 sendLengths, offsets, recvLength, 00666 srcProcessId); 00667 } 00668 int ScatterV(const unsigned long *sendBuffer, unsigned long *recvBuffer, 00669 vtkIdType *sendLengths, vtkIdType *offsets, 00670 vtkIdType recvLength, int srcProcessId) { 00671 return this->Communicator->ScatterV(sendBuffer, recvBuffer, 00672 sendLengths, offsets, recvLength, 00673 srcProcessId); 00674 } 00675 int ScatterV(const unsigned char *sendBuffer, unsigned char *recvBuffer, 00676 vtkIdType *sendLengths, vtkIdType *offsets, 00677 vtkIdType recvLength, int srcProcessId) { 00678 return this->Communicator->ScatterV(sendBuffer, recvBuffer, 00679 sendLengths, offsets, recvLength, 00680 srcProcessId); 00681 } 00682 int ScatterV(const char *sendBuffer, char *recvBuffer, 00683 vtkIdType *sendLengths, vtkIdType *offsets, 00684 vtkIdType recvLength, int srcProcessId) { 00685 return this->Communicator->ScatterV(sendBuffer, recvBuffer, 00686 sendLengths, offsets, recvLength, 00687 srcProcessId); 00688 } 00689 int ScatterV(const float *sendBuffer, float *recvBuffer, 00690 vtkIdType *sendLengths, vtkIdType *offsets, 00691 vtkIdType recvLength, int srcProcessId) { 00692 return this->Communicator->ScatterV(sendBuffer, recvBuffer, 00693 sendLengths, offsets, recvLength, 00694 srcProcessId); 00695 } 00696 int ScatterV(const double *sendBuffer, double *recvBuffer, 00697 vtkIdType *sendLengths, vtkIdType *offsets, 00698 vtkIdType recvLength, int srcProcessId) { 00699 return this->Communicator->ScatterV(sendBuffer, recvBuffer, 00700 sendLengths, offsets, recvLength, 00701 srcProcessId); 00702 } 00703 #ifdef VTK_USE_64BIT_IDS 00704 int ScatterV(const vtkIdType *sendBuffer, vtkIdType *recvBuffer, 00705 vtkIdType *sendLengths, vtkIdType *offsets, 00706 vtkIdType recvLength, int srcProcessId) { 00707 return this->Communicator->ScatterV(sendBuffer, recvBuffer, 00708 sendLengths, offsets, recvLength, 00709 srcProcessId); 00710 } 00711 #endif 00712 00713 00715 00716 int AllGather(const int *sendBuffer, int *recvBuffer, vtkIdType length) { 00717 return this->Communicator->AllGather(sendBuffer, recvBuffer, length); 00718 } 00719 int AllGather(const unsigned long *sendBuffer, 00720 unsigned long *recvBuffer, vtkIdType length) { 00721 return this->Communicator->AllGather(sendBuffer, recvBuffer, length); 00722 } 00723 int AllGather(const unsigned char *sendBuffer, 00724 unsigned char *recvBuffer, vtkIdType length) { 00725 return this->Communicator->AllGather(sendBuffer, recvBuffer, length); 00726 } 00727 int AllGather(const char *sendBuffer, char *recvBuffer, vtkIdType length) { 00728 return this->Communicator->AllGather(sendBuffer, recvBuffer, length); 00729 } 00730 int AllGather(const float *sendBuffer, float *recvBuffer, vtkIdType length) { 00731 return this->Communicator->AllGather(sendBuffer, recvBuffer, length); 00732 } 00733 int AllGather(const double *sendBuffer, 00734 double *recvBuffer, vtkIdType length) { 00735 return this->Communicator->AllGather(sendBuffer, recvBuffer, length); 00736 } 00737 #ifdef VTK_USE_64BIT_IDS 00738 int AllGather(const vtkIdType *sendBuffer, vtkIdType *recvBuffer, 00739 vtkIdType length) { 00740 return this->Communicator->AllGather(sendBuffer, recvBuffer, length); 00741 } 00742 #endif 00743 int AllGather(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer) { 00744 return this->Communicator->AllGather(sendBuffer, recvBuffer); 00745 } 00747 00749 00750 int AllGatherV(const int* sendBuffer, int* recvBuffer, 00751 vtkIdType sendLength, vtkIdType* recvLengths, 00752 vtkIdType* offsets) { 00753 return this->Communicator->AllGatherV(sendBuffer, recvBuffer, 00754 sendLength, recvLengths, 00755 offsets); 00756 } 00757 int AllGatherV(const unsigned long* sendBuffer, unsigned long* recvBuffer, 00758 vtkIdType sendLength, vtkIdType* recvLengths, 00759 vtkIdType* offsets) { 00760 return this->Communicator->AllGatherV(sendBuffer, recvBuffer, 00761 sendLength, recvLengths, 00762 offsets); 00763 } 00764 int AllGatherV(const unsigned char* sendBuffer, unsigned char* recvBuffer, 00765 vtkIdType sendLength, vtkIdType* recvLengths, 00766 vtkIdType* offsets) { 00767 return this->Communicator->AllGatherV(sendBuffer, recvBuffer, 00768 sendLength, recvLengths, 00769 offsets); 00770 } 00771 int AllGatherV(const char* sendBuffer, char* recvBuffer, 00772 vtkIdType sendLength, vtkIdType* recvLengths, 00773 vtkIdType* offsets) { 00774 return this->Communicator->AllGatherV(sendBuffer, recvBuffer, 00775 sendLength, recvLengths, 00776 offsets); 00777 } 00778 int AllGatherV(const float* sendBuffer, float* recvBuffer, 00779 vtkIdType sendLength, vtkIdType* recvLengths, 00780 vtkIdType* offsets) { 00781 return this->Communicator->AllGatherV(sendBuffer, recvBuffer, 00782 sendLength, recvLengths, 00783 offsets); 00784 } 00785 int AllGatherV(const double* sendBuffer, double* recvBuffer, 00786 vtkIdType sendLength, vtkIdType* recvLengths, 00787 vtkIdType* offsets) { 00788 return this->Communicator->AllGatherV(sendBuffer, recvBuffer, 00789 sendLength, recvLengths, 00790 offsets); 00791 } 00792 #ifdef VTK_USE_64BIT_IDS 00793 int AllGatherV(const vtkIdType* sendBuffer, vtkIdType* recvBuffer, 00794 vtkIdType sendLength, vtkIdType* recvLengths, 00795 vtkIdType* offsets) { 00796 return this->Communicator->AllGatherV(sendBuffer, recvBuffer, 00797 sendLength, recvLengths, 00798 offsets); 00799 } 00800 #endif 00801 int AllGatherV(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer, 00802 vtkIdType *recvLengths, vtkIdType *offsets) { 00803 return this->Communicator->AllGatherV(sendBuffer, recvBuffer, 00804 recvLengths, offsets); 00805 } 00807 00809 00814 int AllGatherV(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer) { 00815 return this->Communicator->AllGatherV(sendBuffer, recvBuffer); 00816 } 00818 00820 00823 int Reduce(const int *sendBuffer, int *recvBuffer, 00824 vtkIdType length, int operation, int destProcessId) { 00825 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00826 operation, destProcessId); 00827 } 00828 int Reduce(const unsigned int *sendBuffer, unsigned int *recvBuffer, 00829 vtkIdType length, int operation, int destProcessId) { 00830 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00831 operation, destProcessId); 00832 } 00833 int Reduce(const unsigned long *sendBuffer, unsigned long *recvBuffer, 00834 vtkIdType length, int operation, int destProcessId) { 00835 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00836 operation, destProcessId); 00837 } 00838 int Reduce(const unsigned char *sendBuffer, unsigned char *recvBuffer, 00839 vtkIdType length, int operation, int destProcessId) { 00840 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00841 operation, destProcessId); 00842 } 00843 int Reduce(const char *sendBuffer, char *recvBuffer, 00844 vtkIdType length, int operation, int destProcessId) { 00845 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00846 operation, destProcessId); 00847 } 00848 int Reduce(const float *sendBuffer, float *recvBuffer, 00849 vtkIdType length, int operation, int destProcessId) { 00850 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00851 operation, destProcessId); 00852 } 00853 int Reduce(const double *sendBuffer, double *recvBuffer, 00854 vtkIdType length, int operation, int destProcessId) { 00855 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00856 operation, destProcessId); 00857 } 00858 #ifdef VTK_USE_64BIT_IDS 00859 int Reduce(const vtkIdType *sendBuffer, vtkIdType *recvBuffer, 00860 vtkIdType length, int operation, int destProcessId) { 00861 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00862 operation, destProcessId); 00863 } 00864 #endif 00865 int Reduce(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer, 00866 int operation, int destProcessId) { 00867 return this->Communicator->Reduce(sendBuffer, recvBuffer, 00868 operation, destProcessId); 00869 } 00871 00872 //BTX 00874 00877 int Reduce(const int *sendBuffer, int *recvBuffer, 00878 vtkIdType length, vtkCommunicator::Operation *operation, 00879 int destProcessId) { 00880 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00881 operation, destProcessId); 00882 } 00883 int Reduce(const unsigned long *sendBuffer, unsigned long *recvBuffer, 00884 vtkIdType length, vtkCommunicator::Operation *operation, 00885 int destProcessId) { 00886 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00887 operation, destProcessId); 00888 } 00889 int Reduce(const unsigned char *sendBuffer, unsigned char *recvBuffer, 00890 vtkIdType length, vtkCommunicator::Operation *operation, 00891 int destProcessId) { 00892 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00893 operation, destProcessId); 00894 } 00895 int Reduce(const char *sendBuffer, char *recvBuffer, 00896 vtkIdType length, vtkCommunicator::Operation *operation, 00897 int destProcessId) { 00898 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00899 operation, destProcessId); 00900 } 00901 int Reduce(const float *sendBuffer, float *recvBuffer, 00902 vtkIdType length, vtkCommunicator::Operation *operation, 00903 int destProcessId) { 00904 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00905 operation, destProcessId); 00906 } 00907 int Reduce(const double *sendBuffer, double *recvBuffer, 00908 vtkIdType length, vtkCommunicator::Operation *operation, 00909 int destProcessId) { 00910 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00911 operation, destProcessId); 00912 } 00913 #ifdef VTK_USE_64BIT_IDS 00914 int Reduce(const vtkIdType *sendBuffer, vtkIdType *recvBuffer, 00915 vtkIdType length, vtkCommunicator::Operation *operation, 00916 int destProcessId) { 00917 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00918 operation, destProcessId); 00919 } 00920 #endif 00921 int Reduce(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer, 00922 vtkCommunicator::Operation *operation, int destProcessId) { 00923 return this->Communicator->Reduce(sendBuffer, recvBuffer, 00924 operation, destProcessId); 00925 } 00926 //ETX 00928 00930 00932 int AllReduce(const int *sendBuffer, int *recvBuffer, 00933 vtkIdType length, int operation) { 00934 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00935 operation); 00936 } 00937 int AllReduce(const unsigned long *sendBuffer, unsigned long *recvBuffer, 00938 vtkIdType length, int operation) { 00939 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00940 operation); 00941 } 00942 int AllReduce(const unsigned char *sendBuffer, unsigned char *recvBuffer, 00943 vtkIdType length, int operation) { 00944 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00945 operation); 00946 } 00947 int AllReduce(const char *sendBuffer, char *recvBuffer, 00948 vtkIdType length, int operation) { 00949 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00950 operation); 00951 } 00952 int AllReduce(const float *sendBuffer, float *recvBuffer, 00953 vtkIdType length, int operation) { 00954 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00955 operation); 00956 } 00957 int AllReduce(const double *sendBuffer, double *recvBuffer, 00958 vtkIdType length, int operation) { 00959 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00960 operation); 00961 } 00962 #ifdef VTK_USE_64BIT_IDS 00963 int AllReduce(const vtkIdType *sendBuffer, vtkIdType *recvBuffer, 00964 vtkIdType length, int operation) { 00965 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00966 operation); 00967 } 00968 #endif 00969 int AllReduce(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer, 00970 int operation) { 00971 return this->Communicator->AllReduce(sendBuffer, recvBuffer, operation); 00972 } 00973 //BTX 00974 int AllReduce(const int *sendBuffer, int *recvBuffer, 00975 vtkIdType length, vtkCommunicator::Operation *operation) { 00976 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00977 operation); 00978 } 00979 int AllReduce(const unsigned long *sendBuffer, unsigned long *recvBuffer, 00980 vtkIdType length, vtkCommunicator::Operation *operation) { 00981 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00982 operation); 00983 } 00984 int AllReduce(const unsigned char *sendBuffer, unsigned char *recvBuffer, 00985 vtkIdType length, vtkCommunicator::Operation *operation) { 00986 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00987 operation); 00988 } 00989 int AllReduce(const char *sendBuffer, char *recvBuffer, 00990 vtkIdType length, vtkCommunicator::Operation *operation) { 00991 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00992 operation); 00993 } 00994 int AllReduce(const float *sendBuffer, float *recvBuffer, 00995 vtkIdType length, vtkCommunicator::Operation *operation) { 00996 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00997 operation); 00998 } 00999 int AllReduce(const double *sendBuffer, double *recvBuffer, 01000 vtkIdType length, vtkCommunicator::Operation *operation) { 01001 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 01002 operation); 01003 } 01004 #ifdef VTK_USE_64BIT_IDS 01005 int AllReduce(const vtkIdType *sendBuffer, vtkIdType *recvBuffer, 01006 vtkIdType length, vtkCommunicator::Operation *operation) { 01007 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 01008 operation); 01009 } 01010 #endif 01011 int AllReduce(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer, 01012 vtkCommunicator::Operation *operation) { 01013 return this->Communicator->AllReduce(sendBuffer, recvBuffer, operation); 01014 } 01015 //ETX 01017 01018 // Internally implemented RMI to break the process loop. 01019 01020 protected: 01021 vtkMultiProcessController(); 01022 ~vtkMultiProcessController(); 01023 01025 01028 virtual void TriggerRMIInternal(int remoteProcessId, 01029 void* arg, int argLength, int rmiTag, bool propagate); 01031 01032 vtkProcessFunctionType SingleMethod; 01033 void *SingleData; 01034 01035 void GetMultipleMethod(int index, vtkProcessFunctionType &func, void *&data); 01036 01037 // This is a flag that can be used by the ports to break 01038 // their update loop. (same as ProcessRMIs) 01039 int BreakFlag; 01040 01041 void ProcessRMI(int remoteProcessId, void *arg, int argLength, int rmiTag); 01042 01043 // This method implements "GetGlobalController". 01044 // It needs to be virtual and static. 01045 virtual vtkMultiProcessController *GetLocalController(); 01046 01047 01048 // This flag can force deep copies during send. 01049 int ForceDeepCopy; 01050 01051 // This flag can be used to indicate that an MPI Broadcast will be used 01052 // when calling TriggerRMIOnAllChildren(), instead of the binary tree 01053 // propagation of the data to the sattelite ranks from rank 0. 01054 bool BroadcastTriggerRMI; 01055 01056 vtkOutputWindow* OutputWindow; 01057 01058 // Note that since the communicators can be created differently 01059 // depending on the type of controller, the subclasses are 01060 // responsible of deleting them. 01061 vtkCommunicator* Communicator; 01062 01063 // Communicator which is a copy of the current user 01064 // level communicator except the context; i.e. even if the tags 01065 // are the same, the RMI messages will not interfere with user 01066 // level messages. 01067 // Note that since the communicators can be created differently 01068 // depending on the type of controller, the subclasses are 01069 // responsible of deleting them. 01070 vtkCommunicator* RMICommunicator; 01071 01072 private: 01073 vtkMultiProcessController(const vtkMultiProcessController&); // Not implemented. 01074 void operator=(const vtkMultiProcessController&); // Not implemented. 01075 01076 unsigned long RMICount; 01077 01078 //BTX 01079 class vtkInternal; 01080 vtkInternal *Internal; 01081 //ETX 01082 }; 01083 01084 01085 inline int vtkMultiProcessController::Send(vtkDataObject *data, 01086 int remoteProcessId, int tag) 01087 { 01088 if (this->Communicator) 01089 { 01090 return this->Communicator->Send(data, remoteProcessId, tag); 01091 } 01092 else 01093 { 01094 return 0; 01095 } 01096 } 01097 01098 inline int vtkMultiProcessController::Send(vtkDataArray *data, 01099 int remoteProcessId, int tag) 01100 { 01101 if (this->Communicator) 01102 { 01103 return this->Communicator->Send(data, remoteProcessId, tag); 01104 } 01105 else 01106 { 01107 return 0; 01108 } 01109 } 01110 01111 inline int vtkMultiProcessController::Send(const int* data, vtkIdType length, 01112 int remoteProcessId, int tag) 01113 { 01114 if (this->Communicator) 01115 { 01116 return this->Communicator->Send(data, length, remoteProcessId, tag); 01117 } 01118 else 01119 { 01120 return 0; 01121 } 01122 } 01123 01124 inline int vtkMultiProcessController::Send(const unsigned int* data, vtkIdType length, 01125 int remoteProcessId, int tag) 01126 { 01127 if (this->Communicator) 01128 { 01129 return this->Communicator->Send(data, length, remoteProcessId, tag); 01130 } 01131 else 01132 { 01133 return 0; 01134 } 01135 } 01136 01137 inline int vtkMultiProcessController::Send(const unsigned long* data, 01138 vtkIdType length, 01139 int remoteProcessId, 01140 int tag) 01141 { 01142 if (this->Communicator) 01143 { 01144 return this->Communicator->Send(data, length, remoteProcessId, tag); 01145 } 01146 else 01147 { 01148 return 0; 01149 } 01150 } 01151 01152 inline int vtkMultiProcessController::Send(const char* data, vtkIdType length, 01153 int remoteProcessId, int tag) 01154 { 01155 if (this->Communicator) 01156 { 01157 return this->Communicator->Send(data, length, remoteProcessId, tag); 01158 } 01159 else 01160 { 01161 return 0; 01162 } 01163 } 01164 01165 inline int vtkMultiProcessController::Send(const unsigned char* data, 01166 vtkIdType length, 01167 int remoteProcessId, int tag) 01168 { 01169 if (this->Communicator) 01170 { 01171 return this->Communicator->Send(data, length, remoteProcessId, tag); 01172 } 01173 else 01174 { 01175 return 0; 01176 } 01177 } 01178 01179 inline int vtkMultiProcessController::Send(const float* data, vtkIdType length, 01180 int remoteProcessId, int tag) 01181 { 01182 if (this->Communicator) 01183 { 01184 return this->Communicator->Send(data, length, remoteProcessId, tag); 01185 } 01186 else 01187 { 01188 return 0; 01189 } 01190 } 01191 01192 inline int vtkMultiProcessController::Send(const double* data, vtkIdType length, 01193 int remoteProcessId, int tag) 01194 { 01195 if (this->Communicator) 01196 { 01197 return this->Communicator->Send(data, length, remoteProcessId, tag); 01198 } 01199 else 01200 { 01201 return 0; 01202 } 01203 } 01204 01205 #ifdef VTK_USE_64BIT_IDS 01206 inline int vtkMultiProcessController::Send(const vtkIdType* data, 01207 vtkIdType length, 01208 int remoteProcessId, int tag) 01209 { 01210 if (this->Communicator) 01211 { 01212 return this->Communicator->Send(data, length, remoteProcessId, tag); 01213 } 01214 else 01215 { 01216 return 0; 01217 } 01218 } 01219 #endif 01220 01221 inline int vtkMultiProcessController::Send(const vtkMultiProcessStream& stream, 01222 int remoteId, int tag) 01223 { 01224 if (this->Communicator) 01225 { 01226 return this->Communicator->Send(stream, remoteId, tag); 01227 } 01228 return 0; 01229 } 01230 01231 inline int vtkMultiProcessController::Receive(vtkDataObject* data, 01232 int remoteProcessId, int tag) 01233 { 01234 if (this->Communicator) 01235 { 01236 return this->Communicator->Receive(data, remoteProcessId, tag); 01237 } 01238 else 01239 { 01240 return 0; 01241 } 01242 } 01243 01244 inline vtkDataObject* vtkMultiProcessController::ReceiveDataObject( 01245 int remoteProcessId, int tag) 01246 { 01247 if (this->Communicator) 01248 { 01249 return this->Communicator->ReceiveDataObject(remoteProcessId, tag); 01250 } 01251 else 01252 { 01253 return 0; 01254 } 01255 } 01256 01257 inline int vtkMultiProcessController::Receive(vtkDataArray* data, 01258 int remoteProcessId, int tag) 01259 { 01260 if (this->Communicator) 01261 { 01262 return this->Communicator->Receive(data, remoteProcessId, tag); 01263 } 01264 else 01265 { 01266 return 0; 01267 } 01268 } 01269 01270 inline int vtkMultiProcessController::Receive(int* data, vtkIdType length, 01271 int remoteProcessId, int tag) 01272 { 01273 if (this->Communicator) 01274 { 01275 return this->Communicator->Receive(data, length, remoteProcessId, tag); 01276 } 01277 else 01278 { 01279 return 0; 01280 } 01281 } 01282 01283 inline int vtkMultiProcessController::Receive(unsigned int* data, vtkIdType length, 01284 int remoteProcessId, int tag) 01285 { 01286 if (this->Communicator) 01287 { 01288 return this->Communicator->Receive(data, length, remoteProcessId, tag); 01289 } 01290 else 01291 { 01292 return 0; 01293 } 01294 } 01295 01296 inline int vtkMultiProcessController::Receive(unsigned long* data, 01297 vtkIdType length, 01298 int remoteProcessId, 01299 int tag) 01300 { 01301 if (this->Communicator) 01302 { 01303 return this->Communicator->Receive(data, length, remoteProcessId, tag); 01304 } 01305 else 01306 { 01307 return 0; 01308 } 01309 } 01310 01311 inline int vtkMultiProcessController::Receive(char* data, vtkIdType length, 01312 int remoteProcessId, int tag) 01313 { 01314 if (this->Communicator) 01315 { 01316 return this->Communicator->Receive(data, length, remoteProcessId, tag); 01317 } 01318 else 01319 { 01320 return 0; 01321 } 01322 } 01323 01324 inline int vtkMultiProcessController::Receive(unsigned char* data, 01325 vtkIdType length, 01326 int remoteProcessId, int tag) 01327 { 01328 if (this->Communicator) 01329 { 01330 return this->Communicator->Receive(data, length, remoteProcessId, tag); 01331 } 01332 else 01333 { 01334 return 0; 01335 } 01336 } 01337 01338 inline int vtkMultiProcessController::Receive(float* data, vtkIdType length, 01339 int remoteProcessId, int tag) 01340 { 01341 if (this->Communicator) 01342 { 01343 return this->Communicator->Receive(data, length, remoteProcessId, tag); 01344 } 01345 else 01346 { 01347 return 0; 01348 } 01349 } 01350 01351 inline int vtkMultiProcessController::Receive(double* data, vtkIdType length, 01352 int remoteProcessId, int tag) 01353 { 01354 if (this->Communicator) 01355 { 01356 return this->Communicator->Receive(data, length, remoteProcessId, tag); 01357 } 01358 else 01359 { 01360 return 0; 01361 } 01362 } 01363 01364 #ifdef VTK_USE_64BIT_IDS 01365 inline int vtkMultiProcessController::Receive(vtkIdType* data, 01366 vtkIdType length, 01367 int remoteProcessId, int tag) 01368 { 01369 if (this->Communicator) 01370 { 01371 return this->Communicator->Receive(data, length, remoteProcessId, tag); 01372 } 01373 else 01374 { 01375 return 0; 01376 } 01377 } 01378 #endif 01379 01380 01381 inline int vtkMultiProcessController::Receive(vtkMultiProcessStream& stream, 01382 int remoteId, int tag) 01383 { 01384 if (this->Communicator) 01385 { 01386 return this->Communicator->Receive(stream, remoteId, tag); 01387 } 01388 return 0; 01389 } 01390 01391 inline void vtkMultiProcessController::Barrier() 01392 { 01393 if (this->Communicator) 01394 { 01395 this->Communicator->Barrier(); 01396 } 01397 } 01398 01399 inline vtkIdType vtkMultiProcessController::GetCount() 01400 { 01401 if (this->Communicator) 01402 { 01403 return this->Communicator->GetCount(); 01404 } 01405 return 0; 01406 } 01407 01408 #endif