From 3247363e60c7cd8de5a6db1c0482328bcf2d1821 Mon Sep 17 00:00:00 2001 From: Shahbaj Sohal <89656941+shahbajsohal@users.noreply.github.com> Date: Mon, 17 Jul 2023 16:28:12 -0700 Subject: [PATCH] Bugfix - Creating pcg parallel directory (#297) There was an error where even when MPI was enabled the `../examples/sunlinsol/pcg/parallel` directory was not being built because it was not being added as a subdirectory in `../examples/sunlinsol/CMakeLists.txt`. --------- Co-authored-by: shahbajsohal Co-authored-by: Balos, Cody, J Co-authored-by: David J. Gardner --- examples/sunlinsol/CMakeLists.txt | 1 + examples/sunlinsol/pcg/parallel/CMakeLists.txt | 11 ++++++++++- .../pcg/parallel/test_sunlinsol_pcg_parallel.c | 11 +++++------ scripts/shared | 4 ++-- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/examples/sunlinsol/CMakeLists.txt b/examples/sunlinsol/CMakeLists.txt index 3628997f36..e36b239234 100644 --- a/examples/sunlinsol/CMakeLists.txt +++ b/examples/sunlinsol/CMakeLists.txt @@ -39,6 +39,7 @@ endif() target_link_libraries(test_sunlinsol_obj PRIVATE sundials_sunlinsoldense) if(ENABLE_MPI AND MPI_C_FOUND) + add_subdirectory(pcg/parallel) add_subdirectory(spgmr/parallel) add_subdirectory(spfgmr/parallel) add_subdirectory(spbcgs/parallel) diff --git a/examples/sunlinsol/pcg/parallel/CMakeLists.txt b/examples/sunlinsol/pcg/parallel/CMakeLists.txt index e6a130c84d..8b298db30e 100644 --- a/examples/sunlinsol/pcg/parallel/CMakeLists.txt +++ b/examples/sunlinsol/pcg/parallel/CMakeLists.txt @@ -14,12 +14,21 @@ # CMakeLists.txt file for sunlinsol PCG examples # --------------------------------------------------------------- +# Set tolerance for linear solver test based on Sundials precision +if(SUNDIALS_PRECISION MATCHES "SINGLE") + set(TOL "1e-2") +elseif(SUNDIALS_PRECISION MATCHES "DOUBLE") + set(TOL "1e-10") +else() + set(TOL "1e-13") +endif() + # Example lists are tuples "name\;args\;nodes\;tasks\;type" where the # type is develop for examples excluded from 'make test' in releases # Examples using the SUNDIALS PCG linear solver set(sunlinsol_pcg_examples - "test_sunlinsol_pcg_parallel\;100 100 1e-3 0\;1\;4\;" + "test_sunlinsol_pcg_parallel\;100 200 ${TOL} 0\;1\;4\;" ) # Dependencies for nvector examples diff --git a/examples/sunlinsol/pcg/parallel/test_sunlinsol_pcg_parallel.c b/examples/sunlinsol/pcg/parallel/test_sunlinsol_pcg_parallel.c index 0963050fb7..644079a94d 100644 --- a/examples/sunlinsol/pcg/parallel/test_sunlinsol_pcg_parallel.c +++ b/examples/sunlinsol/pcg/parallel/test_sunlinsol_pcg_parallel.c @@ -103,7 +103,6 @@ int main(int argc, char *argv[]) { int fails=0; /* counter for test failures */ int passfail=0; /* overall passfail flag */ - int mpierr; /* mpi error flag */ SUNLinearSolver LS; /* linear solver object */ N_Vector xhat, x, b; /* test vectors */ UserData ProbData; /* problem data structure */ @@ -158,8 +157,8 @@ int main(int argc, char *argv[]) if (ProbData.myid == 0) { printf("\nPCG linear solver test:\n"); printf(" nprocs = %i\n", ProbData.nprocs); - printf(" local/global problem sizes = %ld/%ld\n", ProbData.Nloc, - ProbData.nprocs * ProbData.Nloc, sunctx); + printf(" local/global problem sizes = %ld/%ld\n", (long int) ProbData.Nloc, + (long int) ProbData.nprocs * ProbData.Nloc); printf(" Maximum Krylov subspace dimension = %i\n", maxl); printf(" Solver Tolerance = %g\n", tol); printf(" timing output flag = %i\n\n", print_timing); @@ -338,7 +337,7 @@ int main(int argc, char *argv[]) } /* check if any other process failed */ - mpierr = MPI_Allreduce(&passfail, &fails, 1, MPI_INT, MPI_MAX, ProbData.comm); + (void) MPI_Allreduce(&passfail, &fails, 1, MPI_INT, MPI_MAX, ProbData.comm); /* Free solver and vectors */ SUNLinSolFree(LS); @@ -489,8 +488,8 @@ static int check_flag(void *flagvalue, const char *funcname, int opt) * --------------------------------------------------------------------*/ int check_vector(N_Vector X, N_Vector Y, realtype tol) { - int failure = 0; - long int i; + int failure = 0; + sunindextype i; realtype *Xdata, *Ydata, maxerr; Xdata = N_VGetArrayPointer(X); diff --git a/scripts/shared b/scripts/shared index b9a7da6458..28ecda2d92 100755 --- a/scripts/shared +++ b/scripts/shared @@ -716,8 +716,8 @@ $tar $tarfile $distrobase/examples/sunlinsol/magmadense/CMakeLists.txt $tar $tarfile $distrobase/examples/sunlinsol/onemkldense/CMakeLists.txt $tar $tarfile $distrobase/examples/sunlinsol/onemkldense/test_sunlinsol_onemkldense.cpp -#$tar $tarfile $distrobase/examples/sunlinsol/pcg/parallel/test_sunlinsol_pcg_parallel.c -#$tar $tarfile $distrobase/examples/sunlinsol/pcg/parallel/CMakeLists.txt +$tar $tarfile $distrobase/examples/sunlinsol/pcg/parallel/test_sunlinsol_pcg_parallel.c +$tar $tarfile $distrobase/examples/sunlinsol/pcg/parallel/CMakeLists.txt $tar $tarfile $distrobase/examples/sunlinsol/pcg/serial/test_sunlinsol_pcg_serial.c $tar $tarfile $distrobase/examples/sunlinsol/pcg/serial/test_fsunlinsol_pcg_mod_serial.f90