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::lno_t lno_t;
72  typedef typename Adapter::part_t part_t;
73  typedef typename Adapter::user_t user_t;
74 #endif
75 
76  const Teuchos::Comm<int> *comm;
80  const Environment *env;
81 
89  const Teuchos::Comm<int> *comm_,
90  const Zoltan2::MachineRepresentation<scalar_t> *machine_, // If NULL, assume homogeneous
91  // Make optional
92  const Zoltan2::Model<typename Adapter::base_adapter_t> *model_, // Needed to get information about
93  // the application data (coords, graph)
94  const Zoltan2::PartitioningSolution<Adapter> *soln_, // Needed for mapping a partition
95  const Environment *envConst_ // Perhaps envConst should be optional
96  // so applications can create a mapping
97  // directly
98  ):comm(comm_),
99  machine(machine_),
100  model(model_),
101  soln(soln_),
102  env(envConst_)
103  {} ;
104 
106  comm(0),
107  machine(0),
108  model(0),
109  soln(0),
110  env(0){};
111 
112  PartitionMapping(const Environment *envConst_):
113  comm(0),
114  machine(0),
115  model(0),
116  soln(0),
117  env(envConst_){};
118 
120  const Environment *envConst_,
121  const Teuchos::Comm<int> *comm_,
122  const MachineRepresentation<scalar_t> *machine_
123  ):
124  comm(comm_),
125  machine(machine_),
126  model(0),
127  soln(0),
128  env(envConst_){};
129 
130 
131  virtual ~PartitionMapping(){}
132 
135  virtual size_t getLocalNumberOfParts() const = 0;
136 
144  // TODO: KDDKDD Decide whether information should be avail for any process
145  // TODO: KDDKDD (requiring more storage or a directory) or only for the
146  // TODO: KDDKDD local process.
147  // TODO: KDDKDD Could require O(nprocs) storage
148  virtual void getPartsForProc(int procId, part_t &numParts, part_t *parts)
149  const = 0;
150 
157  // TODO: KDDKDD Arguments should be count and array, not min and max.
158  // TODO: KDDKDD Could require O(nGlobalParts) storage
159  virtual void getProcsForPart(part_t partId, part_t &numProcs, part_t *procs) const = 0;
160 
161 private:
162 };
163 
164 } // namespace Zoltan2
165 
166 #endif
const Teuchos::Comm< int > * comm
PartitionMapping(const Environment *envConst_, const Teuchos::Comm< int > *comm_, const MachineRepresentation< scalar_t > *machine_)
Defines the Model interface.
const Zoltan2::PartitioningSolution< Adapter > * soln
Defines the PartitioningSolution class.
PartitionMapping(const Environment *envConst_)
const Zoltan2::MachineRepresentation< scalar_t > * machine
virtual void getPartsForProc(int procId, part_t &numParts, part_t *parts) const =0
Get the parts belonging to a process.
PartitionMapping maps a solution or an input distribution to ranks.
A PartitioningSolution is a solution to a partitioning problem.
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
PartitionMapping(const Teuchos::Comm< int > *comm_, const Zoltan2::MachineRepresentation< scalar_t > *machine_, const Zoltan2::Model< typename Adapter::base_adapter_t > *model_, const Zoltan2::PartitioningSolution< Adapter > *soln_, const Environment *envConst_)
Constructor Constructor builds the map from parts to ranks. KDDKDD WILL NEED THE SOLUTION FOR INTELLI...
Defines the Environment class.
const Zoltan2::Model< typename Adapter::base_adapter_t > * model
virtual size_t getLocalNumberOfParts() const =0
Returns the number of parts to be assigned to this process.
virtual void getProcsForPart(part_t partId, part_t &numProcs, part_t *procs) const =0
Get the processes containing a part.