16 #include "Galeri_Maps.h"
17 #include "Galeri_CrsMatrices.h"
19 #ifdef HAVE_VALGRIND_H
20 #include <valgrind/valgrind.h>
23 #ifdef HAVE_VALGRIND_VALGRIND_H
24 #include <valgrind/valgrind.h>
30 using namespace Galeri;
41 bool testPassed =
true;
54 TimingsList.
get(
"Total symbolic factorization time", 0.0 );
59 Teuchos::getParameter<double>( TimingsList,
"Total numeric factorization time" );
64 Teuchos::getParameter<double>( TimingsList,
"Total solve time" );
69 Teuchos::getParameter<double>( TimingsList,
"Total solve time" );
73 TimingsList.
get(
"Total matrix redistribution time", 0.0 );
77 TimingsList.
get(
"Total vector redistribution time", 0.0 );
80 catch( std::exception& e ) {
81 if (
Comm.MyPID() == 0)
82 std::cout << std::endl <<
"Exception caught in TestTiming() : " << e.what() << std::endl;
92 const std::string Descriptor,
98 if (
A.Comm().MyPID() == 0)
99 std::cout << std::endl <<
"*** " << SolverType <<
" : "
100 << Descriptor <<
" ***" << std::endl;
101 std::vector<double> Norm;
103 Norm.resize(NumVectors);
105 A.Multiply(
false,x,Ax);
108 bool TestPassed =
false;
109 double TotalNorm = 0.0;
110 for (
int i = 0 ; i < NumVectors ; ++i) {
111 TotalNorm += Norm[i];
113 if (
A.Comm().MyPID() == 0)
114 std::cout <<
"||Ax - b|| = " << TotalNorm << std::endl;
115 if (TotalNorm < 1e-5 )
120 Ax.
Update (1.0,x,-1.0,x_exact,0.0);
122 for (
int i = 0 ; i < NumVectors ; ++i) {
123 TotalNorm += Norm[i];
125 if (
A.Comm().MyPID() == 0)
126 std::cout <<
"||x - x_exact|| = " << TotalNorm << std::endl;
127 if (TotalNorm < 1e-5 )
144 bool TestPassed =
true;
161 Solver = Factory.
Create(SolverType,ProblemA);
167 std::string ST = SolverType ;
168 if (! ( ST ==
"Amesos_Superludist" ) ) {
171 TestPassed = TestPassed &&
172 CheckError(SolverType,
"Solve() only",
A,x_A,b_A,x_exactA) &&
191 Solver = Factory.
Create(SolverType,ProblemA);
199 TestPassed = TestPassed &&
200 CheckError(SolverType,
"NumFact() + Solve()",
A,x_A,b_A,x_exactA) &&
223 Solver = Factory.
Create(SolverType,ProblemA);
243 TestPassed = TestPassed &&
244 CheckError(SolverType,
"SymFact() + NumFact() + Solve()",
245 A,x_A,b_A,x_exactA) &&
267 Solver = Factory.
Create(SolverType,ProblemA);
278 TestPassed = TestPassed &&
279 CheckError(SolverType,
"Set A, solve B",
B,x_B,b_B,x_exactB) &&
296 Solver = Factory.
Create(SolverType,ProblemA);
300 std::string ST = SolverType ;
301 if (! ( ST ==
"Amesos_Superludist" ) ) {
310 TestPassed = TestPassed &&
311 CheckError(SolverType,
"Set A, Solve C",
C,x_C,b_C,x_exactC) &&
328 Solver = Factory.
Create(SolverType,ProblemA);
330 std::string ST = SolverType ;
331 if (! ( ST ==
"Amesos_Superludist" ) ) {
342 TestPassed = TestPassed &&
343 CheckError(SolverType,
"Solve A + Solve C",
C,x_C,b_C,x_exactC) &&
363 int NumVectors_AB = 7;
364 int NumVectors_C = 13;
367 if ( RUNNING_ON_VALGRIND ) {
377 GaleriList.
set(
"n", Size_AB * Size_AB);
378 GaleriList.
set(
"nx", Size_AB);
379 GaleriList.
set(
"ny", Size_AB);
384 GaleriList.
set(
"n", Size_C);
396 A.Multiply(
false,x_exactA,b_A);
402 B.Multiply(
false,x_exactB,b_B);
408 C.Multiply(
false,x_exactC,b_C);
410 std::vector<std::string> SolverType;
411 SolverType.push_back(
"Amesos_Klu");
412 SolverType.push_back(
"Amesos_Lapack");
413 SolverType.push_back(
"Amesos_Umfpack");
414 SolverType.push_back(
"Amesos_Superlu");
415 SolverType.push_back(
"Amesos_Superludist");
416 SolverType.push_back(
"Amesos_Mumps");
420 bool TestPassed =
true;
422 for (
unsigned int i = 0 ; i < SolverType.size() ; ++i) {
423 std::string Solver = SolverType[i];
424 if (Factory.
Query((
char*)Solver.c_str())) {
425 bool ok =
Test((
char*)Solver.c_str(),
426 A, x_A, b_A, x_exactA,
427 B, x_B, b_B, x_exactB,
428 C, x_C, b_C, x_exactC);
429 TestPassed = TestPassed && ok;
433 if (
Comm.MyPID() == 0)
434 std::cout <<
"Solver " << Solver <<
" not available" << std::endl;
445 if (
Comm.MyPID() == 0)
446 std::cout << std::endl <<
"TEST PASSED" << std::endl << std::endl;
447 return(EXIT_SUCCESS);
450 if (
Comm.MyPID() == 0)
451 std::cout << std::endl <<
"TEST FAILED" << std::endl << std::endl;
458 int main(
int argc,
char *argv[]) {
461 MPI_Init(&argc, &argv);
468 if (
Comm.MyPID() == 0 ) {
469 std::cout <<
"Enter a char to continue" ;