50 #ifndef _ZOLTAN2_MAPPINGPROBLEM_HPP_ 51 #define _ZOLTAN2_MAPPINGPROBLEM_HPP_ 80 template<
typename Adapter,
82 MachineRepresentation<
typename Adapter::scalar_t,
83 typename Adapter::part_t> >
89 typedef typename Adapter::gno_t
gno_t;
90 typedef typename Adapter::lno_t
lno_t;
91 typedef typename Adapter::user_t
user_t;
92 typedef typename Adapter::part_t
part_t;
105 const Teuchos::RCP<
const Teuchos::Comm<int> > &ucomm_,
106 partsoln_t *partition_ = NULL, MachineRep *machine_ = NULL) :
107 Problem<Adapter>(A_, p_, ucomm_)
110 createMappingProblem(partition_, machine_);
113 #ifdef HAVE_ZOLTAN2_MPI 118 partsoln_t *partition_ = NULL, MachineRep *machine_ = NULL) :
119 Problem<Adapter>(A_, p_, ucomm_)
122 createMappingProblem(partition_, machine_);
142 void solve(
bool updateInputData=
true);
148 RCP<Teuchos::StringValidator> mapping_algorithm_Validator =
149 Teuchos::rcp(
new Teuchos::StringValidator(
150 Teuchos::tuple<std::string>(
"geometric",
"default",
"block" )));
151 pl.set(
"mapping_algorithm",
"default",
"mapping algorithm",
152 mapping_algorithm_Validator);
162 void createMappingProblem(
partsoln_t *partition_, MachineRep *machine_);
164 Teuchos::RCP<mapsoln_t> soln;
166 Teuchos::RCP<partsoln_t> partition;
167 Teuchos::RCP<MachineRep> machine;
176 template <
typename Adapter,
typename MachineRep>
177 void MappingProblem<Adapter, MachineRep>::createMappingProblem(
178 partsoln_t *partition_,
179 MachineRep *machine_)
187 partition = Teuchos::rcp(partition_,
false);
193 partition = rcp(
new partsoln_t(this->env_, this->comm_,
194 this->inputAdapter_->getNumWeightsPerID()));
195 size_t nLocal = this->inputAdapter_->getLocalNumIDs();
197 const part_t *inputPartsView = NULL;
198 this->inputAdapter_->getPartsView(inputPartsView);
199 if (nLocal && inputPartsView == NULL) {
201 int me = this->comm_->getRank();
202 ArrayRCP<part_t> inputParts = arcp(
new part_t[nLocal], 0, nLocal,
true);
203 for (
size_t i = 0; i < nLocal; i++) inputParts[i] = me;
204 partition->setParts(inputParts);
208 ArrayRCP<part_t> inputParts = arcp(const_cast<part_t *>(inputPartsView),
210 partition->setParts(inputParts);
216 machine = Teuchos::rcp(machine_,
false);
219 machine = Teuchos::rcp(
new MachineRep(*(this->comm_)));
226 template <
typename Adapter,
typename MachineRep>
233 std::string algName(
"block");
235 Teuchos::ParameterList pl = this->env_->getParametersNonConst();
236 const Teuchos::ParameterEntry *pe = pl.getEntryPtr(
"mapping_algorithm");
237 if (pe) algName = pe->getValue<std::string>(&algName);
240 if (algName ==
"default") {
242 #ifdef KDDKDD_NOT_READH 244 this->comm_, machine,
246 partition, this->envConst_));
247 this->soln = rcp(
new mapsoln_t(this->comm_, this->algorithm_));
248 this->algorithm_->map(this->soln);
251 else if (algName ==
"block") {
253 this->comm_, machine,
255 partition, this->envConst_));
256 this->soln = rcp(
new mapsoln_t(this->comm_, this->algorithm_));
257 this->algorithm_->map(this->soln);
259 #ifdef KDDNOTREADY_NEEDTOMAKE_CTM_ANALGORITHM 260 else if (algName ==
"geometric") {
267 this->soln = rcp(
new mapsoln_t(this->comm_, this->algorithm_));
268 this->algorithm_->map(this->soln);
273 throw std::logic_error(
"specified mapping_algorithm not supported");
288 MachineRepresentation=NULL
305 MachineRepresentation=NULL
319 MachineRepresentation=NULL
334 MachineRepresentation=NULL
348 In general, the applyPartitioningSolution method should take an
349 optional MappingSolution.
351 Should MappingSolution provide a re-numbered communicator reflecting the
new mapping?
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
PartitionMapping maps a solution or an input distribution to ranks.
Adapter::base_adapter_t base_adapter_t
void solve(bool updateInputData=true)
Direct the problem to create a solution.
Defines the PartitioningSolution class.
Define a simple mapping of parts to processors assuming parts.
mapsoln_t * getSolution()
Get the solution to the problem.
MappingProblem(Adapter *A_, Teuchos::ParameterList *p_, const Teuchos::RCP< const Teuchos::Comm< int > > &ucomm_, partsoln_t *partition_=NULL, MachineRep *machine_=NULL)
Constructor that takes an Teuchos communicator.
A PartitioningSolution is a solution to a partitioning problem.
Exception thrown when a called base-class method is not implemented.
static void getValidParameters(ParameterList &pl)
Set up validators specific to this Problem.
Problem base class from which other classes (PartitioningProblem, ColoringProblem, OrderingProblem, MatchingProblem, etc.) derive.
Defines the Problem base class.
Adapter::scalar_t scalar_t
MappingSolution< Adapter > mapsoln_t
Defines the MappingSolution class.
Gathering definitions used in software development.
PartitioningSolution< Adapter > partsoln_t
MappingProblem enables mapping of a partition (either computed or input) to MPI ranks.
virtual ~MappingProblem()
Destructor.
#define __func__zoltan2__