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 =========================================================================*/ 00040 #ifndef __vtkMultiProcessController_h 00041 #define __vtkMultiProcessController_h 00042 00043 #include "vtkParallelCoreModule.h" // For export macro 00044 #include "vtkObject.h" 00045 00046 #include "vtkCommunicator.h" // Needed for direct access to communicator 00047 00048 class vtkCollection; 00049 class vtkDataObject; 00050 class vtkDataSet; 00051 class vtkImageData; 00052 class vtkMultiProcessController; 00053 class vtkMultiProcessStream; 00054 class vtkOutputWindow; 00055 class vtkProcessGroup; 00056 class vtkProcess; 00057 00058 //BTX 00059 // The type of function that gets called when new processes are initiated. 00060 typedef void (*vtkProcessFunctionType)(vtkMultiProcessController *controller, 00061 void *userData); 00062 00063 // The type of function that gets called when an RMI is triggered. 00064 typedef void (*vtkRMIFunctionType)(void *localArg, 00065 void *remoteArg, int remoteArgLength, 00066 int remoteProcessId); 00067 //ETX 00068 00069 00070 class VTKPARALLELCORE_EXPORT vtkMultiProcessController : public vtkObject 00071 { 00072 public: 00073 vtkTypeMacro(vtkMultiProcessController,vtkObject); 00074 void PrintSelf(ostream& os, vtkIndent indent); 00075 00079 virtual void Initialize(int* vtkNotUsed(argc), char*** vtkNotUsed(argv))=0; 00080 00082 00085 virtual void Initialize(int* vtkNotUsed(argc), char*** vtkNotUsed(argv), 00086 int initializedExternally)=0; 00088 00091 virtual void Finalize()=0; 00092 00096 virtual void Finalize(int finalizedExternally)=0; 00097 00099 00102 void SetNumberOfProcesses(int num); 00103 int GetNumberOfProcesses(); 00105 00106 //BTX 00110 void SetSingleMethod(vtkProcessFunctionType, void *data); 00111 00113 00116 void SetSingleProcessObject(vtkProcess *p); 00117 //ETX 00119 00123 virtual void SingleMethodExecute() = 0; 00124 00125 //BTX 00127 00131 void SetMultipleMethod(int index, vtkProcessFunctionType, void *data); 00132 //ETX 00134 00138 virtual void MultipleMethodExecute() = 0; 00139 00141 int GetLocalProcessId(); 00142 00147 static vtkMultiProcessController *GetGlobalController(); 00148 00151 virtual void CreateOutputWindow() = 0; 00152 00154 00163 virtual vtkMultiProcessController *CreateSubController( 00164 vtkProcessGroup *group); 00166 00168 00177 virtual vtkMultiProcessController *PartitionController(int localColor, 00178 int localKey); 00180 00181 //------------------ RMIs -------------------- 00182 //BTX 00193 virtual unsigned long AddRMI(vtkRMIFunctionType, void *localArg, int tag); 00194 00196 virtual int RemoveFirstRMI(int tag); 00197 00200 virtual int RemoveRMI(unsigned long id); 00201 00203 00204 virtual void RemoveRMI(vtkRMIFunctionType f, void *arg, int tag) 00205 {(void)f; (void)arg; (void)tag; vtkErrorMacro("RemoveRMI Not Implemented Yet");}; 00207 00212 virtual unsigned long AddRMICallback(vtkRMIFunctionType, void* localArg, int tag); 00213 00217 virtual void RemoveAllRMICallbacks(int tag); 00218 00220 virtual 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 00384 00385 00386 int Receive(vtkMultiProcessStream& stream, int remoteId, int tag); 00387 //ETX 00388 vtkDataObject *ReceiveDataObject(int remoteId, int tag); 00390 00398 vtkIdType GetCount(); 00399 00400 00401 //---------------------- Collective Operations ---------------------- 00402 00404 00407 int Broadcast(int *data, vtkIdType length, int srcProcessId) { 00408 return this->Communicator->Broadcast(data, length, srcProcessId); 00409 } 00410 int Broadcast(unsigned int *data, vtkIdType length, int srcProcessId) { 00411 return this->Communicator->Broadcast(data, length, srcProcessId); 00412 } 00413 int Broadcast(unsigned long *data, vtkIdType length, int srcProcessId) { 00414 return this->Communicator->Broadcast(data, length, srcProcessId); 00415 } 00416 int Broadcast(unsigned char *data, vtkIdType length, int srcProcessId) { 00417 return this->Communicator->Broadcast(data, length, srcProcessId); 00418 } 00419 int Broadcast(char *data, vtkIdType length, int srcProcessId) { 00420 return this->Communicator->Broadcast(data, length, srcProcessId); 00421 } 00422 int Broadcast(float *data, vtkIdType length, int srcProcessId) { 00423 return this->Communicator->Broadcast(data, length, srcProcessId); 00424 } 00425 int Broadcast(double *data, vtkIdType length, int srcProcessId) { 00426 return this->Communicator->Broadcast(data, length, srcProcessId); 00427 } 00428 #ifdef VTK_USE_64BIT_IDS 00429 int Broadcast(vtkIdType *data, vtkIdType length, int srcProcessId) { 00430 return this->Communicator->Broadcast(data, length, srcProcessId); 00431 } 00432 #endif 00433 int Broadcast(vtkDataObject *data, int srcProcessId) { 00434 return this->Communicator->Broadcast(data, srcProcessId); 00435 } 00436 int Broadcast(vtkDataArray *data, int srcProcessId) { 00437 return this->Communicator->Broadcast(data, srcProcessId); 00438 } 00439 //BTX 00440 int Broadcast(vtkMultiProcessStream& stream, int srcProcessId) { 00441 return this->Communicator->Broadcast(stream, srcProcessId); 00442 } 00443 //ETX 00445 00447 00455 int Gather(const int *sendBuffer, int *recvBuffer, 00456 vtkIdType length, int destProcessId) { 00457 return this->Communicator->Gather(sendBuffer, recvBuffer, length, 00458 destProcessId); 00459 } 00460 int Gather(const unsigned long *sendBuffer, unsigned long *recvBuffer, 00461 vtkIdType length, int destProcessId) { 00462 return this->Communicator->Gather(sendBuffer, recvBuffer, length, 00463 destProcessId); 00464 } 00465 int Gather(const unsigned char *sendBuffer, unsigned char *recvBuffer, 00466 vtkIdType length, int destProcessId) { 00467 return this->Communicator->Gather(sendBuffer, recvBuffer, length, 00468 destProcessId); 00469 } 00470 int Gather(const char *sendBuffer, char *recvBuffer, 00471 vtkIdType length, int destProcessId) { 00472 return this->Communicator->Gather(sendBuffer, recvBuffer, length, 00473 destProcessId); 00474 } 00475 int Gather(const float *sendBuffer, float *recvBuffer, 00476 vtkIdType length, int destProcessId) { 00477 return this->Communicator->Gather(sendBuffer, recvBuffer, length, 00478 destProcessId); 00479 } 00480 int Gather(const double *sendBuffer, double *recvBuffer, 00481 vtkIdType length, int destProcessId) { 00482 return this->Communicator->Gather(sendBuffer, recvBuffer, length, 00483 destProcessId); 00484 } 00485 #ifdef VTK_USE_64BIT_IDS 00486 int Gather(const vtkIdType *sendBuffer, vtkIdType *recvBuffer, 00487 vtkIdType length, int destProcessId) { 00488 return this->Communicator->Gather(sendBuffer, recvBuffer, length, 00489 destProcessId); 00490 } 00491 #endif 00492 int Gather(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer, 00493 int destProcessId) { 00494 return this->Communicator->Gather(sendBuffer, recvBuffer, destProcessId); 00495 } 00497 00499 00509 int GatherV(const int* sendBuffer, int* recvBuffer, 00510 vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets, 00511 int destProcessId) { 00512 return this->Communicator->GatherV(sendBuffer, recvBuffer, 00513 sendLength, recvLengths, 00514 offsets, destProcessId); 00515 } 00516 int GatherV(const unsigned long* sendBuffer, unsigned long* recvBuffer, 00517 vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets, 00518 int destProcessId) { 00519 return this->Communicator->GatherV(sendBuffer, recvBuffer, 00520 sendLength, recvLengths, 00521 offsets, destProcessId); 00522 } 00523 int GatherV(const unsigned char* sendBuffer, unsigned char* recvBuffer, 00524 vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets, 00525 int destProcessId) { 00526 return this->Communicator->GatherV(sendBuffer, recvBuffer, 00527 sendLength, recvLengths, 00528 offsets, destProcessId); 00529 } 00530 int GatherV(const char* sendBuffer, char* recvBuffer, 00531 vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets, 00532 int destProcessId) { 00533 return this->Communicator->GatherV(sendBuffer, recvBuffer, 00534 sendLength, recvLengths, 00535 offsets, destProcessId); 00536 } 00537 int GatherV(const float* sendBuffer, float* recvBuffer, 00538 vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets, 00539 int destProcessId) { 00540 return this->Communicator->GatherV(sendBuffer, recvBuffer, 00541 sendLength, recvLengths, 00542 offsets, destProcessId); 00543 } 00544 int GatherV(const double* sendBuffer, double* recvBuffer, 00545 vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets, 00546 int destProcessId) { 00547 return this->Communicator->GatherV(sendBuffer, recvBuffer, 00548 sendLength, recvLengths, 00549 offsets, destProcessId); 00550 } 00551 #ifdef VTK_USE_64BIT_IDS 00552 int GatherV(const vtkIdType* sendBuffer, vtkIdType* recvBuffer, 00553 vtkIdType sendLength, vtkIdType* recvLengths, vtkIdType* offsets, 00554 int destProcessId) { 00555 return this->Communicator->GatherV(sendBuffer, recvBuffer, 00556 sendLength, recvLengths, 00557 offsets, destProcessId); 00558 } 00559 #endif 00560 int GatherV(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer, 00561 vtkIdType *recvLengths, vtkIdType *offsets, int destProcessId) { 00562 return this->Communicator->GatherV(sendBuffer, recvBuffer, 00563 recvLengths, offsets, 00564 destProcessId); 00565 } 00567 00569 00574 int GatherV(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer, 00575 int destProcessId) { 00576 return this->Communicator->GatherV(sendBuffer, recvBuffer, destProcessId); 00577 } 00579 00581 00586 int Scatter(const int *sendBuffer, int *recvBuffer, 00587 vtkIdType length, int srcProcessId) { 00588 return this->Communicator->Scatter(sendBuffer, recvBuffer, length, 00589 srcProcessId); 00590 } 00591 int Scatter(const unsigned long *sendBuffer, unsigned long *recvBuffer, 00592 vtkIdType length, int srcProcessId) { 00593 return this->Communicator->Scatter(sendBuffer, recvBuffer, length, 00594 srcProcessId); 00595 } 00596 int Scatter(const unsigned char *sendBuffer, unsigned char *recvBuffer, 00597 vtkIdType length, int srcProcessId) { 00598 return this->Communicator->Scatter(sendBuffer, recvBuffer, length, 00599 srcProcessId); 00600 } 00601 int Scatter(const char *sendBuffer, char *recvBuffer, 00602 vtkIdType length, int srcProcessId) { 00603 return this->Communicator->Scatter(sendBuffer, recvBuffer, length, 00604 srcProcessId); 00605 } 00606 int Scatter(const float *sendBuffer, float *recvBuffer, 00607 vtkIdType length, int srcProcessId) { 00608 return this->Communicator->Scatter(sendBuffer, recvBuffer, length, 00609 srcProcessId); 00610 } 00611 int Scatter(const double *sendBuffer, double *recvBuffer, 00612 vtkIdType length, int srcProcessId) { 00613 return this->Communicator->Scatter(sendBuffer, recvBuffer, length, 00614 srcProcessId); 00615 } 00616 #ifdef VTK_USE_64BIT_IDS 00617 int Scatter(const vtkIdType *sendBuffer, vtkIdType *recvBuffer, 00618 vtkIdType length, int srcProcessId) { 00619 return this->Communicator->Scatter(sendBuffer, recvBuffer, length, 00620 srcProcessId); 00621 } 00622 #endif 00623 int Scatter(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer, 00624 int srcProcessId) { 00625 return this->Communicator->Scatter(sendBuffer, recvBuffer, srcProcessId); 00626 } 00628 00630 00636 int ScatterV(const int *sendBuffer, int *recvBuffer, 00637 vtkIdType *sendLengths, vtkIdType *offsets, 00638 vtkIdType recvLength, int srcProcessId) { 00639 return this->Communicator->ScatterV(sendBuffer, recvBuffer, 00640 sendLengths, offsets, recvLength, 00641 srcProcessId); 00642 } 00643 int ScatterV(const unsigned long *sendBuffer, unsigned long *recvBuffer, 00644 vtkIdType *sendLengths, vtkIdType *offsets, 00645 vtkIdType recvLength, int srcProcessId) { 00646 return this->Communicator->ScatterV(sendBuffer, recvBuffer, 00647 sendLengths, offsets, recvLength, 00648 srcProcessId); 00649 } 00650 int ScatterV(const unsigned char *sendBuffer, unsigned char *recvBuffer, 00651 vtkIdType *sendLengths, vtkIdType *offsets, 00652 vtkIdType recvLength, int srcProcessId) { 00653 return this->Communicator->ScatterV(sendBuffer, recvBuffer, 00654 sendLengths, offsets, recvLength, 00655 srcProcessId); 00656 } 00657 int ScatterV(const char *sendBuffer, char *recvBuffer, 00658 vtkIdType *sendLengths, vtkIdType *offsets, 00659 vtkIdType recvLength, int srcProcessId) { 00660 return this->Communicator->ScatterV(sendBuffer, recvBuffer, 00661 sendLengths, offsets, recvLength, 00662 srcProcessId); 00663 } 00664 int ScatterV(const float *sendBuffer, float *recvBuffer, 00665 vtkIdType *sendLengths, vtkIdType *offsets, 00666 vtkIdType recvLength, int srcProcessId) { 00667 return this->Communicator->ScatterV(sendBuffer, recvBuffer, 00668 sendLengths, offsets, recvLength, 00669 srcProcessId); 00670 } 00671 int ScatterV(const double *sendBuffer, double *recvBuffer, 00672 vtkIdType *sendLengths, vtkIdType *offsets, 00673 vtkIdType recvLength, int srcProcessId) { 00674 return this->Communicator->ScatterV(sendBuffer, recvBuffer, 00675 sendLengths, offsets, recvLength, 00676 srcProcessId); 00677 } 00678 #ifdef VTK_USE_64BIT_IDS 00679 int ScatterV(const vtkIdType *sendBuffer, vtkIdType *recvBuffer, 00680 vtkIdType *sendLengths, vtkIdType *offsets, 00681 vtkIdType recvLength, int srcProcessId) { 00682 return this->Communicator->ScatterV(sendBuffer, recvBuffer, 00683 sendLengths, offsets, recvLength, 00684 srcProcessId); 00685 } 00686 #endif 00687 00688 00690 00691 int AllGather(const int *sendBuffer, int *recvBuffer, vtkIdType length) { 00692 return this->Communicator->AllGather(sendBuffer, recvBuffer, length); 00693 } 00694 int AllGather(const unsigned long *sendBuffer, 00695 unsigned long *recvBuffer, vtkIdType length) { 00696 return this->Communicator->AllGather(sendBuffer, recvBuffer, length); 00697 } 00698 int AllGather(const unsigned char *sendBuffer, 00699 unsigned char *recvBuffer, vtkIdType length) { 00700 return this->Communicator->AllGather(sendBuffer, recvBuffer, length); 00701 } 00702 int AllGather(const char *sendBuffer, char *recvBuffer, vtkIdType length) { 00703 return this->Communicator->AllGather(sendBuffer, recvBuffer, length); 00704 } 00705 int AllGather(const float *sendBuffer, float *recvBuffer, vtkIdType length) { 00706 return this->Communicator->AllGather(sendBuffer, recvBuffer, length); 00707 } 00708 int AllGather(const double *sendBuffer, 00709 double *recvBuffer, vtkIdType length) { 00710 return this->Communicator->AllGather(sendBuffer, recvBuffer, length); 00711 } 00712 #ifdef VTK_USE_64BIT_IDS 00713 int AllGather(const vtkIdType *sendBuffer, vtkIdType *recvBuffer, 00714 vtkIdType length) { 00715 return this->Communicator->AllGather(sendBuffer, recvBuffer, length); 00716 } 00717 #endif 00718 int AllGather(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer) { 00719 return this->Communicator->AllGather(sendBuffer, recvBuffer); 00720 } 00722 00724 00725 int AllGatherV(const int* sendBuffer, int* recvBuffer, 00726 vtkIdType sendLength, vtkIdType* recvLengths, 00727 vtkIdType* offsets) { 00728 return this->Communicator->AllGatherV(sendBuffer, recvBuffer, 00729 sendLength, recvLengths, 00730 offsets); 00731 } 00732 int AllGatherV(const unsigned long* sendBuffer, unsigned long* recvBuffer, 00733 vtkIdType sendLength, vtkIdType* recvLengths, 00734 vtkIdType* offsets) { 00735 return this->Communicator->AllGatherV(sendBuffer, recvBuffer, 00736 sendLength, recvLengths, 00737 offsets); 00738 } 00739 int AllGatherV(const unsigned char* sendBuffer, unsigned char* recvBuffer, 00740 vtkIdType sendLength, vtkIdType* recvLengths, 00741 vtkIdType* offsets) { 00742 return this->Communicator->AllGatherV(sendBuffer, recvBuffer, 00743 sendLength, recvLengths, 00744 offsets); 00745 } 00746 int AllGatherV(const char* sendBuffer, char* recvBuffer, 00747 vtkIdType sendLength, vtkIdType* recvLengths, 00748 vtkIdType* offsets) { 00749 return this->Communicator->AllGatherV(sendBuffer, recvBuffer, 00750 sendLength, recvLengths, 00751 offsets); 00752 } 00753 int AllGatherV(const float* sendBuffer, float* recvBuffer, 00754 vtkIdType sendLength, vtkIdType* recvLengths, 00755 vtkIdType* offsets) { 00756 return this->Communicator->AllGatherV(sendBuffer, recvBuffer, 00757 sendLength, recvLengths, 00758 offsets); 00759 } 00760 int AllGatherV(const double* sendBuffer, double* recvBuffer, 00761 vtkIdType sendLength, vtkIdType* recvLengths, 00762 vtkIdType* offsets) { 00763 return this->Communicator->AllGatherV(sendBuffer, recvBuffer, 00764 sendLength, recvLengths, 00765 offsets); 00766 } 00767 #ifdef VTK_USE_64BIT_IDS 00768 int AllGatherV(const vtkIdType* sendBuffer, vtkIdType* recvBuffer, 00769 vtkIdType sendLength, vtkIdType* recvLengths, 00770 vtkIdType* offsets) { 00771 return this->Communicator->AllGatherV(sendBuffer, recvBuffer, 00772 sendLength, recvLengths, 00773 offsets); 00774 } 00775 #endif 00776 int AllGatherV(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer, 00777 vtkIdType *recvLengths, vtkIdType *offsets) { 00778 return this->Communicator->AllGatherV(sendBuffer, recvBuffer, 00779 recvLengths, offsets); 00780 } 00782 00784 00789 int AllGatherV(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer) { 00790 return this->Communicator->AllGatherV(sendBuffer, recvBuffer); 00791 } 00793 00795 00798 int Reduce(const int *sendBuffer, int *recvBuffer, 00799 vtkIdType length, int operation, int destProcessId) { 00800 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00801 operation, destProcessId); 00802 } 00803 int Reduce(const unsigned int *sendBuffer, unsigned int *recvBuffer, 00804 vtkIdType length, int operation, int destProcessId) { 00805 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00806 operation, destProcessId); 00807 } 00808 int Reduce(const unsigned long *sendBuffer, unsigned long *recvBuffer, 00809 vtkIdType length, int operation, int destProcessId) { 00810 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00811 operation, destProcessId); 00812 } 00813 int Reduce(const unsigned char *sendBuffer, unsigned char *recvBuffer, 00814 vtkIdType length, int operation, int destProcessId) { 00815 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00816 operation, destProcessId); 00817 } 00818 int Reduce(const char *sendBuffer, char *recvBuffer, 00819 vtkIdType length, int operation, int destProcessId) { 00820 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00821 operation, destProcessId); 00822 } 00823 int Reduce(const float *sendBuffer, float *recvBuffer, 00824 vtkIdType length, int operation, int destProcessId) { 00825 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00826 operation, destProcessId); 00827 } 00828 int Reduce(const double *sendBuffer, double *recvBuffer, 00829 vtkIdType length, int operation, int destProcessId) { 00830 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00831 operation, destProcessId); 00832 } 00833 #ifdef VTK_USE_64BIT_IDS 00834 int Reduce(const vtkIdType *sendBuffer, vtkIdType *recvBuffer, 00835 vtkIdType length, int operation, int destProcessId) { 00836 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00837 operation, destProcessId); 00838 } 00839 #endif 00840 int Reduce(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer, 00841 int operation, int destProcessId) { 00842 return this->Communicator->Reduce(sendBuffer, recvBuffer, 00843 operation, destProcessId); 00844 } 00846 00847 //BTX 00849 00852 int Reduce(const int *sendBuffer, int *recvBuffer, 00853 vtkIdType length, vtkCommunicator::Operation *operation, 00854 int destProcessId) { 00855 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00856 operation, destProcessId); 00857 } 00858 int Reduce(const unsigned long *sendBuffer, unsigned long *recvBuffer, 00859 vtkIdType length, vtkCommunicator::Operation *operation, 00860 int destProcessId) { 00861 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00862 operation, destProcessId); 00863 } 00864 int Reduce(const unsigned char *sendBuffer, unsigned char *recvBuffer, 00865 vtkIdType length, vtkCommunicator::Operation *operation, 00866 int destProcessId) { 00867 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00868 operation, destProcessId); 00869 } 00870 int Reduce(const char *sendBuffer, char *recvBuffer, 00871 vtkIdType length, vtkCommunicator::Operation *operation, 00872 int destProcessId) { 00873 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00874 operation, destProcessId); 00875 } 00876 int Reduce(const float *sendBuffer, float *recvBuffer, 00877 vtkIdType length, vtkCommunicator::Operation *operation, 00878 int destProcessId) { 00879 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00880 operation, destProcessId); 00881 } 00882 int Reduce(const double *sendBuffer, double *recvBuffer, 00883 vtkIdType length, vtkCommunicator::Operation *operation, 00884 int destProcessId) { 00885 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00886 operation, destProcessId); 00887 } 00888 #ifdef VTK_USE_64BIT_IDS 00889 int Reduce(const vtkIdType *sendBuffer, vtkIdType *recvBuffer, 00890 vtkIdType length, vtkCommunicator::Operation *operation, 00891 int destProcessId) { 00892 return this->Communicator->Reduce(sendBuffer, recvBuffer, length, 00893 operation, destProcessId); 00894 } 00895 #endif 00896 int Reduce(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer, 00897 vtkCommunicator::Operation *operation, int destProcessId) { 00898 return this->Communicator->Reduce(sendBuffer, recvBuffer, 00899 operation, destProcessId); 00900 } 00901 //ETX 00903 00905 00907 int AllReduce(const int *sendBuffer, int *recvBuffer, 00908 vtkIdType length, int operation) { 00909 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00910 operation); 00911 } 00912 int AllReduce(const unsigned long *sendBuffer, unsigned long *recvBuffer, 00913 vtkIdType length, int operation) { 00914 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00915 operation); 00916 } 00917 int AllReduce(const unsigned char *sendBuffer, unsigned char *recvBuffer, 00918 vtkIdType length, int operation) { 00919 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00920 operation); 00921 } 00922 int AllReduce(const char *sendBuffer, char *recvBuffer, 00923 vtkIdType length, int operation) { 00924 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00925 operation); 00926 } 00927 int AllReduce(const float *sendBuffer, float *recvBuffer, 00928 vtkIdType length, int operation) { 00929 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00930 operation); 00931 } 00932 int AllReduce(const double *sendBuffer, double *recvBuffer, 00933 vtkIdType length, int operation) { 00934 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00935 operation); 00936 } 00937 #ifdef VTK_USE_64BIT_IDS 00938 int AllReduce(const vtkIdType *sendBuffer, vtkIdType *recvBuffer, 00939 vtkIdType length, int operation) { 00940 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00941 operation); 00942 } 00943 #endif 00944 int AllReduce(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer, 00945 int operation) { 00946 return this->Communicator->AllReduce(sendBuffer, recvBuffer, operation); 00947 } 00948 //BTX 00949 int AllReduce(const int *sendBuffer, int *recvBuffer, 00950 vtkIdType length, vtkCommunicator::Operation *operation) { 00951 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00952 operation); 00953 } 00954 int AllReduce(const unsigned long *sendBuffer, unsigned long *recvBuffer, 00955 vtkIdType length, vtkCommunicator::Operation *operation) { 00956 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00957 operation); 00958 } 00959 int AllReduce(const unsigned char *sendBuffer, unsigned char *recvBuffer, 00960 vtkIdType length, vtkCommunicator::Operation *operation) { 00961 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00962 operation); 00963 } 00964 int AllReduce(const char *sendBuffer, char *recvBuffer, 00965 vtkIdType length, vtkCommunicator::Operation *operation) { 00966 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00967 operation); 00968 } 00969 int AllReduce(const float *sendBuffer, float *recvBuffer, 00970 vtkIdType length, vtkCommunicator::Operation *operation) { 00971 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00972 operation); 00973 } 00974 int AllReduce(const double *sendBuffer, double *recvBuffer, 00975 vtkIdType length, vtkCommunicator::Operation *operation) { 00976 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00977 operation); 00978 } 00979 #ifdef VTK_USE_64BIT_IDS 00980 int AllReduce(const vtkIdType *sendBuffer, vtkIdType *recvBuffer, 00981 vtkIdType length, vtkCommunicator::Operation *operation) { 00982 return this->Communicator->AllReduce(sendBuffer, recvBuffer, length, 00983 operation); 00984 } 00985 #endif 00986 int AllReduce(vtkDataArray *sendBuffer, vtkDataArray *recvBuffer, 00987 vtkCommunicator::Operation *operation) { 00988 return this->Communicator->AllReduce(sendBuffer, recvBuffer, operation); 00989 } 00990 //ETX 00992 00993 // Internally implemented RMI to break the process loop. 00994 00995 protected: 00996 vtkMultiProcessController(); 00997 ~vtkMultiProcessController(); 00998 01000 01003 virtual void TriggerRMIInternal(int remoteProcessId, 01004 void* arg, int argLength, int rmiTag, bool propagate); 01006 01007 vtkProcessFunctionType SingleMethod; 01008 void *SingleData; 01009 01010 void GetMultipleMethod(int index, vtkProcessFunctionType &func, void *&data); 01011 01012 // This is a flag that can be used by the ports to break 01013 // their update loop. (same as ProcessRMIs) 01014 int BreakFlag; 01015 01016 void ProcessRMI(int remoteProcessId, void *arg, int argLength, int rmiTag); 01017 01018 // This method implements "GetGlobalController". 01019 // It needs to be virtual and static. 01020 virtual vtkMultiProcessController *GetLocalController(); 01021 01022 01023 // This flag can force deep copies during send. 01024 int ForceDeepCopy; 01025 01026 vtkOutputWindow* OutputWindow; 01027 01028 // Note that since the communicators can be created differently 01029 // depending on the type of controller, the subclasses are 01030 // responsible of deleting them. 01031 vtkCommunicator* Communicator; 01032 01033 // Communicator which is a copy of the current user 01034 // level communicator except the context; i.e. even if the tags 01035 // are the same, the RMI messages will not interfere with user 01036 // level messages. 01037 // Note that since the communicators can be created differently 01038 // depending on the type of controller, the subclasses are 01039 // responsible of deleting them. 01040 vtkCommunicator* RMICommunicator; 01041 01042 private: 01043 vtkMultiProcessController(const vtkMultiProcessController&); // Not implemented. 01044 void operator=(const vtkMultiProcessController&); // Not implemented. 01045 01046 unsigned long RMICount; 01047 01048 //BTX 01049 class vtkInternal; 01050 vtkInternal *Internal; 01051 //ETX 01052 }; 01053 01054 01055 inline int vtkMultiProcessController::Send(vtkDataObject *data, 01056 int remoteProcessId, int tag) 01057 { 01058 if (this->Communicator) 01059 { 01060 return this->Communicator->Send(data, remoteProcessId, tag); 01061 } 01062 else 01063 { 01064 return 0; 01065 } 01066 } 01067 01068 inline int vtkMultiProcessController::Send(vtkDataArray *data, 01069 int remoteProcessId, int tag) 01070 { 01071 if (this->Communicator) 01072 { 01073 return this->Communicator->Send(data, remoteProcessId, tag); 01074 } 01075 else 01076 { 01077 return 0; 01078 } 01079 } 01080 01081 inline int vtkMultiProcessController::Send(const int* data, vtkIdType length, 01082 int remoteProcessId, int tag) 01083 { 01084 if (this->Communicator) 01085 { 01086 return this->Communicator->Send(data, length, remoteProcessId, tag); 01087 } 01088 else 01089 { 01090 return 0; 01091 } 01092 } 01093 01094 inline int vtkMultiProcessController::Send(const unsigned int* data, vtkIdType length, 01095 int remoteProcessId, int tag) 01096 { 01097 if (this->Communicator) 01098 { 01099 return this->Communicator->Send(data, length, remoteProcessId, tag); 01100 } 01101 else 01102 { 01103 return 0; 01104 } 01105 } 01106 01107 inline int vtkMultiProcessController::Send(const unsigned long* data, 01108 vtkIdType length, 01109 int remoteProcessId, 01110 int tag) 01111 { 01112 if (this->Communicator) 01113 { 01114 return this->Communicator->Send(data, length, remoteProcessId, tag); 01115 } 01116 else 01117 { 01118 return 0; 01119 } 01120 } 01121 01122 inline int vtkMultiProcessController::Send(const char* data, vtkIdType length, 01123 int remoteProcessId, int tag) 01124 { 01125 if (this->Communicator) 01126 { 01127 return this->Communicator->Send(data, length, remoteProcessId, tag); 01128 } 01129 else 01130 { 01131 return 0; 01132 } 01133 } 01134 01135 inline int vtkMultiProcessController::Send(const unsigned char* data, 01136 vtkIdType length, 01137 int remoteProcessId, int tag) 01138 { 01139 if (this->Communicator) 01140 { 01141 return this->Communicator->Send(data, length, remoteProcessId, tag); 01142 } 01143 else 01144 { 01145 return 0; 01146 } 01147 } 01148 01149 inline int vtkMultiProcessController::Send(const float* data, vtkIdType length, 01150 int remoteProcessId, int tag) 01151 { 01152 if (this->Communicator) 01153 { 01154 return this->Communicator->Send(data, length, remoteProcessId, tag); 01155 } 01156 else 01157 { 01158 return 0; 01159 } 01160 } 01161 01162 inline int vtkMultiProcessController::Send(const double* data, vtkIdType length, 01163 int remoteProcessId, int tag) 01164 { 01165 if (this->Communicator) 01166 { 01167 return this->Communicator->Send(data, length, remoteProcessId, tag); 01168 } 01169 else 01170 { 01171 return 0; 01172 } 01173 } 01174 01175 #ifdef VTK_USE_64BIT_IDS 01176 inline int vtkMultiProcessController::Send(const vtkIdType* data, 01177 vtkIdType length, 01178 int remoteProcessId, int tag) 01179 { 01180 if (this->Communicator) 01181 { 01182 return this->Communicator->Send(data, length, remoteProcessId, tag); 01183 } 01184 else 01185 { 01186 return 0; 01187 } 01188 } 01189 #endif 01190 01191 inline int vtkMultiProcessController::Send(const vtkMultiProcessStream& stream, 01192 int remoteId, int tag) 01193 { 01194 if (this->Communicator) 01195 { 01196 return this->Communicator->Send(stream, remoteId, tag); 01197 } 01198 return 0; 01199 } 01200 01201 inline int vtkMultiProcessController::Receive(vtkDataObject* data, 01202 int remoteProcessId, int tag) 01203 { 01204 if (this->Communicator) 01205 { 01206 return this->Communicator->Receive(data, remoteProcessId, tag); 01207 } 01208 else 01209 { 01210 return 0; 01211 } 01212 } 01213 01214 inline vtkDataObject* vtkMultiProcessController::ReceiveDataObject( 01215 int remoteProcessId, int tag) 01216 { 01217 if (this->Communicator) 01218 { 01219 return this->Communicator->ReceiveDataObject(remoteProcessId, tag); 01220 } 01221 else 01222 { 01223 return 0; 01224 } 01225 } 01226 01227 inline int vtkMultiProcessController::Receive(vtkDataArray* data, 01228 int remoteProcessId, int tag) 01229 { 01230 if (this->Communicator) 01231 { 01232 return this->Communicator->Receive(data, remoteProcessId, tag); 01233 } 01234 else 01235 { 01236 return 0; 01237 } 01238 } 01239 01240 inline int vtkMultiProcessController::Receive(int* data, vtkIdType length, 01241 int remoteProcessId, int tag) 01242 { 01243 if (this->Communicator) 01244 { 01245 return this->Communicator->Receive(data, length, remoteProcessId, tag); 01246 } 01247 else 01248 { 01249 return 0; 01250 } 01251 } 01252 01253 inline int vtkMultiProcessController::Receive(unsigned int* data, vtkIdType length, 01254 int remoteProcessId, int tag) 01255 { 01256 if (this->Communicator) 01257 { 01258 return this->Communicator->Receive(data, length, remoteProcessId, tag); 01259 } 01260 else 01261 { 01262 return 0; 01263 } 01264 } 01265 01266 inline int vtkMultiProcessController::Receive(unsigned long* data, 01267 vtkIdType length, 01268 int remoteProcessId, 01269 int tag) 01270 { 01271 if (this->Communicator) 01272 { 01273 return this->Communicator->Receive(data, length, remoteProcessId, tag); 01274 } 01275 else 01276 { 01277 return 0; 01278 } 01279 } 01280 01281 inline int vtkMultiProcessController::Receive(char* data, vtkIdType length, 01282 int remoteProcessId, int tag) 01283 { 01284 if (this->Communicator) 01285 { 01286 return this->Communicator->Receive(data, length, remoteProcessId, tag); 01287 } 01288 else 01289 { 01290 return 0; 01291 } 01292 } 01293 01294 inline int vtkMultiProcessController::Receive(unsigned char* data, 01295 vtkIdType length, 01296 int remoteProcessId, int tag) 01297 { 01298 if (this->Communicator) 01299 { 01300 return this->Communicator->Receive(data, length, remoteProcessId, tag); 01301 } 01302 else 01303 { 01304 return 0; 01305 } 01306 } 01307 01308 inline int vtkMultiProcessController::Receive(float* data, vtkIdType length, 01309 int remoteProcessId, int tag) 01310 { 01311 if (this->Communicator) 01312 { 01313 return this->Communicator->Receive(data, length, remoteProcessId, tag); 01314 } 01315 else 01316 { 01317 return 0; 01318 } 01319 } 01320 01321 inline int vtkMultiProcessController::Receive(double* data, vtkIdType length, 01322 int remoteProcessId, int tag) 01323 { 01324 if (this->Communicator) 01325 { 01326 return this->Communicator->Receive(data, length, remoteProcessId, tag); 01327 } 01328 else 01329 { 01330 return 0; 01331 } 01332 } 01333 01334 #ifdef VTK_USE_64BIT_IDS 01335 inline int vtkMultiProcessController::Receive(vtkIdType* data, 01336 vtkIdType length, 01337 int remoteProcessId, int tag) 01338 { 01339 if (this->Communicator) 01340 { 01341 return this->Communicator->Receive(data, length, remoteProcessId, tag); 01342 } 01343 else 01344 { 01345 return 0; 01346 } 01347 } 01348 #endif 01349 01350 01351 inline int vtkMultiProcessController::Receive(vtkMultiProcessStream& stream, 01352 int remoteId, int tag) 01353 { 01354 if (this->Communicator) 01355 { 01356 return this->Communicator->Receive(stream, remoteId, tag); 01357 } 01358 return 0; 01359 } 01360 01361 inline void vtkMultiProcessController::Barrier() 01362 { 01363 if (this->Communicator) 01364 { 01365 this->Communicator->Barrier(); 01366 } 01367 } 01368 01369 inline vtkIdType vtkMultiProcessController::GetCount() 01370 { 01371 if (this->Communicator) 01372 { 01373 return this->Communicator->GetCount(); 01374 } 01375 return 0; 01376 } 01377 01378 #endif