14 #include <Zoltan2_config.h>
26 #ifdef HAVE_ZOLTAN2_SARMA
29 std::string alg =
"pal";
30 sarma::Order order_type = sarma::Order::NAT;
31 std::string order_str =
"nat";
32 Ordinal row_parts = 8, col_parts = 0;
34 int seed = 2147483647;
35 double sparsify = 1.0;
36 bool triangular =
false, use_data =
false;
39 const static std::vector<std::pair<Parameters, std::vector<Ordinal> > > expected = {
40 {{.alg=
"opal"}, {0, 48, 94, 143, 175, 218, 257, 295, 332, 0, 48, 94, 143, 175, 218, 257, 295, 332}}
43 auto testFromFile(
const RCP<
const Teuchos::Comm<int> > &comm,
int nparts, std::string &filename,
bool doRemap,
44 const Parameters sarma) {
45 int me = comm->getRank();
48 RCP<tcrsMatrix_t> matrix = userInputForTests.getUITpetraCrsMatrix();
49 RCP<const tcrsMatrix_t> matrixConst = rcp_const_cast<
const tcrsMatrix_t>(matrix);
54 #ifdef HAVE_ZOLTAN2_MPI
55 double begin = MPI_Wtime();
58 Teuchos::ParameterList params(
"test params");
59 params.set(
"debug_level",
"basic_status");
60 params.set(
"num_global_parts", nparts);
61 params.set(
"algorithm",
"sarma");
62 if (doRemap) params.set(
"remap_parts",
true);
63 Teuchos::ParameterList &zparams = params.sublist(
"zoltan_parameters",
false);
64 zparams.set(
"DEBUG_LEVEL",
"0");
67 Teuchos::ParameterList &sparams = params.sublist(
"sarma_parameters",
false);
68 sparams.set(
"alg", sarma.alg);
69 sparams.set(
"order", sarma.order_str);
70 sparams.set(
"row_parts", sarma.row_parts);
71 sparams.set(
"col_parts", sarma.col_parts);
72 sparams.set(
"max_load", sarma.max_load);
73 sparams.set(
"sparsify", sarma.sparsify);
74 sparams.set(
"triangular", sarma.triangular);
75 sparams.set(
"use_data", sarma.use_data);
76 sparams.set(
"seed", sarma.seed);
78 #ifdef HAVE_ZOLTAN2_MPI
83 if (me == 0) std::cout <<
"Problem constructed" << std::endl;
87 #ifdef HAVE_ZOLTAN2_MPI
89 std::cout <<
"Run-time:\t" << MPI_Wtime() - begin << std::endl;
91 return problem.getSolution();
95 int main(
int argc,
char *argv[]) {
96 #ifdef HAVE_ZOLTAN2_SARMA
97 Tpetra::ScopeGuard tscope(&argc, &argv);
98 RCP<const Teuchos::Comm<int> > tcomm = Tpetra::getDefaultComm();
103 bool doRemap =
false;
104 std::string filename =
"USAir97";
108 for (
auto test : expected){
110 auto zsoln = testFromFile(tcomm, nParts, filename, doRemap, test.first);
114 const int *zparts = zsoln.getPartListView();
115 for (
unsigned i = 0; i < test.second.size(); ++i) {
116 if (zparts[i] != (
int) test.second[i]) {
117 std::cout <<
"FAIL" << std::endl;
123 std::cout <<
"PASS" << std::endl;
Provides access for Zoltan2 to Xpetra::CrsMatrix data.
int main(int narg, char **arg)
Defines the PartitioningSolution class.
common code used by tests
Defines the XpetraCrsMatrixAdapter class.
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > myTypes_t
Tpetra::CrsMatrix< zscalar_t, zlno_t, zgno_t, znode_t > tcrsMatrix_t
PartitioningProblem sets up partitioning problems for the user.
Defines the PartitioningProblem class.
std::string testDataFilePath(".")