VTK
vtkMPIController.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMPIController.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
48 #ifndef __vtkMPIController_h
49 #define __vtkMPIController_h
50 
52 // Do not remove this header file. This class contains methods
53 // which take arguments defined in vtkMPICommunicator.h by
54 // reference.
55 #include "vtkMPICommunicator.h" // Needed for direct access to communicator
56 
58 {
59 
60 public:
61 
62  static vtkMPIController *New();
64  void PrintSelf(ostream& os, vtkIndent indent);
65 
67 
75  virtual void Initialize(int* argc, char*** argv)
76  { this->Initialize(argc, argv, 0); }
78 
79  virtual void Initialize(int* vtkNotUsed(argc), char*** vtkNotUsed(argv),
80  int initializedExternally);
81 
84  virtual void Initialize();
85 
88  virtual void Finalize() { this->Finalize(0); }
89 
90  virtual void Finalize(int finalizedExternally);
91 
94  virtual void SingleMethodExecute();
95 
99  virtual void MultipleMethodExecute();
100 
103  virtual void CreateOutputWindow();
104 
107  static char* ErrorString(int err);
108 
109 
115  void SetCommunicator(vtkMPICommunicator* comm);
116 
118 
119  virtual vtkMPIController *PartitionController(int localColor, int localKey);
120 
121 //BTX
122 
124 
129  int NoBlockSend(const int* data, int length, int remoteProcessId, int tag,
131  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend
132  (data ,length, remoteProcessId, tag, req); }
133  int NoBlockSend(const unsigned long* data, int length, int remoteProcessId,
134  int tag, vtkMPICommunicator::Request& req)
135  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend
136  (data, length, remoteProcessId, tag, req); }
137  int NoBlockSend(const char* data, int length, int remoteProcessId,
138  int tag, vtkMPICommunicator::Request& req)
139  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend
140  (data, length, remoteProcessId, tag, req); }
141  int NoBlockSend(const float* data, int length, int remoteProcessId,
142  int tag, vtkMPICommunicator::Request& req)
143  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend
144  (data, length, remoteProcessId, tag, req); }
146 
148 
152  int NoBlockReceive(int* data, int length, int remoteProcessId,
153  int tag, vtkMPICommunicator::Request& req)
154  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
155  (data, length, remoteProcessId, tag, req); }
156  int NoBlockReceive(unsigned long* data, int length,
157  int remoteProcessId, int tag,
159  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
160  (data, length, remoteProcessId, tag, req); }
161  int NoBlockReceive(char* data, int length, int remoteProcessId,
162  int tag, vtkMPICommunicator::Request& req)
163  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
164  (data, length, remoteProcessId, tag, req); }
165  int NoBlockReceive(float* data, int length, int remoteProcessId,
166  int tag, vtkMPICommunicator::Request& req)
167  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
168  (data, length, remoteProcessId, tag, req); }
169 #ifdef VTK_USE_64BIT_IDS
170  int NoBlockReceive(vtkIdType* data, int length, int remoteProcessId,
171  int tag, vtkMPICommunicator::Request& req)
172  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
173  (data, length, remoteProcessId, tag, req); }
174 #endif
175 
176 
177 //ETX
178 
179  static const char* GetProcessorName();
180 
182 
184  static void SetUseSsendForRMI(int use_send)
185  { vtkMPIController::UseSsendForRMI = (use_send != 0)? 1: 0; }
187 //BTX
188 protected:
190  ~vtkMPIController();
192 
193  // Set the communicator to comm and call InitializeNumberOfProcesses()
194  void InitializeCommunicator(vtkMPICommunicator* comm);
195 
196  // Duplicate the current communicator, creating RMICommunicator
197  void InitializeRMICommunicator();
198 
200 
203  virtual void TriggerRMIInternal(int remoteProcessId,
204  void* arg, int argLength, int rmiTag, bool propagate);
206 
207  // MPI communicator created when Initialize() called.
208  // This is a copy of MPI_COMM_WORLD but uses a new
209  // context, i.e. even if the tags are the same, the
210  // RMI messages will not interfere with user level
211  // messages.
213 
214  friend class vtkMPIOutputWindow;
215 
216  // Initialize only once.
217  static int Initialized;
218 
219  static char ProcessorName[];
220 
222 
223  static int UseSsendForRMI;
224 private:
225  vtkMPIController(const vtkMPIController&); // Not implemented.
226  void operator=(const vtkMPIController&); // Not implemented.
227 //ETX
228 };
230 
231 
232 #endif
233 
234