24 int main(
int argc,
char *argv[]) {
25 #ifdef HAVE_ZOLTAN2_MPI
26 MPI_Init(&argc, &argv);
28 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
29 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
36 typedef Tpetra::Map<> Map_t;
37 typedef Map_t::local_ordinal_type localId_t;
38 typedef Map_t::global_ordinal_type globalId_t;
39 typedef Tpetra::Details::DefaultTypes::scalar_type scalar_t;
44 int localCount = 40*(rank+1);
45 int totalCount = 20*nprocs*(nprocs+1);
46 int targetCount = totalCount / nprocs;
47 globalId_t *globalIds =
new globalId_t[localCount];
50 for (
int i=0, num=40; i < nprocs ; i++, num+=40) {
51 std::cout <<
"Rank " << i <<
" generates " << num <<
" ids." << std::endl;
55 globalId_t offset = 0;
56 for (
int i=1; i <= rank; i++) {
60 for (
int i=0; i < localCount; i++) {
61 globalIds[i] = offset++;
73 std::vector<const scalar_t *> noWeights;
74 std::vector<int> noStrides;
76 inputAdapter_t ia(localCount, globalIds, noWeights, noStrides);
81 Teuchos::ParameterList params(
"test params");
82 params.set(
"debug_level",
"basic_status");
83 params.set(
"debug_procs",
"0");
84 params.set(
"error_check_level",
"debug_mode_assertions");
86 params.set(
"algorithm",
"block");
87 params.set(
"imbalance_tolerance", 1.1);
88 params.set(
"num_global_parts", nprocs);
105 const globalId_t *ids = NULL;
107 std::vector<int> partCounts(nprocs, 0), globalPartCounts(nprocs, 0);
109 for (
size_t i = 0; i < ia.getLocalNumIDs(); i++) {
110 int pp = problem->
getSolution().getPartListView()[i];
111 std::cout << rank <<
" LID " << i <<
" GID " << ids[i]
112 <<
" PART " << pp << std::endl;
116 #ifdef HAVE_ZOLTAN2_MPI
117 MPI_Allreduce(&(partCounts[0]), &(globalPartCounts[0]), nprocs,
118 MPI_INT, MPI_SUM, MPI_COMM_WORLD);
120 for (
int i = 0; i < nprocs; i++) globalPartCounts[i] = partCounts[i];
125 for (
int i = 0; i < nprocs; i++) {
126 if (globalPartCounts[i] != targetCount) {
127 std::cout <<
"FAIL: part " << i <<
" has " << globalPartCounts[i]
128 <<
" != " << targetCount <<
"; " << ++ierr <<
" errors"
133 std::cout <<
"PASS" << std::endl;
139 #ifdef HAVE_ZOLTAN2_MPI
A simple class that can be the User template argument for an InputAdapter.
int main(int narg, char **arg)
Defines the PartitioningSolution class.
This class represents a collection of global Identifiers and their associated weights, if any.
Defines the BasicIdentifierAdapter class.
const PartitioningSolution< Adapter > & getSolution()
Get the solution to the problem.
PartitioningProblem sets up partitioning problems for the user.
Defines the PartitioningProblem class.
void solve(bool updateInputData=true)
Direct the problem to create a solution.