diff --git a/examples/._ExampleHelper.hpp b/examples/._ExampleHelper.hpp new file mode 100755 index 00000000..75f4b12f Binary files /dev/null and b/examples/._ExampleHelper.hpp differ diff --git a/resolve/._LinSolverIterativeFGMRES.cpp b/resolve/._LinSolverIterativeFGMRES.cpp new file mode 100755 index 00000000..a69c11a9 Binary files /dev/null and b/resolve/._LinSolverIterativeFGMRES.cpp differ diff --git a/resolve/GramSchmidt.cpp b/resolve/GramSchmidt.cpp index 18b70277..018a2498 100644 --- a/resolve/GramSchmidt.cpp +++ b/resolve/GramSchmidt.cpp @@ -172,7 +172,7 @@ namespace ReSolve } else { - assert(0 && "Gram-Schmidt failed, vector with ZERO norm\n"); + std::cout << "Encountered loss of Orthogonality, exiting gracefully at step " << i + 1 << std::endl; return 1; } return 0; @@ -222,7 +222,7 @@ namespace ReSolve } else { - assert(0 && "Gram-Schmidt failed, vector with ZERO norm\n"); + std::cout << "Encountered loss of Orthogonality, exiting gracefully at step " << i + 1 << std::endl; return 1; } return 0; @@ -279,7 +279,7 @@ namespace ReSolve } else { - assert(0 && "Iterative refinement failed, Krylov vector with ZERO norm\n"); + std::cout << "Encountered loss of Orthogonality, exiting gracefully at step " << i + 1 << std::endl; return 1; } h_rv = nullptr; @@ -364,7 +364,7 @@ namespace ReSolve } else { - assert(0 && "Iterative refinement failed, Krylov vector with ZERO norm\n"); + std::cout << "Encountered loss of Orthogonality, exiting gracefully at step " << i + 1 << std::endl; return 1; } h_rv = nullptr; @@ -395,7 +395,7 @@ namespace ReSolve } else { - assert(0 && "Gram-Schmidt failed, vector with ZERO norm\n"); + std::cout << "Encountered loss of Orthogonality, exiting gracefully at step " << i + 1 << std::endl; return 1; } return 0; diff --git a/resolve/LinSolverIterativeFGMRES.cpp b/resolve/LinSolverIterativeFGMRES.cpp index 643f23a4..b0f5afcf 100644 --- a/resolve/LinSolverIterativeFGMRES.cpp +++ b/resolve/LinSolverIterativeFGMRES.cpp @@ -108,37 +108,63 @@ namespace ReSolve // io::Logger::setVerbosity(io::Logger::EVERYTHING); - int outer_flag = 1; - int notconv = 1; - int i = 0; - int it = 0; - int j = 0; - int k = 0; - int k1 = 0; + int outer_flag = 1; + int update_flag = 1; + int notconv = 1; + int i = 0; + int it = 0; + int j = 0; + int k = 0; + int k1 = 0; real_type t = 0.0; real_type rnorm = 0.0; real_type bnorm = 0.0; real_type tolrel; + real_type rhsnorm = 0.0; vector_type vec_v(n_); vector_type vec_z(n_); - // V[0] = b-A*x_0 - // debug + + // Compute the residual + vec_R_->setToZero(memspace_); + vec_R_->copyDataFrom(rhs, memspace_, memspace_); + matrix_handler_->matvec(A_, x, vec_R_, &MINUS_ONE, &ONE, memspace_); + + // Normalizing the RHS + bnorm = vector_handler_->dot(vec_R_, vec_R_, memspace_); + bnorm = std::sqrt(bnorm); + t = 1 / bnorm; + vector_handler_->scal(&t, vec_R_, memspace_); + + // Arnoldi Basis vec_Z_->setToZero(memspace_); vec_V_->setToZero(memspace_); - rhs->copyDataTo(vec_V_->getData(memspace_), 0, memspace_); - matrix_handler_->matvec(A_, x, vec_V_, &MINUS_ONE, &ONE, memspace_); - rnorm = 0.0; - bnorm = vector_handler_->dot(rhs, rhs, memspace_); + // Initializing Residual and Update + vec_Y_->setToZero(memspace_); + + // Computing the first Arnodi basis vector + vec_R_->copyDataTo(vec_V_->getData(memspace_), 0, memspace_); rnorm = vector_handler_->dot(vec_V_, vec_V_, memspace_); - // rnorm = ||V_1|| rnorm = std::sqrt(rnorm); - bnorm = std::sqrt(bnorm); + + // Checking if bnorm > norm of RHS + rhsnorm = vector_handler_->dot(rhs, rhs, memspace_); + rhsnorm = std::sqrt(rhsnorm); + if (bnorm > rhsnorm) + { + std::cout << "Initial guess is invalid. Quitting iterative refinement" << std::endl; + initial_residual_norm_ = bnorm; + final_residual_norm_ = bnorm; // Set final norm to initial norm as no work was done. + total_iters_ = 0; + return 0; + } + io::Logger::misc() << "it 0: norm of residual " << std::scientific << std::setprecision(16) << rnorm << " Norm of rhs: " << bnorm << "\n"; - initial_residual_norm_ = rnorm; + initial_residual_norm_ = bnorm; + while (outer_flag) { if (it == 0) @@ -169,13 +195,11 @@ namespace ReSolve outer_flag = 0; final_residual_norm_ = rnorm; initial_residual_norm_ = rnorm; + update_flag = 1; total_iters_ = 0; break; } - // normalize first vector - t = 1.0 / rnorm; - vector_handler_->scal(&t, vec_V_, memspace_); // initialize norm history h_rs_[0] = rnorm; i = -1; @@ -200,14 +224,18 @@ namespace ReSolve mem_.deviceSynchronize(); // V_{i+1}=A*Z_i - vec_v.setData(vec_V_->getData(i + 1, memspace_), memspace_); - matrix_handler_->matvec(A_, &vec_z, &vec_v, &ONE, &ZERO, memspace_); // orthogonalize V[i+1], form a column of h_H_ - GS_->orthogonalize(n_, vec_V_, h_H_, i); + int gs_status = GS_->orthogonalize(n_, vec_V_, h_H_, i); + + if (gs_status != 0) // checking for successful breakdown + { + notconv = 0; // exiting outer loop after one inner loop iteration + } + if (i != 0) { for (index_type k = 1; k <= i; k++) @@ -252,7 +280,18 @@ namespace ReSolve << std::scientific << std::setprecision(16) << rnorm << "\n"; // solve tri system - h_rs_[i] = h_rs_[i] / h_H_[i * (restart_ + 1) + i]; + real_type H_ii_diag = h_H_[i * (restart_ + 1) + i]; + + // FIX: Check for division by zero before starting back-substitution + if (std::abs(H_ii_diag) < MACHINE_EPSILON) + { + h_rs_[i] = ZERO; // Last element of solution is set to 0 + } + else + { + h_rs_[i] = h_rs_[i] / H_ii_diag; + } + for (int ii = 2; ii <= i + 1; ii++) { k = i - ii + 1; @@ -262,7 +301,17 @@ namespace ReSolve { t -= h_H_[j * (restart_ + 1) + k] * h_rs_[j]; } - h_rs_[k] = t / h_H_[k * (restart_ + 1) + k]; + + // Checking for division by zero inside the loop as well + real_type H_diag_k = h_H_[k * (restart_ + 1) + k]; + if (std::abs(H_diag_k) < MACHINE_EPSILON) + { + h_rs_[k] = ZERO; + } + else + { + h_rs_[k] = t / H_diag_k; + } } // get solution @@ -271,7 +320,7 @@ namespace ReSolve for (j = 0; j <= i; j++) { vec_z.setData(vec_Z_->getData(j, memspace_), memspace_); - vector_handler_->axpy(&h_rs_[j], &vec_z, x, memspace_); + vector_handler_->axpy(&h_rs_[j], &vec_z, vec_Y_, memspace_); } } else @@ -287,11 +336,11 @@ namespace ReSolve vec_v.setData(vec_V_->getData(memspace_), memspace_); this->precV(&vec_z, &vec_v); - // and add to x - vector_handler_->axpy(&ONE, &vec_v, x, memspace_); + // and add to update + vector_handler_->axpy(&ONE, &vec_v, vec_Y_, memspace_); } - /* test solution */ + /* test update */ if (rnorm <= tolrel || it >= maxit_) { @@ -299,8 +348,8 @@ namespace ReSolve outer_flag = 0; } - rhs->copyDataTo(vec_V_->getData(memspace_), 0, memspace_); - matrix_handler_->matvec(A_, x, vec_V_, &MINUS_ONE, &ONE, memspace_); + vec_R_->copyDataTo(vec_V_->getData(memspace_), 0, memspace_); + matrix_handler_->matvec(A_, vec_Y_, vec_V_, &MINUS_ONE, &ONE, memspace_); rnorm = vector_handler_->dot(vec_V_, vec_V_, memspace_); // rnorm = ||V_1|| rnorm = std::sqrt(rnorm); @@ -314,6 +363,37 @@ namespace ReSolve << rnorm << "\n"; } } // outer while + + if (update_flag) + { + // renormalizing + t = bnorm; + vector_handler_->scal(&t, vec_Y_, memspace_); + vector_handler_->axpy(&ONE, x, vec_Y_, memspace_); + vec_R_->copyDataFrom(rhs, memspace_, memspace_); + matrix_handler_->matvec(A_, vec_Y_, vec_R_, &MINUS_ONE, &ONE, memspace_); + final_residual_norm_ = vector_handler_->dot(vec_R_, vec_R_, memspace_); + final_residual_norm_ = std::sqrt(final_residual_norm_); + + // Compare this with initial and update x accordingly + if (final_residual_norm_ < initial_residual_norm_) + { + std::cout << "Update to intial guess is successful, final residual (solution plus update) " + << std::scientific << std::setprecision(16) + << final_residual_norm_ / rhsnorm << "\n"; + + x->copyDataFrom(vec_Y_, memspace_, memspace_); + } + else + { + std::cout << "Update to intial guess is not successful, final residual greater than initial residual " + << std::scientific << std::setprecision(16) + << final_residual_norm_ / rhsnorm << "\n"; + + final_residual_norm_ = initial_residual_norm_; + } + } + return 0; } @@ -559,6 +639,11 @@ namespace ReSolve { vec_V_ = new vector_type(n_, restart_ + 1); vec_V_->allocate(memspace_); + vec_Y_ = new vector_type(n_); + vec_Y_->allocate(memspace_); + vec_R_ = new vector_type(n_); + vec_R_->allocate(memspace_); + if (flexible_) { vec_Z_ = new vector_type(n_, restart_ + 1); @@ -585,6 +670,8 @@ namespace ReSolve delete[] h_rs_; delete vec_V_; delete vec_Z_; + delete vec_R_; + delete vec_Y_; h_H_ = nullptr; h_c_ = nullptr; @@ -592,6 +679,8 @@ namespace ReSolve h_rs_ = nullptr; vec_V_ = nullptr; vec_Z_ = nullptr; + vec_Y_ = nullptr; + vec_R_ = nullptr; return 0; } diff --git a/resolve/LinSolverIterativeFGMRES.hpp b/resolve/LinSolverIterativeFGMRES.hpp index 38887579..7461959a 100644 --- a/resolve/LinSolverIterativeFGMRES.hpp +++ b/resolve/LinSolverIterativeFGMRES.hpp @@ -97,6 +97,8 @@ namespace ReSolve vector_type* vec_V_{nullptr}; vector_type* vec_Z_{nullptr}; + vector_type* vec_R_{nullptr}; + vector_type* vec_Y_{nullptr}; real_type* h_H_{nullptr}; real_type* h_c_{nullptr}; diff --git a/resolve/LinSolverIterativeRandFGMRES.cpp b/resolve/LinSolverIterativeRandFGMRES.cpp index db26b007..e744303d 100644 --- a/resolve/LinSolverIterativeRandFGMRES.cpp +++ b/resolve/LinSolverIterativeRandFGMRES.cpp @@ -138,10 +138,11 @@ namespace ReSolve // io::Logger::setVerbosity(io::Logger::EVERYTHING); - int outer_flag = 1; - int notconv = 1; - index_type i = 0; - int it = 0; + int outer_flag = 1; + int notconv = 1; + int update_flag = 1; + index_type i = 0; + int it = 0; int j; int k; int k1; @@ -150,16 +151,31 @@ namespace ReSolve real_type rnorm; real_type bnorm; real_type tolrel; + real_type rhsnorm; vector_type vec_v(n_); vector_type vec_z(n_); vector_type vec_s(k_rand_); - // V[0] = b-A*x_0 - // debug + + // Compute the residual + vec_R_->setToZero(memspace_); + vec_R_->copyDataFrom(rhs, memspace_, memspace_); + matrix_handler_->matvec(A_, x, vec_R_, &MINUS_ONE, &ONE, memspace_); + + // Normalizing the residual + bnorm = vector_handler_->dot(vec_R_, vec_R_, memspace_); + bnorm = std::sqrt(bnorm); + t = 1 / bnorm; + vector_handler_->scal(&t, vec_R_, memspace_); + + // Arnoldi Basis vec_Z_->setToZero(memspace_); vec_V_->setToZero(memspace_); - rhs->copyDataTo(vec_V_->getData(memspace_), 0, memspace_); - matrix_handler_->matvec(A_, x, vec_V_, &MINUS_ONE, &ONE, memspace_); + // Initializing Residual and Update + vec_Y_->setToZero(memspace_); + + // Computing the first Arnodi basis vector + vec_R_->copyDataTo(vec_V_->getData(memspace_), 0, memspace_); vec_v.setData(vec_V_->getData(0, memspace_), memspace_); vec_s.setData(vec_S_->getData(0, memspace_), memspace_); @@ -173,15 +189,27 @@ namespace ReSolve mem_.deviceSynchronize(); rnorm = 0.0; - bnorm = vector_handler_->dot(rhs, rhs, memspace_); rnorm = vector_handler_->dot(&vec_s, &vec_s, memspace_); - rnorm = std::sqrt(rnorm); // rnorm = ||V_1|| - bnorm = std::sqrt(bnorm); + rnorm = std::sqrt(rnorm); io::Logger::misc() << "it 0: norm of residual " << std::scientific << std::setprecision(16) << rnorm << " Norm of rhs: " << bnorm << "\n"; - initial_residual_norm_ = rnorm; + initial_residual_norm_ = bnorm; + + // Checking if rnorm > norm of RHS + rhsnorm = vector_handler_->dot(rhs, rhs, memspace_); + rhsnorm = std::sqrt(rhsnorm); + + if (bnorm > rhsnorm) + { + std::cout << "Initial guess is invalid. Quitting iterative refinement" << std::endl; + initial_residual_norm_ = bnorm; + final_residual_norm_ = bnorm; // Set final norm to initial norm as no work was done. + total_iters_ = 0; + return 0; + } + while (outer_flag) { if (it == 0) @@ -210,6 +238,7 @@ namespace ReSolve if (exit_cond) { outer_flag = 0; + update_flag = 1; final_residual_norm_ = rnorm; initial_residual_norm_ = rnorm; total_iters_ = 0; @@ -333,13 +362,13 @@ namespace ReSolve h_rs_[k] = t / h_H_[k * (restart_ + 1) + k]; } - // get solution + // get update if (flexible_) { for (j = 0; j <= i; j++) { vec_z.setData(vec_Z_->getData(j, memspace_), memspace_); - vector_handler_->axpy(&h_rs_[j], &vec_z, x, memspace_); + vector_handler_->axpy(&h_rs_[j], &vec_z, vec_Y_, memspace_); } } else @@ -355,18 +384,18 @@ namespace ReSolve vec_v.setData(vec_V_->getData(memspace_), memspace_); this->precV(&vec_z, &vec_v); - // and add to x - vector_handler_->axpy(&ONE, &vec_v, x, memspace_); + // and add to update + vector_handler_->axpy(&ONE, &vec_v, vec_Y_, memspace_); } - /* test solution */ + /* test update */ if (rnorm <= tolrel || it >= maxit_) { outer_flag = 0; } - rhs->copyDataTo(vec_V_->getData(memspace_), 0, memspace_); - matrix_handler_->matvec(A_, x, vec_V_, &MINUS_ONE, &ONE, memspace_); + vec_R_->copyDataTo(vec_V_->getData(memspace_), 0, memspace_); + matrix_handler_->matvec(A_, vec_Y_, vec_V_, &MINUS_ONE, &ONE, memspace_); if (outer_flag) { @@ -403,6 +432,36 @@ namespace ReSolve total_iters_ = it; } } // outer while + + if (update_flag) + { + t = bnorm; + vector_handler_->scal(&t, vec_Y_, memspace_); + vector_handler_->axpy(&ONE, x, vec_Y_, memspace_); + vec_R_->copyDataFrom(rhs, memspace_, memspace_); + matrix_handler_->matvec(A_, vec_Y_, vec_R_, &MINUS_ONE, &ONE, memspace_); + final_residual_norm_ = vector_handler_->dot(vec_R_, vec_R_, memspace_); + final_residual_norm_ = std::sqrt(final_residual_norm_); + + // Compare this with initial and update x accordingly + if (final_residual_norm_ < initial_residual_norm_) + { + std::cout << "Update to intial guess is successful, final residual (solution plus update) " + << std::scientific << std::setprecision(16) + << final_residual_norm_ / rhsnorm << "\n"; + + x->copyDataFrom(vec_Y_, memspace_, memspace_); + } + else + { + std::cout << "Update to intial guess is not successful, final residual greater than initial residual " + << std::scientific << std::setprecision(16) + << final_residual_norm_ / rhsnorm << "\n"; + + final_residual_norm_ = initial_residual_norm_; + } + } + return 0; } @@ -680,6 +739,11 @@ namespace ReSolve { vec_V_ = new vector_type(n_, restart_ + 1); vec_V_->allocate(memspace_); + vec_Y_ = new vector_type(n_); + vec_Y_->allocate(memspace_); + vec_R_ = new vector_type(n_); + vec_R_->allocate(memspace_); + if (flexible_) { vec_Z_ = new vector_type(n_, restart_ + 1); @@ -710,6 +774,8 @@ namespace ReSolve delete[] h_rs_; delete vec_V_; delete vec_Z_; + delete vec_Y_; + delete vec_R_; delete vec_aux_; h_H_ = nullptr; @@ -719,6 +785,8 @@ namespace ReSolve vec_V_ = nullptr; vec_Z_ = nullptr; vec_aux_ = nullptr; + vec_Y_ = nullptr; + vec_R_ = nullptr; is_solver_set_ = false; return 0; diff --git a/resolve/LinSolverIterativeRandFGMRES.hpp b/resolve/LinSolverIterativeRandFGMRES.hpp index c16f7711..fd5e24a0 100644 --- a/resolve/LinSolverIterativeRandFGMRES.hpp +++ b/resolve/LinSolverIterativeRandFGMRES.hpp @@ -116,6 +116,8 @@ namespace ReSolve vector_type* vec_Z_{nullptr}; // for performing Gram-Schmidt vector_type* vec_S_{nullptr}; ///< this is where sketched vectors are stored + vector_type* vec_Y_{nullptr}; + vector_type* vec_R_{nullptr}; real_type* h_H_{nullptr}; real_type* h_c_{nullptr}; diff --git a/tests/functionality/._CMakeLists.txt b/tests/functionality/._CMakeLists.txt new file mode 100755 index 00000000..db89664f Binary files /dev/null and b/tests/functionality/._CMakeLists.txt differ diff --git a/tests/functionality/._testRandGmres.cpp b/tests/functionality/._testRandGmres.cpp new file mode 100755 index 00000000..9df76d8f Binary files /dev/null and b/tests/functionality/._testRandGmres.cpp differ diff --git a/tests/functionality/._testSysGmres.cpp b/tests/functionality/._testSysGmres.cpp new file mode 100755 index 00000000..722d157a Binary files /dev/null and b/tests/functionality/._testSysGmres.cpp differ diff --git a/tests/functionality/CMakeLists.txt b/tests/functionality/CMakeLists.txt index b4722558..ab8c2413 100644 --- a/tests/functionality/CMakeLists.txt +++ b/tests/functionality/CMakeLists.txt @@ -7,7 +7,7 @@ ]] # Build basic version test -add_executable(version.exe testVersion.cpp) +add_executable(version.exe testVersion.cpp) target_link_libraries(version.exe PRIVATE ReSolve) # Build test for Krylov solvers @@ -44,7 +44,6 @@ if(RESOLVE_USE_LUSOL) target_link_libraries(lusol_test.exe PRIVATE ReSolve) endif() - # Install tests set(installable_tests version.exe) list(APPEND installable_tests rand_gmres_test.exe) @@ -53,8 +52,7 @@ list(APPEND installable_tests sys_rand_gmres_test.exe) if(RESOLVE_USE_KLU) list(APPEND installable_tests klu_klu_test.exe) if(RESOLVE_USE_GPU) - list(APPEND installable_tests klu_rf_test.exe - sys_refactor_test.exe) + list(APPEND installable_tests klu_rf_test.exe sys_refactor_test.exe) endif(RESOLVE_USE_GPU) if(RESOLVE_USE_CUDA) @@ -66,8 +64,9 @@ if(RESOLVE_USE_LUSOL) list(APPEND installable_tests lusol_test.exe) endif() -install(TARGETS ${installable_tests} - RUNTIME DESTINATION bin/resolve/tests/functionality) +install(TARGETS ${installable_tests} + RUNTIME DESTINATION bin/resolve/tests/functionality +) # Install directory with data files install(DIRECTORY data DESTINATION bin/resolve/tests/functionality) @@ -79,67 +78,189 @@ set(sym_rhs_path /data/rhs_ACTIVSg200_AC_renumbered_add9_ones_) set(asym_matrix_path /data/A_asymmetric) set(asym_rhs_path /data/b_asymmetric) - add_test(NAME version COMMAND $) if(RESOLVE_USE_LUSOL) - add_test(NAME lusol_test COMMAND $ "${test_data_dir}") + add_test(NAME lusol_test COMMAND $ + "${test_data_dir}" + ) endif() # Krylov solvers tests (FGMRES) -add_test(NAME sys_rand_count_fgmres_cgs2_test COMMAND $ "-i" "randgmres" "-g" "cgs2" "-s" "count") -add_test(NAME sys_rand_count_fgmres_mgs_test COMMAND $ "-i" "randgmres" "-g" "mgs" "-s" "count") -add_test(NAME sys_rand_count_fgmres_mgs2sync_test COMMAND $ "-i" "randgmres" "-g" "mgs_two_sync" "-s" "count") -add_test(NAME sys_rand_count_fgmres_mgspm_test COMMAND $ "-i" "randgmres" "-g" "mgs_pm" "-s" "count") -add_test(NAME sys_rand_fwht_fgmres_cgs2_test COMMAND $ "-i" "randgmres" "-g" "cgs2" "-s" "fwht") -add_test(NAME sys_rand_fwht_fgmres_mgs_test COMMAND $ "-i" "randgmres" "-g" "mgs" "-s" "fwht") -add_test(NAME sys_rand_fwht_fgmres_mgs2sync_test COMMAND $ "-i" "randgmres" "-g" "mgs_two_sync" "-s" "fwht") -add_test(NAME sys_rand_fwht_fgmres_mgspm_test COMMAND $ "-i" "randgmres" "-g" "mgs_pm" "-s" "fwht") -add_test(NAME sys_fgmres_cgs2_test COMMAND $ "-i" "fgmres" "-g" "cgs2") -add_test(NAME sys_fgmres_mgs_test COMMAND $ "-i" "fgmres" "-g" "mgs") -add_test(NAME sys_fgmres_mgs2sync_test COMMAND $ "-i" "fgmres" "-g" "mgs_two_sync") -add_test(NAME sys_fgmres_mgspm_test COMMAND $ "-i" "fgmres" "-g" "mgs_pm") +add_test(NAME sys_rand_count_fgmres_cgs2_test + COMMAND $ "-i" "randgmres" "-g" + "cgs2" "-s" "count" +) +add_test(NAME sys_rand_count_fgmres_mgs_test + COMMAND $ "-i" "randgmres" "-g" + "mgs" "-s" "count" +) +add_test(NAME sys_rand_count_fgmres_mgs2sync_test + COMMAND $ "-i" "randgmres" "-g" + "mgs_two_sync" "-s" "count" +) +add_test(NAME sys_rand_count_fgmres_mgspm_test + COMMAND $ "-i" "randgmres" "-g" + "mgs_pm" "-s" "count" +) +add_test(NAME sys_rand_fwht_fgmres_cgs2_test + COMMAND $ "-i" "randgmres" "-g" + "cgs2" "-s" "fwht" +) +add_test(NAME sys_rand_fwht_fgmres_mgs_test + COMMAND $ "-i" "randgmres" "-g" + "mgs" "-s" "fwht" +) +add_test(NAME sys_rand_fwht_fgmres_mgs2sync_test + COMMAND $ "-i" "randgmres" "-g" + "mgs_two_sync" "-s" "fwht" +) +add_test(NAME sys_rand_fwht_fgmres_mgspm_test + COMMAND $ "-i" "randgmres" "-g" + "mgs_pm" "-s" "fwht" +) +add_test(NAME sys_fgmres_cgs2_test + COMMAND $ "-i" "fgmres" "-g" + "cgs2" +) +add_test(NAME sys_fgmres_mgs_test COMMAND $ + "-i" "fgmres" "-g" "mgs" +) +add_test(NAME sys_fgmres_mgs2sync_test + COMMAND $ "-i" "fgmres" "-g" + "mgs_two_sync" +) +add_test(NAME sys_fgmres_mgspm_test + COMMAND $ "-i" "fgmres" "-g" + "mgs_pm" +) # Krylov solvers tests (GMRES) -add_test(NAME sys_rand_count_gmres_cgs2_test COMMAND $ "-x" "no" "-i" "randgmres" "-g" "cgs2" "-s" "count") -add_test(NAME sys_rand_count_gmres_mgs_test COMMAND $ "-x" "no" "-i" "randgmres" "-g" "mgs" "-s" "count") -add_test(NAME sys_rand_count_gmres_mgs2sync_test COMMAND $ "-x" "no" "-i" "randgmres" "-g" "mgs_two_sync" "-s" "count") -add_test(NAME sys_rand_count_gmres_mgspm_test COMMAND $ "-x" "no" "-i" "randgmres" "-g" "mgs_pm" "-s" "count") -add_test(NAME sys_rand_fwht_gmres_cgs2_test COMMAND $ "-x" "no" "-i" "randgmres" "-g" "cgs2" "-s" "fwht") -add_test(NAME sys_rand_fwht_gmres_mgs_test COMMAND $ "-x" "no" "-i" "randgmres" "-g" "mgs" "-s" "fwht") -add_test(NAME sys_rand_fwht_gmres_mgs2sync_test COMMAND $ "-x" "no" "-i" "randgmres" "-g" "mgs_two_sync" "-s" "fwht") -add_test(NAME sys_rand_fwht_gmres_mgspm_test COMMAND $ "-x" "no" "-i" "randgmres" "-g" "mgs_pm" "-s" "fwht") -add_test(NAME sys_gmres_cgs2_test COMMAND $ "-x" "no" "-i" "fgmres" "-g" "cgs2") -add_test(NAME sys_gmres_mgs_test COMMAND $ "-x" "no" "-i" "fgmres" "-g" "mgs") -add_test(NAME sys_gmres_mgs2sync_test COMMAND $ "-x" "no" "-i" "fgmres" "-g" "mgs_two_sync") -add_test(NAME sys_gmres_mgspm_test COMMAND $ "-x" "no" "-i" "fgmres" "-g" "mgs_pm") +add_test(NAME sys_rand_count_gmres_cgs2_test + COMMAND $ "-x" "no" "-i" + "randgmres" "-g" "cgs2" "-s" "count" +) +add_test(NAME sys_rand_count_gmres_mgs_test + COMMAND $ "-x" "no" "-i" + "randgmres" "-g" "mgs" "-s" "count" +) +add_test(NAME sys_rand_count_gmres_mgs2sync_test + COMMAND $ "-x" "no" "-i" + "randgmres" "-g" "mgs_two_sync" "-s" "count" +) +add_test(NAME sys_rand_count_gmres_mgspm_test + COMMAND $ "-x" "no" "-i" + "randgmres" "-g" "mgs_pm" "-s" "count" +) +add_test(NAME sys_rand_fwht_gmres_cgs2_test + COMMAND $ "-x" "no" "-i" + "randgmres" "-g" "cgs2" "-s" "fwht" +) +add_test(NAME sys_rand_fwht_gmres_mgs_test + COMMAND $ "-x" "no" "-i" + "randgmres" "-g" "mgs" "-s" "fwht" +) +add_test(NAME sys_rand_fwht_gmres_mgs2sync_test + COMMAND $ "-x" "no" "-i" + "randgmres" "-g" "mgs_two_sync" "-s" "fwht" +) +add_test(NAME sys_rand_fwht_gmres_mgspm_test + COMMAND $ "-x" "no" "-i" + "randgmres" "-g" "mgs_pm" "-s" "fwht" +) +add_test(NAME sys_gmres_cgs2_test COMMAND $ + "-x" "no" "-i" "fgmres" "-g" "cgs2" +) +add_test(NAME sys_gmres_mgs_test COMMAND $ + "-x" "no" "-i" "fgmres" "-g" "mgs" +) +add_test(NAME sys_gmres_mgs2sync_test + COMMAND $ "-x" "no" "-i" "fgmres" + "-g" "mgs_two_sync" +) +add_test(NAME sys_gmres_mgspm_test + COMMAND $ "-x" "no" "-i" "fgmres" + "-g" "mgs_pm" +) # Randomized GMRES solvers tested without SystemSolver class -add_test(NAME rand_gmres_test COMMAND $) +add_test(NAME rand_gmres_test COMMAND $) if(RESOLVE_USE_KLU) # Using KLU as refactorization solver - add_test(NAME klu_klu_test COMMAND $ "-d" "${test_data_dir}" "-m" "${sym_matrix_path}" "-r" "${sym_rhs_path}") - add_test(NAME klu_klu_ir_test COMMAND $ "-d" "${test_data_dir}" "-m" "${sym_matrix_path}" "-r" "${sym_rhs_path}" "-i") - add_test(NAME klu_klu_asym_test COMMAND $ "-d" "${test_data_dir}" "-m" "${asym_matrix_path}" "-r" "${asym_rhs_path}") - add_test(NAME klu_klu_asym_ir_test COMMAND $ "-d" "${test_data_dir}" "-m" "${asym_matrix_path}" "-r" "${asym_rhs_path}" "-i") + add_test(NAME klu_klu_test + COMMAND $ "-d" "${test_data_dir}" "-m" + "${sym_matrix_path}" "-r" "${sym_rhs_path}" + ) + add_test(NAME klu_klu_ir_test + COMMAND $ "-d" "${test_data_dir}" "-m" + "${sym_matrix_path}" "-r" "${sym_rhs_path}" "-i" + ) + add_test(NAME klu_klu_asym_test + COMMAND $ "-d" "${test_data_dir}" "-m" + "${asym_matrix_path}" "-r" "${asym_rhs_path}" + ) + add_test(NAME klu_klu_asym_ir_test + COMMAND $ "-d" "${test_data_dir}" "-m" + "${asym_matrix_path}" "-r" "${asym_rhs_path}" "-i" + ) # CUDA-SDK specific tests if(RESOLVE_USE_CUDA) - add_test(NAME klu_rf_cuda_test COMMAND $ "-d" "${test_data_dir}") - add_test(NAME klu_rf_ir_cuda_test COMMAND $ "-d" "${test_data_dir}" "-i") - add_test(NAME klu_glu_cuda_test COMMAND $ "-d" "${test_data_dir}" "-s" "glu") - add_test(NAME sys_refactor_cuda_test COMMAND $ "${test_data_dir}" "-d" "${test_data_dir}" "-m" "${sym_matrix_path}" "-r" "${sym_rhs_path}") - add_test(NAME sys_refactor_cuda_asym_test COMMAND $ "${test_data_dir}" "-d" "${test_data_dir}" "-m" "${asym_matrix_path}" "-r" "${asym_rhs_path}") - add_test(NAME sys_glu_test COMMAND $ "${test_data_dir}" "-d" "${test_data_dir}" "-m" "${sym_matrix_path}" "-r" "${sym_rhs_path}") - add_test(NAME sys_glu_asym_test COMMAND $ "${test_data_dir}" "-d" "${test_data_dir}" "-m" "${asym_matrix_path}" "-r" "${asym_rhs_path}") + add_test(NAME klu_rf_cuda_test COMMAND $ "-d" + "${test_data_dir}" + ) + add_test(NAME klu_rf_ir_cuda_test COMMAND $ + "-d" "${test_data_dir}" "-i" + ) + add_test(NAME klu_glu_cuda_test COMMAND $ "-d" + "${test_data_dir}" "-s" "glu" + ) + add_test( + NAME sys_refactor_cuda_test + COMMAND + $ "${test_data_dir}" "-d" + "${test_data_dir}" "-m" "${sym_matrix_path}" "-r" "${sym_rhs_path}" + ) + add_test( + NAME sys_refactor_cuda_asym_test + COMMAND + $ "${test_data_dir}" "-d" + "${test_data_dir}" "-m" "${asym_matrix_path}" "-r" "${asym_rhs_path}" + ) + add_test( + NAME sys_glu_test + COMMAND + $ "${test_data_dir}" "-d" + "${test_data_dir}" "-m" "${sym_matrix_path}" "-r" "${sym_rhs_path}" + ) + add_test( + NAME sys_glu_asym_test + COMMAND + $ "${test_data_dir}" "-d" + "${test_data_dir}" "-m" "${asym_matrix_path}" "-r" "${asym_rhs_path}" + ) endif(RESOLVE_USE_CUDA) # ROCm specific tests if(RESOLVE_USE_HIP) - add_test(NAME rocsolver_rf_test COMMAND $ "-d" "${test_data_dir}") - add_test(NAME rocsolver_rf_ir_test COMMAND $ "-d" "${test_data_dir}" "-i") - add_test(NAME sys_refactor_hip_test COMMAND $ "${test_data_dir}" "-d" "${test_data_dir}" "-m" "${sym_matrix_path}" "-r" "${sym_rhs_path}") - add_test(NAME sys_refactor_hip_asym_test COMMAND $ "${test_data_dir}" "-d" "${test_data_dir}" "-m" "${asym_matrix_path}" "-r" "${asym_rhs_path}") + add_test(NAME rocsolver_rf_test COMMAND $ "-d" + "${test_data_dir}" + ) + add_test(NAME rocsolver_rf_ir_test COMMAND $ + "-d" "${test_data_dir}" "-i" + ) + add_test( + NAME sys_refactor_hip_test + COMMAND + $ "${test_data_dir}" "-d" + "${test_data_dir}" "-m" "${sym_matrix_path}" "-r" "${sym_rhs_path}" + ) + add_test( + NAME sys_refactor_hip_asym_test + COMMAND + $ "${test_data_dir}" "-d" + "${test_data_dir}" "-m" "${asym_matrix_path}" "-r" "${asym_rhs_path}" + ) endif(RESOLVE_USE_HIP) endif(RESOLVE_USE_KLU)