Zoltan2
Zoltan2_PartitionMapping.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Zoltan2: A package of combinatorial algorithms for scientific computing
6 // Copyright 2012 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 Karen Devine (kddevin@sandia.gov)
39 // Erik Boman (egboman@sandia.gov)
40 // Siva Rajamanickam (srajama@sandia.gov)
41 //
42 // ***********************************************************************
43 //
44 // @HEADER
45 
50 #ifndef _ZOLTAN2_PARTITIONMAPPING_HPP_
51 #define _ZOLTAN2_PARTITIONMAPPING_HPP_
52 #include "Zoltan2_Model.hpp"
54 #include "Teuchos_Comm.hpp"
55 #include "Zoltan2_Environment.hpp"
57 
58 namespace Zoltan2 {
59 
63 template <typename Adapter>
65 {
66 public:
67 
68 #ifndef DOXYGEN_SHOULD_SKIP_THIS
69  typedef typename Adapter::gno_t gno_t;
70  typedef typename Adapter::scalar_t scalar_t;
71  typedef typename Adapter::scalar_t pcoord_t;
72  typedef typename Adapter::lno_t lno_t;
73  typedef typename Adapter::part_t part_t;
74  typedef typename Adapter::user_t user_t;
75 #endif
76 
77  const Teuchos::RCP <const Teuchos::Comm<int> >comm;
78  const Teuchos::RCP <const Zoltan2::MachineRepresentation <pcoord_t,part_t> > machine;
79  const Teuchos::RCP <const Adapter > input_adapter;
80  const Teuchos::RCP <const Zoltan2::PartitioningSolution<Adapter> >soln;
81  const Teuchos::RCP <const Environment >env;
82  const part_t num_parts;
83  const part_t *solution_parts;
84 
85 
93  const Teuchos::RCP <const Teuchos::Comm<int> >comm_,
94  const Teuchos::RCP <const Zoltan2::MachineRepresentation<pcoord_t,part_t> >machine_, // If NULL, assume homogeneous
95  // Make optional
96  const Teuchos::RCP <const Adapter> input_adapter_, // Needed to get information about
97  // the application data (coords, graph)
98  const Teuchos::RCP <const Zoltan2::PartitioningSolution<Adapter> >soln_, // Needed for mapping a partition
99  const Teuchos::RCP <const Environment > envConst_ // Perhaps envConst should be optional
100  // so applications can create a mapping
101  // directly
102  ):comm(comm_),
103  machine(machine_),
104  input_adapter(input_adapter_),
105  soln(soln_),
106  env(envConst_),num_parts(soln_->getActualGlobalNumberOfParts()),
107  solution_parts(soln_->getPartListView())
108  {} ;
109 
111  const Teuchos::RCP <const Teuchos::Comm<int> >comm_,
112  const Teuchos::RCP <const Zoltan2::MachineRepresentation<pcoord_t,part_t> >machine_, // If NULL, assume homogeneous
113  // Make optional
114  const Teuchos::RCP <const Adapter> input_adapter_, // Needed to get information about
115  // the application data (coords, graph)
116  const part_t num_parts_,
117  const part_t *result_parts,
118  const Teuchos::RCP <const Environment > envConst_ // Perhaps envConst should be optional
119  // so applications can create a mapping
120  // directly
121  ):comm(comm_),
122  machine(machine_),
123  input_adapter(input_adapter_),
124  soln(),
125  env(envConst_),num_parts(num_parts_),
126  solution_parts(result_parts)
127  {} ;
128 
130  const Teuchos::RCP <const Teuchos::Comm<int> >comm_,
131  const Teuchos::RCP <const Environment > envConst_ // Perhaps envConst should be optional
132  // so applications can create a mapping
133  // directly
134  ):comm(comm_),
135  machine(),
136  input_adapter(),
137  soln(),
138  env(envConst_),num_parts(0),
139  solution_parts(NULL)
140  {} ;
141 
143  comm(0),
144  machine(0),
145  input_adapter(0),
146  soln(0),
147  env(0),
148  solution_parts(NULL){};
149 
150  PartitionMapping(const Teuchos::RCP <const Environment >envConst_):
151  comm(0),
152  machine(0),
153  input_adapter(0),
154  soln(0),
155  env(envConst_),num_parts(0),
156  solution_parts(NULL){};
157 
159  const Teuchos::RCP <const Environment > envConst_,
160  const Teuchos::RCP <const Teuchos::Comm<int> >comm_,
161  const Teuchos::RCP <const MachineRepresentation<pcoord_t,part_t> >machine_
162  ):
163  comm(comm_),
164  machine(machine_),
165  input_adapter(0),
166  soln(0),
167  env(envConst_),num_parts(0),
168  solution_parts(NULL){};
169 
170 
171  virtual ~PartitionMapping(){}
172 
175  virtual size_t getLocalNumberOfParts() const = 0;
176 
184  // TODO: KDDKDD Decide whether information should be avail for any process
185  // TODO: KDDKDD (requiring more storage or a directory) or only for the
186  // TODO: KDDKDD local process.
187  // TODO: KDDKDD Could require O(nprocs) storage
188  virtual void getPartsForProc(int procId, part_t &numParts, part_t *&parts)
189  const = 0;
190 
197  // TODO: KDDKDD Arguments should be count and array, not min and max.
198  // TODO: KDDKDD Could require O(nGlobalParts) storage
199  virtual void getProcsForPart(part_t partId, part_t &numProcs, part_t *&procs) const = 0;
200 
201 private:
202 };
203 
204 } // namespace Zoltan2
205 
206 #endif
Defines the Model interface.
PartitionMapping(const Teuchos::RCP< const Teuchos::Comm< int > >comm_, const Teuchos::RCP< const Zoltan2::MachineRepresentation< pcoord_t, part_t > >machine_, const Teuchos::RCP< const Adapter > input_adapter_, const part_t num_parts_, const part_t *result_parts, const Teuchos::RCP< const Environment > envConst_)
PartitionMapping(const Teuchos::RCP< const Environment > envConst_, const Teuchos::RCP< const Teuchos::Comm< int > >comm_, const Teuchos::RCP< const MachineRepresentation< pcoord_t, part_t > >machine_)
Defines the PartitioningSolution class.
PartitionMapping(const Teuchos::RCP< const Teuchos::Comm< int > >comm_, const Teuchos::RCP< const Zoltan2::MachineRepresentation< pcoord_t, part_t > >machine_, const Teuchos::RCP< const Adapter > input_adapter_, const Teuchos::RCP< const Zoltan2::PartitioningSolution< Adapter > >soln_, const Teuchos::RCP< const Environment > envConst_)
Constructor Constructor builds the map from parts to ranks. KDDKDD WILL NEED THE SOLUTION FOR INTELLI...
const Teuchos::RCP< const Zoltan2::PartitioningSolution< Adapter > > soln
PartitionMapping maps a solution or an input distribution to ranks.
A PartitioningSolution is a solution to a partitioning problem.
PartitionMapping(const Teuchos::RCP< const Teuchos::Comm< int > >comm_, const Teuchos::RCP< const Environment > envConst_)
MachineRepresentation Class Base class for representing machine coordinates, networks, etc.
virtual void getPartsForProc(int procId, part_t &numParts, part_t *&parts) const =0
Get the parts belonging to a process.
const Teuchos::RCP< const Adapter > input_adapter
const Teuchos::RCP< const Zoltan2::MachineRepresentation< pcoord_t, part_t > > machine
const Teuchos::RCP< const Teuchos::Comm< int > > comm
Defines the Environment class.
PartitionMapping(const Teuchos::RCP< const Environment >envConst_)
virtual size_t getLocalNumberOfParts() const =0
Returns the number of parts to be assigned to this process.
const Teuchos::RCP< const Environment > env
virtual void getProcsForPart(part_t partId, part_t &numProcs, part_t *&procs) const =0
Get the processes containing a part.