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 
130  int NoBlockSend(const int* data, int length, int remoteProcessId, int tag,
132  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend
133  (data ,length, remoteProcessId, tag, req); }
134  int NoBlockSend(const unsigned long* data, int length, int remoteProcessId,
135  int tag, vtkMPICommunicator::Request& req)
136  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend
137  (data, length, remoteProcessId, tag, req); }
138  int NoBlockSend(const char* data, int length, int remoteProcessId,
139  int tag, vtkMPICommunicator::Request& req)
140  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend
141  (data, length, remoteProcessId, tag, req); }
142  int NoBlockSend(const float* data, int length, int remoteProcessId,
143  int tag, vtkMPICommunicator::Request& req)
144  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend
145  (data, length, remoteProcessId, tag, req); }
146  int NoBlockSend(const double* data, int length, int remoteProcessId,
147  int tag, vtkMPICommunicator::Request& req)
148  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockSend
149  (data, length, remoteProcessId, tag, req); }
151 
153 
158  int NoBlockReceive(int* data, int length, int remoteProcessId,
159  int tag, vtkMPICommunicator::Request& req)
160  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
161  (data, length, remoteProcessId, tag, req); }
162  int NoBlockReceive(unsigned long* data, int length,
163  int remoteProcessId, int tag,
165  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
166  (data, length, remoteProcessId, tag, req); }
167  int NoBlockReceive(char* data, int length, int remoteProcessId,
168  int tag, vtkMPICommunicator::Request& req)
169  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
170  (data, length, remoteProcessId, tag, req); }
171  int NoBlockReceive(float* data, int length, int remoteProcessId,
172  int tag, vtkMPICommunicator::Request& req)
173  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
174  (data, length, remoteProcessId, tag, req); }
175  int NoBlockReceive(double* data, int length, int remoteProcessId,
176  int tag, vtkMPICommunicator::Request& req)
177  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
178  (data, length, remoteProcessId, tag, req); }
179 #ifdef VTK_USE_64BIT_IDS
180  int NoBlockReceive(vtkIdType* data, int length, int remoteProcessId,
181  int tag, vtkMPICommunicator::Request& req)
182  { return ((vtkMPICommunicator*)this->Communicator)->NoBlockReceive
183  (data, length, remoteProcessId, tag, req); }
184 #endif
185 
186 
188 
195  int Iprobe(int source, int tag, int* flag, int* actualSource)
196  { return ((vtkMPICommunicator*)this->Communicator)->Iprobe(
197  source, tag, flag, actualSource); }
198  int Iprobe(int source, int tag, int* flag, int* actualSource,
199  int* type, int* size)
200  { return ((vtkMPICommunicator*)this->Communicator)->Iprobe(
201  source, tag, flag, actualSource, type, size); }
202  int Iprobe(int source, int tag, int* flag, int* actualSource,
203  unsigned long* type, int* size)
204  { return ((vtkMPICommunicator*)this->Communicator)->Iprobe(
205  source, tag, flag, actualSource, type, size); }
206  int Iprobe(int source, int tag, int* flag, int* actualSource,
207  const char* type, int* size)
208  { return ((vtkMPICommunicator*)this->Communicator)->Iprobe(
209  source, tag, flag, actualSource, type, size); }
210  int Iprobe(int source, int tag, int* flag, int* actualSource,
211  float* type, int* size)
212  { return ((vtkMPICommunicator*)this->Communicator)->Iprobe(
213  source, tag, flag, actualSource, type, size); }
214  int Iprobe(int source, int tag, int* flag, int* actualSource,
215  double* type, int* size)
216  { return ((vtkMPICommunicator*)this->Communicator)->Iprobe(
217  source, tag, flag, actualSource, type, size); }
219 
220 //ETX
221 
222  static const char* GetProcessorName();
223 
225 
227  static void SetUseSsendForRMI(int use_send)
228  { vtkMPIController::UseSsendForRMI = (use_send != 0)? 1: 0; }
230 //BTX
231 protected:
233  ~vtkMPIController();
235 
236  // Set the communicator to comm and call InitializeNumberOfProcesses()
237  void InitializeCommunicator(vtkMPICommunicator* comm);
238 
239  // Duplicate the current communicator, creating RMICommunicator
240  void InitializeRMICommunicator();
241 
243 
246  virtual void TriggerRMIInternal(int remoteProcessId,
247  void* arg, int argLength, int rmiTag, bool propagate);
249 
250  // MPI communicator created when Initialize() called.
251  // This is a copy of MPI_COMM_WORLD but uses a new
252  // context, i.e. even if the tags are the same, the
253  // RMI messages will not interfere with user level
254  // messages.
256 
257  friend class vtkMPIOutputWindow;
258 
259  // Initialize only once.
260  static int Initialized;
261 
262  static char ProcessorName[];
263 
265 
266  static int UseSsendForRMI;
267 private:
268  vtkMPIController(const vtkMPIController&); // Not implemented.
269  void operator=(const vtkMPIController&); // Not implemented.
270 //ETX
271 };
273 
274 
275 #endif
276 
277