60 using Teuchos::ArrayRCP;
70 ArrayRCP<ArrayRCP<partId_t> > &
idList, ArrayRCP<ArrayRCP<scalar_t> > &sizeList)
72 ArrayRCP<partId_t> *idArrays =
new ArrayRCP<partId_t> [wdim];
73 ArrayRCP<scalar_t> *sizeArrays =
new ArrayRCP<scalar_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 argc,
char *argv[])
86 Teuchos::GlobalMPISession session(&argc, &argv);
87 RCP<const Comm<int> > comm = Teuchos::DefaultComm<int>::getComm();
88 int nprocs = comm->getSize();
89 int rank = comm->getRank();
91 double epsilon = 10e-6;
96 int numIdsPerProc = 10;
98 int maxNumPartSizes = nprocs;
99 int *lengths =
new int [maxWeightDim];
103 for (
int w=0; w < maxWeightDim; w++){
104 idLists[w] =
new partId_t [maxNumPartSizes];
105 sizeLists[w] =
new scalar_t [maxNumPartSizes];
116 for (
int i=0, x=rank*numIdsPerProc; i < numIdsPerProc; i++){
120 ArrayRCP<const gno_t> gidArray(myGids, 0, numIdsPerProc,
true);
122 RCP<const Zoltan2::IdentifierMap<user_t> > idMap =
130 int numGlobalParts = nprocs;
133 ArrayRCP<ArrayRCP<partId_t> > ids;
134 ArrayRCP<ArrayRCP<scalar_t> > sizes;
136 memset(lengths, 0,
sizeof(
int) * maxWeightDim);
139 idLists[0][0] = rank;
140 sizeLists[0][0] = rank%2 + 1.0;
142 makeArrays(1, lengths, idLists, sizeLists, ids, sizes);
148 for (
int i=0; i < numGlobalParts; i++){
149 normalizedPartSizes[i] = 1.0;
150 if (i % 2) normalizedPartSizes[i] = 2.0;
151 sumSizes += normalizedPartSizes[i];
153 for (
int i=0; i < numGlobalParts; i++)
154 normalizedPartSizes[i] /= sumSizes;
159 RCP<Zoltan2::PartitioningSolution<idInput_t> > solution;
167 ids.view(0,weightDim),
168 sizes.view(0,weightDim)));
170 catch (std::exception &e){
178 if (solution->getTargetGlobalNumberOfParts() != size_t(numGlobalParts))
181 if (!fail && solution->getLocalNumberOfParts() != 1)
184 if (!fail && !solution->oneToOnePartDistribution())
187 if (!fail && solution->getPartDistribution() != NULL)
190 if (!fail && solution->getProcDistribution() != NULL)
194 ((nprocs>1 && solution->criteriaHasUniformPartSizes(0)) ||
195 (nprocs==1 && !solution->criteriaHasUniformPartSizes(0))) )
199 for (
int partId=0; !fail && partId < numGlobalParts; partId++){
200 scalar_t psize = solution->getCriteriaPartSize(0, partId);
202 if ( psize < normalizedPartSizes[partId] - epsilon ||
203 psize > normalizedPartSizes[partId] + epsilon )
208 delete [] normalizedPartSizes;
218 for (
int i=0; i < numIdsPerProc; i++){
219 partAssignments[i] = myGids[i] % numGlobalParts;
221 ArrayRCP<partId_t> partList = arcp(partAssignments, 0, numIdsPerProc);
224 solution->setParts(gidArray, partList,
true);
226 catch (std::exception &e){
238 if (solution->getLocalNumberOfIds() != size_t(numIdsPerProc))
242 const gno_t *gids = solution->getIdList();
243 for (
int i=0; !fail && i < numIdsPerProc; i++){
244 if (gids[i] != myGids[i])
250 const partId_t *parts = solution->getPartList();
251 for (
int i=0; !fail && i < numIdsPerProc; i++){
252 if (parts[i] != myGids[i] % numGlobalParts)
263 std::cout <<
"PASS" << std::endl;
277 for (
int w=0; w < maxWeightDim; w++){
278 delete [] idLists[w];
279 delete [] sizeLists[w];
An IdentifierMap manages a global space of object identifiers.
int globalFail(const RCP< const Comm< int > > &comm, int fail)
A simple class that can be the User template argument for an InputAdapter.
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
Defines the PartitioningSolution class.
Zoltan2::BasicUserTypes< scalar_t, gno_t, lno_t, gno_t > user_t
void makeArrays(int wdim, int *lens, partId_t **ids, scalar_t **sizes, ArrayRCP< ArrayRCP< partId_t > > &idList, ArrayRCP< ArrayRCP< scalar_t > > &sizeList)
common code used by tests
zoltan2_partId_t partId_t
int main(int argc, char *argv[])
list idList
Match up parameters to validators.
Zoltan2::BasicIdentifierInput< user_t > idInput_t
int zoltan2_partId_t
a data type for part IDs
A PartitioningSolution is a solution to a partitioning problem.
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
void printFailureCode(const RCP< const Comm< int > > &comm, int fail)