Commit 20cb7b89 authored by Dmitry Bagaev's avatar Dmitry Bagaev

Tests refactored using new Solver class

parent 5dd7d258
......@@ -42,73 +42,73 @@ if(USE_SOLVER_SUPERLU)
endif()
add_test(NAME solver_test000_serial_inner_ilu2 COMMAND $<TARGET_FILE:solver_test000> 0 0)
add_test(NAME solver_test000_serial_inner_ddpqiluc COMMAND $<TARGET_FILE:solver_test000> 0 1)
add_test(NAME solver_test000_serial_inner_ilu2 COMMAND $<TARGET_FILE:solver_test000> 0 inner_ilu2)
add_test(NAME solver_test000_serial_inner_ddpqiluc COMMAND $<TARGET_FILE:solver_test000> 0 inner_ddpqiluc2)
if( HAVE_SOLVER_MPTILUC2 )
add_test(NAME solver_test000_serial_inner_mptiluc COMMAND $<TARGET_FILE:solver_test000> 0 8)
add_test(NAME solver_test000_serial_inner_mptiluc COMMAND $<TARGET_FILE:solver_test000> 0 inner_mptiluc)
endif()
if( HAVE_SOLVER_MPTILU2 )
add_test(NAME solver_test000_serial_inner_mptilu2 COMMAND $<TARGET_FILE:solver_test000> 0 9)
add_test(NAME solver_test000_serial_inner_mptilu2 COMMAND $<TARGET_FILE:solver_test000> 0 inner_mptilu2)
endif()
if(USE_SOLVER_PETSC)
add_test(NAME solver_test000_serial_petsc COMMAND $<TARGET_FILE:solver_test000> 0 2)
add_test(NAME solver_test000_serial_petsc COMMAND $<TARGET_FILE:solver_test000> 0 petsc)
endif()
if(USE_SOLVER_TRILINOS)
add_test(NAME solver_test000_serial_trilinos_aztec COMMAND $<TARGET_FILE:solver_test000> 0 3)
add_test(NAME solver_test000_serial_trilinos_ifpack COMMAND $<TARGET_FILE:solver_test000> 0 4)
add_test(NAME solver_test000_serial_trilinos_ml COMMAND $<TARGET_FILE:solver_test000> 0 5)
add_test(NAME solver_test000_serial_trilinos_belos COMMAND $<TARGET_FILE:solver_test000> 0 6)
add_test(NAME solver_test000_serial_trilinos_aztec COMMAND $<TARGET_FILE:solver_test000> 0 trilinos_aztec)
add_test(NAME solver_test000_serial_trilinos_ifpack COMMAND $<TARGET_FILE:solver_test000> 0 trilinos_ifpack)
add_test(NAME solver_test000_serial_trilinos_ml COMMAND $<TARGET_FILE:solver_test000> 0 trilinos_ml)
add_test(NAME solver_test000_serial_trilinos_belos COMMAND $<TARGET_FILE:solver_test000> 0 trilinos_belos)
endif()
if(USE_SOLVER_ANI)
add_test(NAME solver_test000_serial_ani COMMAND $<TARGET_FILE:solver_test000> 2 0 7)
add_test(NAME solver_test000_serial_ani COMMAND $<TARGET_FILE:solver_test000> 0 ani)
endif()
if( USE_MPI )
if( EXISTS ${MPIEXEC} )
add_test(NAME solver_test000_parallel_normal_inner_ilu2 COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 0 0)
add_test(NAME solver_test000_parallel_permute1_inner_ilu2 COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 1 0)
add_test(NAME solver_test000_parallel_permute2_inner_ilu2 COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 2 0)
add_test(NAME solver_test000_parallel_normal_inner_ilu2 COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 0 inner_ilu2)
add_test(NAME solver_test000_parallel_permute1_inner_ilu2 COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 1 inner_ilu2)
add_test(NAME solver_test000_parallel_permute2_inner_ilu2 COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 2 inner_ilu2)
add_test(NAME solver_test000_parallel_normal_inner_ddpqiluc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 0 1)
add_test(NAME solver_test000_parallel_permute1_inner_ddpqiluc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 1 1)
add_test(NAME solver_test000_parallel_permute2_inner_ddpqiluc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 2 1)
add_test(NAME solver_test000_parallel_normal_inner_ddpqiluc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 0 inner_ddpqiluc2)
add_test(NAME solver_test000_parallel_permute1_inner_ddpqiluc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 1 inner_ddpqiluc2)
add_test(NAME solver_test000_parallel_permute2_inner_ddpqiluc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 2 inner_ddpqiluc2)
if( HAVE_SOLVER_MPTILUC2 )
add_test(NAME solver_test000_parallel_normal_inner_mptiluc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 0 8)
add_test(NAME solver_test000_parallel_permute1_inner_mptiluc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 1 8)
add_test(NAME solver_test000_parallel_permute2_inner_mptiluc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 2 8)
add_test(NAME solver_test000_parallel_normal_inner_mptiluc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 0 inner_mptiluc)
add_test(NAME solver_test000_parallel_permute1_inner_mptiluc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 1 inner_mptiluc)
add_test(NAME solver_test000_parallel_permute2_inner_mptiluc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 2 inner_mptiluc)
endif()
if( HAVE_SOLVER_MPTILU2 )
add_test(NAME solver_test000_parallel_normal_inner_mptilu2 COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 0 9)
add_test(NAME solver_test000_parallel_permute1_inner_mptilu2 COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 1 9)
add_test(NAME solver_test000_parallel_permute2_inner_mptilu2 COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 2 9)
add_test(NAME solver_test000_parallel_normal_inner_mptilu2 COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 0 inner_mptilu2)
add_test(NAME solver_test000_parallel_permute1_inner_mptilu2 COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 1 inner_mptilu2)
add_test(NAME solver_test000_parallel_permute2_inner_mptilu2 COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 2 inner_mptilu2)
endif()
if(USE_SOLVER_PETSC)
add_test(NAME solver_test000_parallel_normal_petsc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 0 2)
add_test(NAME solver_test000_parallel_normal_petsc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 0 petsc)
#add_test(NAME solver_test000_parallel_permute1_petsc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 1 2)
#add_test(NAME solver_test000_parallel_permute2_petsc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 2 2)
endif()
if(USE_SOLVER_TRILINOS)
add_test(NAME solver_test000_parallel_normal_trilinos_aztec COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 0 3)
add_test(NAME solver_test000_parallel_permute1_trilinos_aztec COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 1 3)
add_test(NAME solver_test000_parallel_permute2_trilinos_aztec COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 2 3)
add_test(NAME solver_test000_parallel_normal_trilinos_aztec COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 0 trilinos_aztec)
add_test(NAME solver_test000_parallel_permute1_trilinos_aztec COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 1 trilinos_aztec)
add_test(NAME solver_test000_parallel_permute2_trilinos_aztec COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 2 trilinos_aztec)
add_test(NAME solver_test000_parallel_normal_trilinos_ifpack COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 0 4)
add_test(NAME solver_test000_parallel_permute1_trilinos_ifpack COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 1 4)
add_test(NAME solver_test000_parallel_permute2_trilinos_ifpack COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 2 4)
add_test(NAME solver_test000_parallel_normal_trilinos_ifpack COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 0 trilinos_ifpack)
add_test(NAME solver_test000_parallel_permute1_trilinos_ifpack COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 1 trilinos_ifpack)
add_test(NAME solver_test000_parallel_permute2_trilinos_ifpack COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 2 trilinos_ifpack)
add_test(NAME solver_test000_parallel_normal_trilinos_ml COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 0 5)
add_test(NAME solver_test000_parallel_permute1_trilinos_ml COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 1 5)
add_test(NAME solver_test000_parallel_permute2_trilinos_ml COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 2 5)
add_test(NAME solver_test000_parallel_normal_trilinos_ml COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 0 trilinos_ml)
add_test(NAME solver_test000_parallel_permute1_trilinos_ml COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 1 trilinos_ml)
add_test(NAME solver_test000_parallel_permute2_trilinos_ml COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 2 trilinos_ml)
#add_test(NAME solver_test000_parallel_normal_trilinos_belos COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 0 6)
#add_test(NAME solver_test000_parallel_permute1_trilinos_belos COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test000> 1 6)
......
......@@ -7,7 +7,8 @@ using namespace INMOST;
int main(int argc,char ** argv)
{
int permut = 0;
int solver = 0; // 0 - INNER_ILU2, 1 - INNER_MLILUC, 2 - PETSc
std::string solver = "inner_ilu2";
// 0 - INNER_ILU2, 1 - INNER_MLILUC, 2 - PETSc
// 3 - Trilinos_Aztec, 4 - Trilinos_Ifpack,
// 5 - Trilinos_ML, 6 - Trilinos_Belos, 7 - ANI
int rank,procs,newrank;
......@@ -22,30 +23,15 @@ int main(int argc,char ** argv)
#endif
if (argc > 1) permut = atoi(argv[1]);
if (argc > 2) solver = atoi(argv[2]);
if (argc > 2) solver = std::string(argv[2]);
if (permut < procs) newrank = (rank + permut) % procs;
else newrank = (permut - rank) % procs;
std::cout << rank << " -> " << newrank << std::endl;
Solver::Type type;
switch(solver)
{
case 0: type = Solver::INNER_ILU2; break;
case 1: type = Solver::INNER_DDPQILUC; break;
case 2: type = Solver::PETSc; break;
case 3: type = Solver::Trilinos_Aztec; break;
case 4: type = Solver::Trilinos_Ifpack; break;
case 5: type = Solver::Trilinos_ML; break;
case 6: type = Solver::Trilinos_Belos; break;
case 7: type = Solver::ANI; break;
case 8: type = Solver::INNER_MPTILUC; break;
case 9: type = Solver::INNER_MPTILU2; break;
}
{
Solver S(type); // Specify the linear solver
Solver S(solver); // Specify the linear solver
Sparse::Matrix A; // Declare the matrix of the linear system to be solved
......@@ -72,7 +58,7 @@ int main(int argc,char ** argv)
if( !S.Solve(b,x) ) // Solve the linear system with the previously computted preconditioner
{
if( rank == 0 )
std::cout << S.GetReason() << std::endl;
std::cout << S.ReturnReason() << std::endl;
#if defined(USE_MPI)
MPI_Abort(MPI_COMM_WORLD,-1);
#else
......
......@@ -43,52 +43,52 @@ if(USE_SOLVER)
endif()
endif()
add_test(NAME solver_test002_serial_inner_ilu2 COMMAND $<TARGET_FILE:solver_test002> 0 20)
add_test(NAME solver_test002_serial_inner_ddpqiluc COMMAND $<TARGET_FILE:solver_test002> 1 20)
add_test(NAME solver_test002_serial_inner_ilu2 COMMAND $<TARGET_FILE:solver_test002> inner_ilu2 20)
add_test(NAME solver_test002_serial_inner_ddpqiluc COMMAND $<TARGET_FILE:solver_test002> inner_ddpqiluc2 20)
if(HAVE_SOLVER_MPTILUC2)
add_test(NAME solver_test002_serial_inner_mptiluc COMMAND $<TARGET_FILE:solver_test002> 2 20)
add_test(NAME solver_test002_serial_inner_mptiluc COMMAND $<TARGET_FILE:solver_test002> inner_mptiluc 20)
endif()
if(HAVE_SOLVER_MPTILU2)
add_test(NAME solver_test002_serial_inner_mptilu2 COMMAND $<TARGET_FILE:solver_test002> 3 20)
add_test(NAME solver_test002_serial_inner_mptilu2 COMMAND $<TARGET_FILE:solver_test002> inner_mptilu2 20)
endif()
if(USE_SOLVER_TRILINOS)
add_test(NAME solver_test002_serial_trilinos_aztec COMMAND $<TARGET_FILE:solver_test002> 4 20)
add_test(NAME solver_test002_serial_trilinos_belos COMMAND $<TARGET_FILE:solver_test002> 5 20)
add_test(NAME solver_test002_serial_trilinos_ml COMMAND $<TARGET_FILE:solver_test002> 6 20)
add_test(NAME solver_test002_serial_trilinos_ifpack COMMAND $<TARGET_FILE:solver_test002> 7 20)
add_test(NAME solver_test002_serial_trilinos_aztec COMMAND $<TARGET_FILE:solver_test002> trilinos_aztec 20)
add_test(NAME solver_test002_serial_trilinos_belos COMMAND $<TARGET_FILE:solver_test002> trilinos_belos 20)
add_test(NAME solver_test002_serial_trilinos_ml COMMAND $<TARGET_FILE:solver_test002> trilinos_ml 20)
add_test(NAME solver_test002_serial_trilinos_ifpack COMMAND $<TARGET_FILE:solver_test002> trilinos_ifpack 20)
endif()
if(USE_SOLVER_PETSC)
add_test(NAME solver_test002_serial_petsc COMMAND $<TARGET_FILE:solver_test002> 8 20)
add_test(NAME solver_test002_serial_petsc COMMAND $<TARGET_FILE:solver_test002> petsc 20)
endif()
if(USE_SOLVER_ANI)
add_test(NAME solver_test002_serial_ani COMMAND $<TARGET_FILE:solver_test002> 9 20)
add_test(NAME solver_test002_serial_ani COMMAND $<TARGET_FILE:solver_test002> ani 20)
endif()
if( USE_MPI )
if( EXISTS ${MPIEXEC} )
add_test(NAME solver_test002_parallel_inner_ilu2 COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test002> 0 20)
add_test(NAME solver_test002_parallel_inner_ddpqiluc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test002> 1 20)
add_test(NAME solver_test002_parallel_inner_ilu2 COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test002> inner_ilu2 20)
add_test(NAME solver_test002_parallel_inner_ddpqiluc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test002> inner_ddpqiluc2 20)
if(HAVE_SOLVER_MPTILUC2)
add_test(NAME solver_test002_parallel_inner_mptiluc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test002> 2 20)
add_test(NAME solver_test002_parallel_inner_mptiluc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test002> inner_mptiluc 20)
endif()
if(HAVE_SOLVER_MPTILU2)
add_test(NAME solver_test002_parallel_inner_mptilu2 COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test002> 3 20)
add_test(NAME solver_test002_parallel_inner_mptilu2 COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test002> inner_mptilu2 20)
endif()
if(USE_SOLVER_TRILINOS)
add_test(NAME solver_test002_parallel_trilinos_aztec COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test002> 4 20)
add_test(NAME solver_test002_parallel_trilinos_belos COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test002> 5 20)
add_test(NAME solver_test002_parallel_trilinos_ml COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test002> 6 20)
add_test(NAME solver_test002_parallel_trilinos_ifpack COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test002> 7 20)
add_test(NAME solver_test002_parallel_trilinos_aztec COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test002> trilinos_aztec 20)
add_test(NAME solver_test002_parallel_trilinos_belos COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test002> trilinos_belos 20)
add_test(NAME solver_test002_parallel_trilinos_ml COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test002> trilinos_ml 20)
add_test(NAME solver_test002_parallel_trilinos_ifpack COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test002> trilinos_ifpack 20)
endif()
if(USE_SOLVER_PETSC)
add_test(NAME solver_test002_parallel_petsc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test002> 8 20)
add_test(NAME solver_test002_parallel_petsc COMMAND ${MPIEXEC} -np 4 $<TARGET_FILE:solver_test002> petsc 20)
endif()
endif()
......
......@@ -87,25 +87,10 @@ int main(int argc, char ** argv)
int rank,procs;
if( argc < 3 )
{
std::cout << "Usage: " << argv[0] << " method_number<0:INNER_ILU2,1:INNER_DDPQILUC,2:INNER_MPTILUC,3:INNER_MPTILU2,4:Trilinos_Aztec,5:Trilinos_Belos,6:Trilinos_ML,7:Trilinos_Ifpack,8:PETSc,9:ANI,10:FCBIILU2,11:K3BIILU2> N<for NxNxN problem> [solver_options.txt]" << std::endl;
std::cout << "Usage: " << argv[0] << " S<method name> N<for NxNxN problem> [solver_options.txt]" << std::endl;
return -1;
}
Solver::Type type;
switch(atoi(argv[1]))
{
case 0: type = Solver::INNER_ILU2; break;
case 1: type = Solver::INNER_DDPQILUC; break;
case 2: type = Solver::INNER_MPTILUC; break;
case 3: type = Solver::INNER_MPTILU2; break;
case 4: type = Solver::Trilinos_Aztec; break;
case 5: type = Solver::Trilinos_Belos; break;
case 6: type = Solver::Trilinos_ML; break;
case 7: type = Solver::Trilinos_Ifpack; break;
case 8: type = Solver::PETSc; break;
case 9: type = Solver::ANI; break;
case 10: type = Solver::FCBIILU2; break;
case 11: type = Solver::K3BIILU2; break;
}
std::string type = std::string(argv[1]);
int n = atoi(argv[2]);
Solver::Initialize(&argc,&argv,argc > 3 ? argv[3] : NULL); // Initialize the linear solver in accordance with args
......@@ -118,7 +103,7 @@ int main(int argc, char ** argv)
procs = 1;
#endif
if( rank == 0 )
std::cout << "Testing " << Solver::TypeName(type) << std::endl;
std::cout << "Testing " << type << std::endl;
//std::cout << rank << "/" << procs << " " << argv[0] << std::endl;
Sparse::Matrix mat("A"); // Declare the matrix of the linear system to be solved
Sparse::Vector b("rhs"); // Declare the right-hand side vector
......@@ -143,15 +128,15 @@ int main(int argc, char ** argv)
{
Solver s(type); // Declare the linear solver by specified type
s.SetParameterEnum("gmres_substeps",3);
s.SetParameter("gmres_substeps", "3");
s.SetParameterEnum("reorder_nonzeros",0);
s.SetParameterEnum("rescale_iterations",8);
s.SetParameterEnum("adapt_ddpq_tolerance",0);
s.SetParameter("reorder_nonzeros", "0");
s.SetParameter("rescale_iterations", "8");
s.SetParameter("adapt_ddpq_tolerance", "0");
s.SetParameterReal("drop_tolerance",0.001);
s.SetParameterReal("reuse_tolerance",0.00001);
s.SetParameterReal("ddpq_tolerance",0.7);
s.SetParameter("drop_tolerance", "0.001");
s.SetParameter("reuse_tolerance", "0.00001");
s.SetParameter("ddpq_tolerance", "0.7");
t = Timer();
......@@ -164,7 +149,7 @@ int main(int argc, char ** argv)
if( !rank ) std::cout << "solver: " << Timer() - t << std::endl;
iters = s.Iterations(); // Get the number of iterations performed
resid = s.Residual(); // Get the final residual achieved
reason = s.GetReason();
reason = s.ReturnReason();
//x.Save("output.rhs");
}
tt = Timer() - tt;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment