61 using Teuchos::ArrayRCP;
70 ArrayRCP<ArrayRCP<zzpart_t> > &
idList, ArrayRCP<ArrayRCP<zscalar_t> > &sizeList)
72 ArrayRCP<zzpart_t> *idArrays =
new ArrayRCP<zzpart_t> [wdim];
73 ArrayRCP<zscalar_t> *sizeArrays =
new ArrayRCP<zscalar_t> [wdim];
75 for (
int w=0; w < wdim; w++){
76 idArrays[w] = arcp(ids[w], 0, lens[w],
false);
77 sizeArrays[w] = arcp(sizes[w], 0, lens[w],
false);
80 idList = arcp(idArrays, 0, wdim,
true);
81 sizeList = arcp(sizeArrays, 0, wdim,
true);
84 int main(
int narg,
char *arg[])
86 Tpetra::ScopeGuard tscope(&narg, &arg);
87 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
89 int nprocs = comm->getSize();
90 int rank = comm->getRank();
97 int numIdsPerProc = 10;
98 int maxNumWeights = 3;
99 int maxNumPartSizes = nprocs;
100 int *lengths =
new int [maxNumWeights];
104 for (
int w=0; w < maxNumWeights; w++){
105 idLists[w] =
new zzpart_t [maxNumPartSizes];
106 sizeLists[w] =
new zscalar_t [maxNumPartSizes];
117 for (
int i=0, x=rank*numIdsPerProc; i < numIdsPerProc; i++)
125 int numGlobalParts = nprocs;
128 ArrayRCP<ArrayRCP<zzpart_t> > ids;
129 ArrayRCP<ArrayRCP<zscalar_t> > sizes;
131 memset(lengths, 0,
sizeof(
int) * maxNumWeights);
134 idLists[0][0] = rank;
135 sizeLists[0][0] = rank%2 + 1.0;
137 makeArrays(1, lengths, idLists, sizeLists, ids, sizes);
143 for (
int i=0; i < numGlobalParts; i++){
144 normalizedPartSizes[i] = 1.0;
145 if (i % 2) normalizedPartSizes[i] = 2.0;
146 sumSizes += normalizedPartSizes[i];
148 for (
int i=0; i < numGlobalParts; i++)
149 normalizedPartSizes[i] /= sumSizes;
154 RCP<Zoltan2::PartitioningSolution<idInput_t> > solution;
161 ids.view(0,nWeights),
162 sizes.view(0,nWeights)));
164 catch (std::exception &e){
172 if (solution->getTargetGlobalNumberOfParts() != size_t(numGlobalParts))
175 if (!fail && solution->getLocalNumberOfParts() != 1)
178 if (!fail && !solution->oneToOnePartDistribution())
181 if (!fail && solution->getPartDistribution() != NULL)
184 if (!fail && solution->getProcDistribution() != NULL)
188 ((nprocs>1 && solution->criteriaHasUniformPartSizes(0)) ||
189 (nprocs==1 && !solution->criteriaHasUniformPartSizes(0))) )
193 for (
int partId=0; !fail && partId < numGlobalParts; partId++){
194 zscalar_t psize = solution->getCriteriaPartSize(0, partId);
196 if ( psize < normalizedPartSizes[partId] - epsilon ||
197 psize > normalizedPartSizes[partId] + epsilon )
202 delete [] normalizedPartSizes;
212 for (
int i=0; i < numIdsPerProc; i++){
213 partAssignments[i] = myGids[i] % numGlobalParts;
215 ArrayRCP<zzpart_t> partList = arcp(partAssignments, 0, numIdsPerProc);
218 solution->setParts(partList);
220 catch (std::exception &e){
233 const zzpart_t *parts = solution->getPartListView();
234 for (
int i=0; !fail && i < numIdsPerProc; i++){
235 if (parts[i] !=
zzpart_t(myGids[i] % numGlobalParts))
246 std::cout <<
"PASS" << std::endl;
260 for (
int w=0; w < maxNumWeights; w++){
261 delete [] idLists[w];
262 delete [] sizeLists[w];
void printFailureCode(const Comm< int > &comm, int fail)
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > zzuser_t
int main(int narg, char *arg[])
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
Defines the PartitioningSolution class.
idInput_t::part_t zzpart_t
common code used by tests
This class represents a collection of global Identifiers and their associated weights, if any.
list idList
Match up parameters to validators.
void makeArrays(int wdim, int *lens, zzpart_t **ids, zscalar_t **sizes, ArrayRCP< ArrayRCP< zzpart_t > > &idList, ArrayRCP< ArrayRCP< zscalar_t > > &sizeList)
A PartitioningSolution is a solution to a partitioning problem.
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
static const std::string fail
InputTraits< User >::part_t part_t
Defines the BasicIdentifierAdapter class.
int globalFail(const Comm< int > &comm, int fail)
Zoltan2::BasicIdentifierAdapter< zzuser_t > idInput_t