Epetra Package Browser (Single Doxygen Collection) Development
Loading...
Searching...
No Matches
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"
48class Epetra_MpiComm;
49#include <mpi.h>
50
60
61 public:
62
64
65
68
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
268 int NumReceives() const {return nrecvs_;}
269
271 int NumSends() const {return nsends_;}
272
274 int MaxSendLength() const {return max_send_length_;}
275
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
344
349
351 int * sizes_;
352
357
362
366
368
371
372 int tag_;
373
375 const MPI_Comm comm_;
376
377 MPI_Request * request_;
378 MPI_Status * status_;
379
381
384
386
389};
390#endif /* EPETRA_MPIDISTRIBUTOR_H */
Epetra_Distributor: The Epetra Gather/Scatter Setup Base Class.
Epetra_MpiComm: The Epetra MPI Communication Class.
MPI implementation of Epetra_Distributor.
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)
int MaxSendLength() const
Maximum number of values that this proc is sending to another single proc.
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.
Epetra_Distributor * Clone()
Clone method.
int Sort_ints_(int *vals, int *other, int nvals)
const Epetra_MpiComm * epComm_
Epetra_Distributor * ReverseClone()
Create and extract the reverse version of the distributor.
void Print(std::ostream &os) const
int ComputeRecvs_(int my_proc, int nprocs)
const int * ProcsFrom() const
A list of procs sending values to this proc.
const int * ProcsTo() const
A list of procs to which this proc is sending values.
virtual ~Epetra_MpiDistributor()
Destructor (declared virtual for memory safety).
int NumSends() const
The number of procs to which we will send data.
const int * LengthsTo() const
Number of values we're sending to each proc.
int DoReverseWaits()
Wait on a reverse set of posts.
int CreateSendStructures_(int my_proc, int nprocs, const int &NumExportIDs, const int *ExportPIDs)
Epetra_MpiDistributor * comm_plan_reverse_
Epetra_MpiDistributor & operator=(const Epetra_MpiDistributor &src)
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 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.
int CreateFromSends(const int &NumExportIDs, const int *ExportPIDs, bool Deterministic, int &NumRemoteIDs)
Create a communication plan from send list.
int CreateRecvStructures_(const int &NumRemoteIDs, const int *RemotePIDs)
int TotalReceiveLength() const
Total number of values that this proc is receiving from other procs.
const int * LengthsFrom() const
Number of values we're receiving from each proc.
void GetLastDoStatistics(int &bytes_sent, int &bytes_recvd) const
Information on the last call to Do/DoReverse.
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.
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.
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)
int NumReceives() const
The number of procs from which we will receive data.
int DoWaits()
Wait on a set of posts.
Epetra_Object: The base Epetra class.
Definition: Epetra_Object.h:57