Domi
Multi-dimensional, distributed data structures
Loading...
Searching...
No Matches
Domi_MDComm.hpp
1// @HEADER
2// ***********************************************************************
3//
4// Domi: Multi-dimensional Distributed Linear Algebra Services
5// Copyright (2014) Sandia Corporation
6//
7// Under the terms of Contract DE-AC04-94AL85000 with Sandia
8// Corporation, the U.S. Government retains certain rights in this
9// 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 William F. Spotz (wfspotz@sandia.gov)
39//
40// ***********************************************************************
41// @HEADER
42
43#ifndef DOMI_MDCOMM_HPP
44#define DOMI_MDCOMM_HPP
45
46// Teuchos includes
47#include "Teuchos_Comm.hpp"
48#include "Teuchos_Array.hpp"
49#include "Teuchos_ArrayView.hpp"
50#include "Teuchos_ParameterList.hpp"
51
52// Domi includes
53#include "Domi_ConfigDefs.hpp"
54#include "Domi_Slice.hpp"
55
56#ifdef HAVE_EPETRA
57#ifdef HAVE_MPI
58#include "Epetra_MpiComm.h"
59#else
60#include "Epetra_SerialComm.h"
61#endif
62#endif
63
64namespace Domi
65{
66
109{
110public:
111
114
115 typedef Teuchos::Array< int >::size_type size_type;
116
118
121
122 static const Layout commLayout;
123
125
128
145 MDComm(const Teuchos::ArrayView< const int > & commDims,
146 const Teuchos::ArrayView< const int > & periodic =
147 Teuchos::ArrayView< const int >());
148
165 MDComm(const Teuchos::RCP< const Teuchos::Comm< int > > teuchosComm,
166 const Teuchos::ArrayView< const int > & commDims,
167 const Teuchos::ArrayView< const int > & periodic =
168 Teuchos::ArrayView< const int >());
169
181 MDComm(Teuchos::ParameterList & plist);
182
194 MDComm(const Teuchos::RCP< const Teuchos::Comm< int > > teuchosComm,
195 Teuchos::ParameterList & plist);
196
207
217 MDComm(const Teuchos::RCP< const Teuchos::Comm< int > > teuchosComm,
218 int numDims);
219
242 const Teuchos::ArrayView< const int > & commDims,
243 const Teuchos::ArrayView< const int > & periodic =
244 Teuchos::ArrayView< const int >());
245
267 MDComm(const Teuchos::RCP< const Teuchos::Comm< int > > teuchosComm,
268 int numDims,
269 const Teuchos::ArrayView< const int > & commDims,
270 const Teuchos::ArrayView< const int > & periodic =
271 Teuchos::ArrayView< const int >());
272
287 int axis,
288 int axisRank);
289
301 int axis,
302 const Slice & slice);
303
313 const Teuchos::ArrayView< Slice > & slices);
314
320
324
330
332
335
342 bool onSubcommunicator() const;
343
350 Teuchos::RCP< const Teuchos::Comm< int > > getTeuchosComm() const;
351
352#ifdef HAVE_EPETRA
359 Teuchos::RCP< const Epetra_Comm > getEpetraComm() const;
360#endif
361
368 int numDims() const;
369
376 Teuchos::Array< int > getCommDims() const;
377
387 int getCommDim(int axis) const;
388
398 bool isPeriodic(int axis) const;
399
409 int getCommIndex(int axis) const;
410
427 int getLowerNeighbor(int axis) const;
428
446 int getUpperNeighbor(int axis) const;
447
449
452
460 Teuchos::ArrayView< Teuchos::RCP< const MDComm > > getAxisComms() const;
461
471 Teuchos::RCP< const MDComm > getAxisComm(int axis) const;
472
474
475protected:
476
477 // Not implemented
478 MDComm();
479
480private:
481
482 // The Teuchos communicator
483 Teuchos::RCP< const Teuchos::Comm< int > > _teuchosComm;
484
485#ifdef HAVE_EPETRA
486 // An equivalent Epetra communicator. This is mutable because we
487 // only compute it if requested by a get method that is const.
488 mutable Teuchos::RCP< const Epetra_Comm > _epetraComm;
489#endif
490
491 // An array of the sizes of the communicator along each axis
492 Teuchos::Array< int > _commDims;
493
494 // An array of the strides between processor ranks along each axis.
495 Teuchos::Array< int > _commStrides;
496
497 // The comm index for this processor along each axis
498 Teuchos::Array< int > _commIndex;
499
500 // An array of flags denoting periodic axes
501 Teuchos::Array< int > _periodic;
502
503 // An array of 1D axis communicators, that represent the comm along
504 // each axis of this MDComm. These comms are technically
505 // sub-communicators, but each one is guaranteed to exist on the
506 // processor that constructs it. This array is mutable so that its
507 // construction can be delayed until it is requested.
508 mutable Teuchos::Array< Teuchos::RCP< const MDComm > > _axisComms;
509
510};
511
512} // namespace Domi
513
514#endif
A Slice defines a subset of a container.
Memory-safe templated multi-dimensional array class.
Definition Domi_MDArray.hpp:287
Multi-dimensional communicator object.
Definition Domi_MDComm.hpp:109
MDComm & operator=(const MDComm &source)
Assignment operator.
MDComm(const Teuchos::RCP< const Teuchos::Comm< int > > teuchosComm, Teuchos::ParameterList &plist)
Constructor with Teuchos Comm and ParameterList.
Teuchos::Array< int > getCommDims() const
Get the communicator sizes along each axis.
MDComm(const Teuchos::RCP< const Teuchos::Comm< int > > teuchosComm, int numDims, const Teuchos::ArrayView< const int > &commDims, const Teuchos::ArrayView< const int > &periodic=Teuchos::ArrayView< const int >())
Constructor with Teuchos Comm, number of dimensions and axis sizes.
int getLowerNeighbor(int axis) const
Get the rank of the lower neighbor.
Teuchos::ArrayView< Teuchos::RCP< const MDComm > > getAxisComms() const
Return array of all axis communicators.
MDComm(int numDims, const Teuchos::ArrayView< const int > &commDims, const Teuchos::ArrayView< const int > &periodic=Teuchos::ArrayView< const int >())
Constructor with number of dimensions and axis sizes.
int getUpperNeighbor(int axis) const
Get the rank of the upper neighbor.
MDComm(const Teuchos::RCP< const Teuchos::Comm< int > > teuchosComm, const Teuchos::ArrayView< const int > &commDims, const Teuchos::ArrayView< const int > &periodic=Teuchos::ArrayView< const int >())
Constructor with Teuchos Comm and axis sizes.
MDComm(const MDComm &source)
Copy constructor.
MDComm(Teuchos::ParameterList &plist)
Constructor with ParameterList.
Teuchos::RCP< const MDComm > getAxisComm(int axis) const
Return an axis communicator for the given axis.
int getCommIndex(int axis) const
Get the comm index along the given axis.
MDComm(int numDims)
Constructor with number of dimensions.
MDComm(const Teuchos::RCP< const Teuchos::Comm< int > > teuchosComm, int numDims)
Constructor with number of dimensions.
MDComm(const MDComm &parent, int axis, int axisRank)
Axis rank sub-communicator constructor.
bool onSubcommunicator() const
Query whether this processor is on the sub-communicator.
bool isPeriodic(int axis) const
Return the periodic flag for the given axis.
Teuchos::RCP< const Teuchos::Comm< int > > getTeuchosComm() const
Get the Teuchos communicator.
int numDims() const
Get the number of dimensions.
MDComm(const Teuchos::ArrayView< const int > &commDims, const Teuchos::ArrayView< const int > &periodic=Teuchos::ArrayView< const int >())
Constructor with default Teuchos comm and axis sizes.
MDComm(const MDComm &parent, int axis, const Slice &slice)
Slice sub-communicator constructor.
int getCommDim(int axis) const
Get the communicator size along the given axis.
MDComm(const MDComm &parent, const Teuchos::ArrayView< Slice > &slices)
Array of Slices sub-communicator constructor.
A Slice contains a start, stop, and step index, describing a subset of an ordered container.
Definition Domi_Slice.hpp:138

Generated for Domi by doxygen 1.10.0