51 #include <Teuchos_ParameterList.hpp>
52 #include <Teuchos_RCP.hpp>
53 #include <Teuchos_FancyOStream.hpp>
54 #include <Teuchos_CommandLineProcessor.hpp>
55 #include <Tpetra_CrsMatrix.hpp>
56 #include <Tpetra_Vector.hpp>
57 #include <MatrixMarket_Tpetra.hpp>
71 typedef Tpetra::Vector<z2TestScalar, z2TestLO, z2TestGO>
Vector;
72 typedef Vector::node_type
Node;
74 typedef Tpetra::MultiVector<z2TestScalar, z2TestLO, z2TestGO,znode_t>
tMVector_t;
82 #define epsilon 0.00000001
84 int testNDwithRCB(RCP<SparseMatrix_t> &origMatrix,RCP<tMVector_t> &coords,
int numParts,
int me);
85 int testNDwithPHG(RCP<SparseMatrix_t> &origMatrix,
int numParts,
int me);
89 int main(
int narg,
char** arg)
94 Tpetra::ScopeGuard tscope(&narg, &arg);
95 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
96 int me = comm->getRank();
99 std::string inputFile =
"";
101 bool distributeInput =
true;
108 Teuchos::CommandLineProcessor cmdp (
false,
false);
109 cmdp.setOption(
"inputPath", &inputPath,
110 "Path to the MatrixMarket or Zoltan file to be read; "
111 "if not specified, a default path will be used.");
112 cmdp.setOption(
"inputFile", &inputFile,
113 "Name of the Matrix Market or Zoltan file to read; "
115 cmdp.setOption(
"distribute",
"no-distribute", &distributeInput,
116 "for Zoltan input files only, "
117 "indicate whether or not to distribute "
118 "input across the communicator");
119 cmdp.setOption(
"numParts", &numParts,
120 "Global number of parts;");
122 Teuchos::CommandLineProcessor::EParseCommandLineReturn
123 parseReturn= cmdp.parse( narg, arg );
125 if( parseReturn == Teuchos::CommandLineProcessor::PARSE_HELP_PRINTED )
134 RCP<UserInputForTests> uinput;
139 true, distributeInput));
143 std::cout <<
"Input file must be specified." << std::endl;
146 RCP<SparseMatrix_t> origMatrix = uinput->getUITpetraCrsMatrix();
151 std::cout <<
"NumRows = " << origMatrix->getGlobalNumRows() << std::endl
152 <<
"NumNonzeros = " << origMatrix->getGlobalNumEntries() << std::endl
153 <<
"NumProcs = " << comm->getSize() << std::endl
154 <<
"NumParts = " << numParts << std::endl;
157 if (origMatrix->getGlobalNumRows() < 40)
159 Teuchos::FancyOStream out(Teuchos::rcp(&std::cout,
false));
160 origMatrix->describe(out, Teuchos::VERB_EXTREME);
167 RCP<tMVector_t> coords;
170 coords = uinput->getUICoordinates();
175 std::cout <<
"FAIL: get coordinates" << std::endl;
200 int testNDwithRCB(RCP<SparseMatrix_t> &origMatrix,RCP<tMVector_t> &coords,
int numParts,
int me)
207 Teuchos::ParameterList params;
209 params.set(
"num_global_parts", numParts);
210 params.set(
"order_method",
"nd");
211 params.set(
"edge_separator_method",
"rcb");
228 std::cout <<
"FAIL: vector adapter" << std::endl;
243 if (me == 0) std::cout <<
"Calling solve() " << std::endl;
245 if (me == 0) std::cout <<
"Done solve() " << std::endl;
247 catch (std::runtime_error &e)
249 std::cout <<
"Runtime exception returned from solve(): " << e.what();
250 if (!strncmp(e.what(),
"BUILD ERROR", 11)) {
252 std::cout <<
" PASS" << std::endl;
257 std::cout <<
" FAIL" << std::endl;
261 catch (std::logic_error &e)
263 std::cout <<
"Logic exception returned from solve(): " << e.what()
264 <<
" FAIL" << std::endl;
267 catch (std::bad_alloc &e)
269 std::cout <<
"Bad_alloc exception returned from solve(): " << e.what()
270 <<
" FAIL" << std::endl;
273 catch (std::exception &e)
275 std::cout <<
"Unknown exception returned from solve(). " << e.what()
276 <<
" FAIL" << std::endl;
285 std::cout <<
"PASS" << std::endl;
300 Teuchos::ParameterList params;
302 params.set(
"num_global_parts", numParts);
303 params.set(
"order_method",
"nd");
304 params.set(
"edge_separator_method",
"phg");
321 if (me == 0) std::cout <<
"Calling solve() " << std::endl;
323 if (me == 0) std::cout <<
"Done solve() " << std::endl;
325 catch (std::runtime_error &e)
327 std::cout <<
"Runtime exception returned from solve(): " << e.what();
328 if (!strncmp(e.what(),
"BUILD ERROR", 11)) {
330 std::cout <<
" PASS" << std::endl;
335 std::cout <<
" FAIL" << std::endl;
339 catch (std::logic_error &e)
341 std::cout <<
"Logic exception returned from solve(): " << e.what()
342 <<
" FAIL" << std::endl;
345 catch (std::bad_alloc &e)
347 std::cout <<
"Bad_alloc exception returned from solve(): " << e.what()
348 <<
" FAIL" << std::endl;
351 catch (std::exception &e)
353 std::cout <<
"Unknown exception returned from solve(). " << e.what()
354 <<
" FAIL" << std::endl;
359 std::cout <<
"PASS" << std::endl;
Provides access for Zoltan2 to Xpetra::CrsMatrix data.
int testNDwithRCB(RCP< SparseMatrix_t > &origMatrix, RCP< tMVector_t > &coords, int numParts, int me)
Tpetra::CrsMatrix< z2TestScalar, z2TestLO, z2TestGO > SparseMatrix_t
int main(int narg, char **arg)
common code used by tests
Tpetra::Vector< z2TestScalar, z2TestLO, z2TestGO > Vector
Defines the XpetraMultiVectorAdapter.
OrderingProblem sets up ordering problems for the user.
Defines the XpetraCrsMatrixAdapter class.
Zoltan2::XpetraCrsMatrixAdapter< SparseMatrix_t, tMVector_t > SparseMatrixAdapter_t
void solve(bool updateInputData=true)
Direct the problem to create a solution.
Zoltan2::XpetraMultiVectorAdapter< tMVector_t > MultiVectorAdapter_t
An adapter for Xpetra::MultiVector.
Tpetra::Map::local_ordinal_type zlno_t
Defines the OrderingProblem class.
int testNDwithPHG(RCP< SparseMatrix_t > &origMatrix, int numParts, int me)
void setCoordinateInput(VectorAdapter< UserCoord > *coordData) override
Allow user to provide additional data that contains coordinate info associated with the MatrixAdapter...
Tpetra::MultiVector< zscalar_t, zlno_t, zgno_t, znode_t > tMVector_t
Tpetra::Map::global_ordinal_type zgno_t
std::string testDataFilePath(".")