Skip to content

Commit

Permalink
Bugfix - Creating pcg parallel directory (#297)
Browse files Browse the repository at this point in the history
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 <[email protected]>
Co-authored-by: Balos, Cody, J <[email protected]>
Co-authored-by: David J. Gardner <[email protected]>
  • Loading branch information
4 people authored Jul 17, 2023
1 parent cd0d062 commit 3247363
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions examples/sunlinsol/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion examples/sunlinsol/pcg/parallel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions examples/sunlinsol/pcg/parallel/test_sunlinsol_pcg_parallel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions scripts/shared
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3247363

Please sign in to comment.