Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Epetra_MpiDistributor.h
Go to the documentation of this file.
1 /*
2 //@HEADER
3 // ************************************************************************
4 //
5 // Epetra: Linear Algebra Services Package
6 // Copyright 2011 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ************************************************************************
41 //@HEADER
42 */
43 
44 #ifndef EPETRA_MPIDISTRIBUTOR_H
45 #define EPETRA_MPIDISTRIBUTOR_H
46 
47 #if defined(Epetra_SHOW_DEPRECATED_WARNINGS)
48 #ifdef __GNUC__
49 #warning "The Epetra package is deprecated"
50 #endif
51 #endif
52 
53 
54 #include "Epetra_Object.h"
55 #include "Epetra_Distributor.h"
56 class Epetra_MpiComm;
57 #include <mpi.h>
58 
68 
69  public:
70 
72 
73 
76 
78  Epetra_MpiDistributor(const Epetra_MpiDistributor & Distributor);
79 
81  Epetra_Distributor * Clone(){return(dynamic_cast<Epetra_Distributor *>(new Epetra_MpiDistributor(*this)));};
82 
84 
88 
90  virtual ~Epetra_MpiDistributor();
92 
93 
95 
96 
112  int CreateFromSends( const int & NumExportIDs,
113  const int * ExportPIDs,
114  bool Deterministic,
115  int & NumRemoteIDs );
116 
141  int CreateFromRecvs( const int & NumRemoteIDs,
142  const int * RemoteGIDs,
143  const int * RemotePIDs,
144  bool Deterministic,
145  int & NumExportIDs,
146  int *& ExportGIDs,
147  int *& ExportPIDs);
148 
149 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
150  int CreateFromRecvs( const int & NumRemoteIDs,
151  const long long * RemoteGIDs,
152  const int * RemotePIDs,
153  bool Deterministic,
154  int & NumExportIDs,
155  long long *& ExportGIDs,
156  int *& ExportPIDs);
157 #endif
158 
159 
160 
161 
164 
187 
188  int CreateFromSendsAndRecvs( const int & NumExportIDs,
189  const int * ExportPIDs,
190  const int & NumRemoteIDs,
191  const int * RemoteGIDs,
192  const int * RemotePIDs,
193  bool Deterministic);
194 
195 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
196  int CreateFromSendsAndRecvs( const int & NumExportIDs,
197  const int * ExportPIDs,
198  const int & NumRemoteIDs,
199  const long long * RemoteGIDs,
200  const int * RemotePIDs,
201  bool Deterministic);
202 #endif
203 
204 
206 
208 
209 
211  int Do( char * export_objs,
212  int obj_size,
213  int & len_import_objs,
214  char *& import_objs );
215 
217  int DoReverse( char * export_objs,
218  int obj_size,
219  int & len_import_objs,
220  char *& import_objs );
221 
223  int DoPosts( char * export_objs,
224  int obj_size,
225  int & len_import_objs,
226  char *& import_objs );
228  int DoWaits();
229 
231  int DoReversePosts( char * export_objs,
232  int obj_size,
233  int & len_import_objs,
234  char *& import_objs );
235 
237  int DoReverseWaits();
239 
241 
242 
244  int Do( char * export_objs,
245  int obj_size,
246  int *& sizes,
247  int & len_import_objs,
248  char *& import_objs );
249 
251  int DoReverse( char * export_objs,
252  int obj_size,
253  int *& sizes,
254  int & len_import_objs,
255  char *& import_objs );
256 
258  int DoPosts( char * export_objs,
259  int obj_size,
260  int *& sizes,
261  int & len_import_objs,
262  char *& import_objs);
263 
265  int DoReversePosts( char * export_objs,
266  int obj_size,
267  int *& sizes,
268  int & len_import_objs,
269  char *& import_objs );
271 
272 
274 
275  int NumReceives() const {return nrecvs_;}
277 
279  int NumSends() const {return nsends_;}
280 
282  int MaxSendLength() const {return max_send_length_;}
283 
285  int TotalReceiveLength() const { return total_recv_length_;}
286 
288  const int * ProcsFrom() const {return procs_from_;}
289 
291  const int * ProcsTo() const {return procs_to_;}
292 
294 
295  const int * LengthsFrom() const {return lengths_from_;}
296 
298 
299  const int * LengthsTo() const {return lengths_to_;}
300 
304  void GetLastDoStatistics(int & bytes_sent, int & bytes_recvd) const {
305  bytes_sent = lastRoundBytesSend_;
306  bytes_recvd = lastRoundBytesRecv_;
307  }
308 
310 
312 
313  void Print(std::ostream & os) const;
315  private:
316  int CreateSendStructures_(int my_proc,
317  int nprocs,
318  const int & NumExportIDs,
319  const int * ExportPIDs);
320 
321 
322  int CreateRecvStructures_(const int & NumRemoteIDs,
323  const int * RemotePIDs);
324 
325 
326  int ComputeRecvs_( int my_proc,
327  int nprocs );
328 
329  template<typename id_type>
330  int ComputeSends_( int num_imports,
331  const id_type *& import_ids,
332  const int *& import_procs,
333  int & num_exports,
334  id_type *& export_ids,
335  int *& export_procs,
336  int my_proc );
337 
338 
339  int Resize_(int *sizes);
340 
341  int Sort_ints_( int *vals, int *other, int nvals );
342 
343  private:
345 
347 
348  int * lengths_to_;
349  int * procs_to_;
350  int * indices_to_;
352 
354  int * procs_from_;
357 
358  bool resized_;
359  int * sizes_;
360 
361  int * sizes_to_;
362  int * starts_to_;
365 
366  int * sizes_from_;
370 
371  int nrecvs_;
372  int nsends_;
374 
376 
379 
380  int tag_;
381 
383  const MPI_Comm comm_;
384 
385  MPI_Request * request_;
386  MPI_Status * status_;
387 
389 
390  char * send_array_;
392 
394 
397 };
398 #endif /* EPETRA_MPIDISTRIBUTOR_H */
const int * LengthsFrom() const
Number of values we&#39;re receiving from each proc.
int CreateSendStructures_(int my_proc, int nprocs, const int &NumExportIDs, const int *ExportPIDs)
int ComputeSends_(int num_imports, const id_type *&import_ids, const int *&import_procs, int &num_exports, id_type *&export_ids, int *&export_procs, int my_proc)
int ComputeRecvs_(int my_proc, int nprocs)
Epetra_MpiDistributor & operator=(const Epetra_MpiDistributor &src)
int DoPosts(char *export_objs, int obj_size, int &len_import_objs, char *&import_objs)
Post buffer of export objects (can do other local work before executing Waits)
Epetra_Distributor: The Epetra Gather/Scatter Setup Base Class.
int CreateFromRecvs(const int &NumRemoteIDs, const int *RemoteGIDs, const int *RemotePIDs, bool Deterministic, int &NumExportIDs, int *&ExportGIDs, int *&ExportPIDs)
Create a communication plan from receive list.
int NumReceives() const
The number of procs from which we will receive data.
int DoReverseWaits()
Wait on a reverse set of posts.
int CreateFromSendsAndRecvs(const int &NumExportIDs, const int *ExportPIDs, const int &NumRemoteIDs, const int *RemoteGIDs, const int *RemotePIDs, bool Deterministic)
Create a communication plan from send list and a recv list.
MPI implementation of Epetra_Distributor.
Epetra_MpiComm: The Epetra MPI Communication Class.
int CreateRecvStructures_(const int &NumRemoteIDs, const int *RemotePIDs)
int NumSends() const
The number of procs to which we will send data.
Epetra_Object: The base Epetra class.
Definition: Epetra_Object.h:65
int TotalReceiveLength() const
Total number of values that this proc is receiving from other procs.
virtual ~Epetra_MpiDistributor()
Destructor (declared virtual for memory safety).
int MaxSendLength() const
Maximum number of values that this proc is sending to another single proc.
int CreateFromSends(const int &NumExportIDs, const int *ExportPIDs, bool Deterministic, int &NumRemoteIDs)
Create a communication plan from send list.
int DoWaits()
Wait on a set of posts.
const int * ProcsTo() const
A list of procs to which this proc is sending values.
const int * LengthsTo() const
Number of values we&#39;re sending to each proc.
int DoReversePosts(char *export_objs, int obj_size, int &len_import_objs, char *&import_objs)
Do reverse post of buffer of export objects (can do other local work before executing Waits) ...
Epetra_Distributor * ReverseClone()
Create and extract the reverse version of the distributor.
Epetra_Distributor * Clone()
Clone method.
void Print(std::ostream &os) const
Epetra_MpiDistributor * comm_plan_reverse_
const int * ProcsFrom() const
A list of procs sending values to this proc.
int Sort_ints_(int *vals, int *other, int nvals)
int Do(char *export_objs, int obj_size, int &len_import_objs, char *&import_objs)
Execute plan on buffer of export objects in a single step.
Epetra_MpiDistributor(const Epetra_MpiComm &Comm)
Default constructor.
int DoReverse(char *export_objs, int obj_size, int &len_import_objs, char *&import_objs)
Execute reverse of plan on buffer of export objects in a single step.
const Epetra_MpiComm * epComm_
void GetLastDoStatistics(int &bytes_sent, int &bytes_recvd) const
Information on the last call to Do/DoReverse.