Zoltan2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 #include "Zoltan2_Algorithm.hpp"
58 
59 namespace Zoltan2 {
60 
64 template <typename Adapter>
65  class PartitionMapping :public Algorithm<Adapter>
66 {
67 public:
68 
69 #ifndef DOXYGEN_SHOULD_SKIP_THIS
70  typedef typename Adapter::gno_t gno_t;
71  typedef typename Adapter::scalar_t scalar_t;
72  typedef typename Adapter::scalar_t pcoord_t;
73  typedef typename Adapter::lno_t lno_t;
74  typedef typename Adapter::part_t part_t;
75  typedef typename Adapter::user_t user_t;
76 #endif
77 
78  const Teuchos::RCP <const Teuchos::Comm<int> >comm;
79  const Teuchos::RCP <const Zoltan2::MachineRepresentation <pcoord_t,part_t> > machine;
80  const Teuchos::RCP <const Adapter > input_adapter;
81  const Teuchos::RCP <const Zoltan2::PartitioningSolution<Adapter> >soln;
82  const Teuchos::RCP <const Environment >env;
85 
86 
94  const Teuchos::RCP <const Teuchos::Comm<int> >comm_,
95  const Teuchos::RCP <const Zoltan2::MachineRepresentation<pcoord_t,part_t> >machine_, // If NULL, assume homogeneous
96  // Make optional
97  const Teuchos::RCP <const Adapter> input_adapter_, // Needed to get information about
98  // the application data (coords, graph)
99  const Teuchos::RCP <const Zoltan2::PartitioningSolution<Adapter> >soln_, // Needed for mapping a partition
100  const Teuchos::RCP <const Environment > envConst_ // Perhaps envConst should be optional
101  // so applications can create a mapping
102  // directly
103  ):comm(comm_),
104  machine(machine_),
105  input_adapter(input_adapter_),
106  soln(soln_),
107  env(envConst_),num_parts(soln_->getActualGlobalNumberOfParts()),
109  {} ;
110 
112  const Teuchos::RCP <const Teuchos::Comm<int> >comm_,
113  const Teuchos::RCP <const Zoltan2::MachineRepresentation<pcoord_t,part_t> >machine_, // If NULL, assume homogeneous
114  // Make optional
115  const Teuchos::RCP <const Adapter> input_adapter_, // Needed to get information about
116  // the application data (coords, graph)
117  const part_t num_parts_,
118  const part_t *result_parts,
119  const Teuchos::RCP <const Environment > envConst_ // Perhaps envConst should be optional
120  // so applications can create a mapping
121  // directly
122  ):comm(comm_),
123  machine(machine_),
124  input_adapter(input_adapter_),
125  soln(),
126  env(envConst_),num_parts(num_parts_),
127  solution_parts(result_parts)
128  {} ;
129 
131  const Teuchos::RCP <const Teuchos::Comm<int> >comm_,
132  const Teuchos::RCP <const Environment > envConst_ // Perhaps envConst should be optional
133  // so applications can create a mapping
134  // directly
135  ):comm(comm_),
136  machine(),
137  input_adapter(),
138  soln(),
139  env(envConst_),num_parts(0),
140  solution_parts(NULL)
141  {} ;
142 
144  comm(0),
145  machine(0),
146  input_adapter(0),
147  soln(0),
148  env(0),
149  solution_parts(NULL){};
150 
151  PartitionMapping(const Teuchos::RCP <const Environment >envConst_):
152  comm(0),
153  machine(0),
154  input_adapter(0),
155  soln(0),
156  env(envConst_),num_parts(0),
157  solution_parts(NULL){};
158 
160  const Teuchos::RCP <const Environment > envConst_,
161  const Teuchos::RCP <const Teuchos::Comm<int> >comm_,
162  const Teuchos::RCP <const MachineRepresentation<pcoord_t,part_t> >machine_
163  ):
164  comm(comm_),
165  machine(machine_),
166  input_adapter(0),
167  soln(0),
168  env(envConst_),num_parts(0),
169  solution_parts(NULL){};
170 
171 
172  virtual ~PartitionMapping(){}
173 
176  virtual size_t getLocalNumberOfParts() const = 0;
177 
185  // TODO: KDDKDD Decide whether information should be avail for any process
186  // TODO: KDDKDD (requiring more storage or a directory) or only for the
187  // TODO: KDDKDD local process.
188  // TODO: KDDKDD Could require O(nprocs) storage
189  virtual void getPartsForProc(int procId, part_t &numParts, part_t *&parts)
190  const = 0;
191 
198  // TODO: KDDKDD Arguments should be count and array, not min and max.
199  // TODO: KDDKDD Could require O(nGlobalParts) storage
200  virtual void getProcsForPart(part_t partId, part_t &numProcs, part_t *&procs) const = 0;
201 
202 private:
203 };
204 
205 } // namespace Zoltan2
206 
207 #endif
const zpart_t * getPartListView(RCP< ProblemFactory > problemFactory)
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_)
map_t::global_ordinal_type gno_t
Definition: mapRemotes.cpp:18
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
SparseMatrixAdapter_t::part_t part_t
Adapter::scalar_t scalar_t
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_)
Adapter::part_t part_t
Algorithm defines the base class for all algorithms.
map_t::local_ordinal_type lno_t
Definition: mapRemotes.cpp:17
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.
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > user_t
Definition: Metric.cpp:74