Domi
Multi-dimensional, distributed data structures
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 
64 namespace Domi
65 {
66 
108 class MDComm
109 {
110 public:
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 
206  MDComm(int numDims);
207 
217  MDComm(const Teuchos::RCP< const Teuchos::Comm< int > > teuchosComm,
218  int numDims);
219 
241  MDComm(int numDims,
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 
286  MDComm(const MDComm & parent,
287  int axis,
288  int axisRank);
289 
300  MDComm(const MDComm & parent,
301  int axis,
302  const Slice & slice);
303 
312  MDComm(const MDComm & parent,
313  const Teuchos::ArrayView< Slice > & slices);
314 
319  MDComm(const MDComm & source);
320 
323  ~MDComm();
324 
329  MDComm & operator=(const MDComm & source);
330 
332 
335 
342  bool onSubcommunicator() const;
343 
350  Teuchos::RCP< const Teuchos::Comm< int > > getTeuchosComm() const;
351 
352 #ifdef HAVE_EPETRA
353 
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 
475 protected:
476 
477  // Not implemented
478  MDComm();
479 
480 private:
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
Domi::MDComm::getCommDim
int getCommDim(int axis) const
Get the communicator size along the given axis.
Domi::MDComm::getLowerNeighbor
int getLowerNeighbor(int axis) const
Get the rank of the lower neighbor.
Domi::MDComm::getUpperNeighbor
int getUpperNeighbor(int axis) const
Get the rank of the upper neighbor.
Domi::MDComm::getTeuchosComm
Teuchos::RCP< const Teuchos::Comm< int > > getTeuchosComm() const
Get the Teuchos communicator.
Domi::MDComm::getCommIndex
int getCommIndex(int axis) const
Get the comm index along the given axis.
Domi::Slice
A Slice contains a start, stop, and step index, describing a subset of an ordered container.
Definition: Domi_Slice.hpp:137
Domi::MDComm::operator=
MDComm & operator=(const MDComm &source)
Assignment operator.
Domi::MDComm::~MDComm
~MDComm()
Domi_Slice.hpp
A Slice defines a subset of a container.
Domi::MDComm::getAxisComms
Teuchos::ArrayView< Teuchos::RCP< const MDComm > > getAxisComms() const
Return array of all axis communicators.
Domi::MDComm
Multi-dimensional communicator object.
Definition: Domi_MDComm.hpp:108
Domi::MDComm::numDims
int numDims() const
Get the number of dimensions.
Domi::MDComm::onSubcommunicator
bool onSubcommunicator() const
Query whether this processor is on the sub-communicator.
Domi::MDComm::isPeriodic
bool isPeriodic(int axis) const
Return the periodic flag for the given axis.
Domi::MDComm::getCommDims
Teuchos::Array< int > getCommDims() const
Get the communicator sizes along each axis.
Domi::MDComm::getAxisComm
Teuchos::RCP< const MDComm > getAxisComm(int axis) const
Return an axis communicator for the given axis.

Generated for Domi by doxygen 1.8.16