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 #include "Epetra_Object.h"
47 #include "Epetra_Distributor.h"
48 class Epetra_MpiComm;
49 #include <mpi.h>
50 
60 
61  public:
62 
64 
65 
68 
70  Epetra_MpiDistributor(const Epetra_MpiDistributor & Distributor);
71 
73  Epetra_Distributor * Clone(){return(dynamic_cast<Epetra_Distributor *>(new Epetra_MpiDistributor(*this)));};
74 
76 
80 
82  virtual ~Epetra_MpiDistributor();
84 
85 
87 
88 
104  int CreateFromSends( const int & NumExportIDs,
105  const int * ExportPIDs,
106  bool Deterministic,
107  int & NumRemoteIDs );
108 
133  int CreateFromRecvs( const int & NumRemoteIDs,
134  const int * RemoteGIDs,
135  const int * RemotePIDs,
136  bool Deterministic,
137  int & NumExportIDs,
138  int *& ExportGIDs,
139  int *& ExportPIDs);
140 
141 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
142  int CreateFromRecvs( const int & NumRemoteIDs,
143  const long long * RemoteGIDs,
144  const int * RemotePIDs,
145  bool Deterministic,
146  int & NumExportIDs,
147  long long *& ExportGIDs,
148  int *& ExportPIDs);
149 #endif
150 
151 
152 
153 
156 
179 
180  int CreateFromSendsAndRecvs( const int & NumExportIDs,
181  const int * ExportPIDs,
182  const int & NumRemoteIDs,
183  const int * RemoteGIDs,
184  const int * RemotePIDs,
185  bool Deterministic);
186 
187 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
188  int CreateFromSendsAndRecvs( const int & NumExportIDs,
189  const int * ExportPIDs,
190  const int & NumRemoteIDs,
191  const long long * RemoteGIDs,
192  const int * RemotePIDs,
193  bool Deterministic);
194 #endif
195 
196 
198 
200 
201 
203  int Do( char * export_objs,
204  int obj_size,
205  int & len_import_objs,
206  char *& import_objs );
207 
209  int DoReverse( char * export_objs,
210  int obj_size,
211  int & len_import_objs,
212  char *& import_objs );
213 
215  int DoPosts( char * export_objs,
216  int obj_size,
217  int & len_import_objs,
218  char *& import_objs );
220  int DoWaits();
221 
223  int DoReversePosts( char * export_objs,
224  int obj_size,
225  int & len_import_objs,
226  char *& import_objs );
227 
229  int DoReverseWaits();
231 
233 
234 
236  int Do( char * export_objs,
237  int obj_size,
238  int *& sizes,
239  int & len_import_objs,
240  char *& import_objs );
241 
243  int DoReverse( char * export_objs,
244  int obj_size,
245  int *& sizes,
246  int & len_import_objs,
247  char *& import_objs );
248 
250  int DoPosts( char * export_objs,
251  int obj_size,
252  int *& sizes,
253  int & len_import_objs,
254  char *& import_objs);
255 
257  int DoReversePosts( char * export_objs,
258  int obj_size,
259  int *& sizes,
260  int & len_import_objs,
261  char *& import_objs );
263 
264 
266 
267  int NumReceives() const {return nrecvs_;}
269 
271  int NumSends() const {return nsends_;}
272 
274  int MaxSendLength() const {return max_send_length_;}
275 
277  int TotalReceiveLength() const { return total_recv_length_;}
278 
280  const int * ProcsFrom() const {return procs_from_;}
281 
283  const int * ProcsTo() const {return procs_to_;}
284 
286 
287  const int * LengthsFrom() const {return lengths_from_;}
288 
290 
291  const int * LengthsTo() const {return lengths_to_;}
292 
296  void GetLastDoStatistics(int & bytes_sent, int & bytes_recvd) const {
297  bytes_sent = lastRoundBytesSend_;
298  bytes_recvd = lastRoundBytesRecv_;
299  }
300 
302 
304 
305  void Print(std::ostream & os) const;
307  private:
308  int CreateSendStructures_(int my_proc,
309  int nprocs,
310  const int & NumExportIDs,
311  const int * ExportPIDs);
312 
313 
314  int CreateRecvStructures_(const int & NumRemoteIDs,
315  const int * RemotePIDs);
316 
317 
318  int ComputeRecvs_( int my_proc,
319  int nprocs );
320 
321  template<typename id_type>
322  int ComputeSends_( int num_imports,
323  const id_type *& import_ids,
324  const int *& import_procs,
325  int & num_exports,
326  id_type *& export_ids,
327  int *& export_procs,
328  int my_proc );
329 
330 
331  int Resize_(int *sizes);
332 
333  int Sort_ints_( int *vals, int *other, int nvals );
334 
335  private:
337 
339 
340  int * lengths_to_;
341  int * procs_to_;
342  int * indices_to_;
344 
346  int * procs_from_;
349 
350  bool resized_;
351  int * sizes_;
352 
353  int * sizes_to_;
354  int * starts_to_;
357 
358  int * sizes_from_;
362 
363  int nrecvs_;
364  int nsends_;
366 
368 
371 
372  int tag_;
373 
375  const MPI_Comm comm_;
376 
377  MPI_Request * request_;
378  MPI_Status * status_;
379 
381 
382  char * send_array_;
384 
386 
389 };
390 #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:57
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.