Skip to content

Commit

Permalink
CI: Update Compiler Warnings, Enable Warnings as Errors (#484)
Browse files Browse the repository at this point in the history
* Additional warning flags from #481, #482, and #483
* Remove `-Wno-deprecated-declarations`
* Enable warnings as errors in GitHub actions
  • Loading branch information
gardner48 authored May 20, 2024
1 parent 48bbc24 commit aee81f8
Show file tree
Hide file tree
Showing 71 changed files with 431 additions and 360 deletions.
36 changes: 23 additions & 13 deletions benchmarks/advection_reaction_3D/kokkos/ParallelGrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ class ParallelGrid
// [in] npxyz - the number of processors in each dimension; defaults to 0 which means MPI will choose
// [in] reorder - should MPI_Cart_create do process reordering to optimize or not; defaults to false (some MPI implementations ignore this)
ParallelGrid(MPI_Comm* comm, const sunrealtype a[], const sunrealtype b[],
const GLOBALINT npts[], int dof, BoundaryType bc, StencilType st,
const sunrealtype c, const int npxyz[] = nullptr,
bool reorder = false)
const GLOBALINT npts[], int dof_, BoundaryType bc_,
StencilType st_, const sunrealtype c,
const int npxyz[] = nullptr, bool reorder = false)
: nx(1),
ny(1),
nz(1),
Expand All @@ -103,12 +103,12 @@ class ParallelGrid
bx(0.0),
by(0.0),
bz(0.0),
dof(dof),
dof(dof_),
upwindRight(true),
dims{0, 0, 0},
coords{0, 0, 0},
bc(bc),
st(st),
upwindRight(true)
bc(bc_),
st(st_)
{
assert(st == StencilType::UPWIND);

Expand All @@ -121,6 +121,10 @@ class ParallelGrid
}

int retval, nprocs;
#ifdef NDEBUG
// Suppress unused variable warning
((void)retval);
#endif
MPI_Comm_size(*comm, &nprocs);
retval = MPI_Dims_create(nprocs, 3, dims);
assert(retval == MPI_SUCCESS);
Expand Down Expand Up @@ -181,6 +185,12 @@ class ParallelGrid
// For all faces: allocate upwind exchange buffers.
void AllocateBuffersUpwind()
{
int retval;
#ifdef NDEBUG
// Suppress unused variable warning
((void)retval);
#endif

/* Allocate send/receive buffers and determine ID for communication West */
if (upwindRight)
{
Expand All @@ -196,7 +206,7 @@ class ParallelGrid
if ((coords[0] > 0) || (bc == BoundaryType::PERIODIC))
{
int nbcoords[] = {coords[0] - 1, coords[1], coords[2]};
int retval = MPI_Cart_rank(cart_comm, nbcoords, &ipW);
retval = MPI_Cart_rank(cart_comm, nbcoords, &ipW);
assert(retval == MPI_SUCCESS);
}

Expand All @@ -215,7 +225,7 @@ class ParallelGrid
if ((coords[0] < dims[0] - 1) || (bc == BoundaryType::PERIODIC))
{
int nbcoords[] = {coords[0] + 1, coords[1], coords[2]};
int retval = MPI_Cart_rank(cart_comm, nbcoords, &ipE);
retval = MPI_Cart_rank(cart_comm, nbcoords, &ipE);
assert(retval == MPI_SUCCESS);
}

Expand All @@ -234,7 +244,7 @@ class ParallelGrid
if ((coords[1] > 0) || (bc == BoundaryType::PERIODIC))
{
int nbcoords[] = {coords[0], coords[1] - 1, coords[2]};
int retval = MPI_Cart_rank(cart_comm, nbcoords, &ipS);
retval = MPI_Cart_rank(cart_comm, nbcoords, &ipS);
assert(retval == MPI_SUCCESS);
}

Expand All @@ -253,7 +263,7 @@ class ParallelGrid
if ((coords[1] < dims[1] - 1) || (bc == BoundaryType::PERIODIC))
{
int nbcoords[] = {coords[0], coords[1] + 1, coords[2]};
int retval = MPI_Cart_rank(cart_comm, nbcoords, &ipN);
retval = MPI_Cart_rank(cart_comm, nbcoords, &ipN);
assert(retval == MPI_SUCCESS);
}

Expand All @@ -272,7 +282,7 @@ class ParallelGrid
if ((coords[2] > 0) || (bc == BoundaryType::PERIODIC))
{
int nbcoords[] = {coords[0], coords[1], coords[2] - 1};
int retval = MPI_Cart_rank(cart_comm, nbcoords, &ipB);
retval = MPI_Cart_rank(cart_comm, nbcoords, &ipB);
assert(retval == MPI_SUCCESS);
}

Expand All @@ -291,7 +301,7 @@ class ParallelGrid
if ((coords[2] < dims[2] - 1) || (bc == BoundaryType::PERIODIC))
{
int nbcoords[] = {coords[0], coords[1], coords[2] + 1};
int retval = MPI_Cart_rank(cart_comm, nbcoords, &ipF);
retval = MPI_Cart_rank(cart_comm, nbcoords, &ipF);
assert(retval == MPI_SUCCESS);
}
}
Expand Down
25 changes: 13 additions & 12 deletions benchmarks/advection_reaction_3D/kokkos/advection_reaction_3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int main(int argc, char* argv[])
if (udata.myid == 0 && uopt.nout > 0)
{
char fname[MXSTR];
snprintf(fname, MXSTR, "%s/mesh.txt", uopt.outputdir);
snprintf(fname, MXSTR, "%s/mesh.txt", uopt.outputdir.c_str());
udata.grid->MeshToFile(fname);
}

Expand Down Expand Up @@ -259,7 +259,7 @@ int FillSendBuffers(N_Vector y, UserData* udata)
* --------------------------------------------------------------*/

/* Parses the CLI arguments */
int ParseArgs(int argc, char* argv[], UserData* udata, UserOptions* uopt)
static int ParseArgs(int argc, char* argv[], UserData* udata, UserOptions* uopt)
{
/* check for input args */
if (argc > 1)
Expand Down Expand Up @@ -449,7 +449,7 @@ int SetupProblem(int argc, char* argv[], UserData* udata, UserOptions* uopt,
uopt->fused = 0; /* use fused vector ops */
uopt->save = 1; /* save solution to disk */
uopt->nout = 10; /* number of output times */
uopt->outputdir = (char*)"."; /* output directory */
uopt->outputdir = "."; /* output directory */

/* Parse CLI args and set udata/uopt appropriately */
int retval = ParseArgs(argc, argv, udata, uopt);
Expand Down Expand Up @@ -493,17 +493,17 @@ int SetupProblem(int argc, char* argv[], UserData* udata, UserOptions* uopt,
char fname[MXSTR];
if (udata->myid == 0)
{
sprintf(fname, "%s/t.%06d.txt", uopt->outputdir, udata->myid);
sprintf(fname, "%s/t.%06d.txt", uopt->outputdir.c_str(), udata->myid);
udata->TFID = fopen(fname, "w");
}

sprintf(fname, "%s/u.%06d.txt", uopt->outputdir, udata->myid);
sprintf(fname, "%s/u.%06d.txt", uopt->outputdir.c_str(), udata->myid);
udata->UFID = fopen(fname, "w");

sprintf(fname, "%s/v.%06d.txt", uopt->outputdir, udata->myid);
sprintf(fname, "%s/v.%06d.txt", uopt->outputdir.c_str(), udata->myid);
udata->VFID = fopen(fname, "w");

sprintf(fname, "%s/w.%06d.txt", uopt->outputdir, udata->myid);
sprintf(fname, "%s/w.%06d.txt", uopt->outputdir.c_str(), udata->myid);
udata->WFID = fopen(fname, "w");
}

Expand Down Expand Up @@ -540,7 +540,7 @@ int SetupProblem(int argc, char* argv[], UserData* udata, UserOptions* uopt,
printf(" reltol = %.1e\n", uopt->rtol);
printf(" abstol = %.1e\n", uopt->atol);
printf(" nout = %d\n", uopt->nout);
printf("Output directory: %s\n", uopt->outputdir);
printf("Output directory: %s\n", uopt->outputdir.c_str());
}

/* return success */
Expand All @@ -549,7 +549,8 @@ int SetupProblem(int argc, char* argv[], UserData* udata, UserOptions* uopt,

/* Compute the 3D Gaussian function. */
KOKKOS_FUNCTION
void Gaussian3D(sunrealtype& x, sunrealtype& y, sunrealtype& z, sunrealtype xmax)
static void Gaussian3D(sunrealtype& x, sunrealtype& y, sunrealtype& z,
sunrealtype xmax)
{
/* Gaussian distribution defaults */
const sunrealtype alpha = 0.1;
Expand All @@ -567,7 +568,7 @@ void Gaussian3D(sunrealtype& x, sunrealtype& y, sunrealtype& z, sunrealtype xmax
}

/* Initial condition function */
int SetIC(N_Vector y, UserData* udata)
int SetIC(N_Vector yvec, UserData* udata)
{
SUNDIALS_CXX_MARK_FUNCTION(udata->prof);

Expand Down Expand Up @@ -596,8 +597,8 @@ int SetIC(N_Vector y, UserData* udata)
const sunrealtype ws = 3.0;

/* Create 4D view of y */
Vec4D yview(N_VGetDeviceArrayPointer(N_VGetLocalVector_MPIPlusX(y)), nxl, nyl,
nzl, dof);
Vec4D yview(N_VGetDeviceArrayPointer(N_VGetLocalVector_MPIPlusX(yvec)), nxl,
nyl, nzl, dof);

/* Gaussian perturbation of the steady state solution */
Kokkos::parallel_for(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct UserOptions
int fused; /* use fused vector ops */
int nout; /* number of outputs */
int save; /* save solution to disk */
char* outputdir;
string outputdir;
};

/*
Expand Down Expand Up @@ -113,16 +113,16 @@ struct UserData
UserOptions* uopt;

/* Constructor that takes the context */
UserData(SUNContext ctx)
: ctx(ctx),
umask(nullptr),
vmask(nullptr),
wmask(nullptr),
uopt(nullptr),
UserData(SUNContext ctx_)
: ctx(ctx_),
TFID(nullptr),
UFID(nullptr),
VFID(nullptr),
WFID(nullptr)
WFID(nullptr),
umask(nullptr),
vmask(nullptr),
wmask(nullptr),
uopt(nullptr)
{
SUNContext_GetProfiler(ctx, &prof);
}
Expand Down
31 changes: 15 additions & 16 deletions benchmarks/advection_reaction_3D/kokkos/arkode_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ int EvolveProblemDIRK(N_Vector y, UserData* udata, UserOptions* uopt)
long int nfe, nfi; /* RHS stats */
long int nni, ncnf; /* nonlinear solver stats */
long int nli, npsol; /* linear solver stats */
char fname[MXSTR];

/* Additively split methods should not add the advection and reaction terms */
udata->add_reactions = true;
Expand Down Expand Up @@ -246,7 +245,6 @@ int EvolveProblemIMEX(N_Vector y, UserData* udata, UserOptions* uopt)
long int nfe, nfi; /* RHS stats */
long int nni, ncnf; /* nonlinear solver stats */
long int nli, npsol; /* linear solver stats */
char fname[MXSTR];

/* Additively split methods should not add the advection and reaction terms */
udata->add_reactions = false;
Expand Down Expand Up @@ -445,7 +443,6 @@ int EvolveProblemExplicit(N_Vector y, UserData* udata, UserOptions* uopt)
int iout; /* output counter */
long int nst, nst_a, netf; /* step stats */
long int nfe; /* RHS stats */
char fname[MXSTR];

/* Additively split methods should not add the advection and reaction terms */
udata->add_reactions = true;
Expand Down Expand Up @@ -544,7 +541,7 @@ int EvolveProblemExplicit(N_Vector y, UserData* udata, UserOptions* uopt)
* (Non)linear system functions
* --------------------------------------------------------------*/

int TaskLocalNlsResidual(N_Vector ycor, N_Vector F, void* arkode_mem)
static int TaskLocalNlsResidual(N_Vector ycor, N_Vector F, void* arkode_mem)
{
/* temporary variables */
UserData* udata;
Expand Down Expand Up @@ -586,7 +583,7 @@ int TaskLocalNlsResidual(N_Vector ycor, N_Vector F, void* arkode_mem)
return (0);
}

int TaskLocalLSolve(N_Vector delta, void* arkode_mem)
static int TaskLocalLSolve(N_Vector delta, void* arkode_mem)
{
/* local variables */
UserData* udata = NULL;
Expand All @@ -609,12 +606,12 @@ int TaskLocalLSolve(N_Vector delta, void* arkode_mem)
return (retval);
}

SUNNonlinearSolver_Type TaskLocalNewton_GetType(SUNNonlinearSolver NLS)
static SUNNonlinearSolver_Type TaskLocalNewton_GetType(SUNNonlinearSolver NLS)
{
return SUNNONLINEARSOLVER_ROOTFIND;
}

int TaskLocalNewton_Initialize(SUNNonlinearSolver NLS)
static int TaskLocalNewton_Initialize(SUNNonlinearSolver NLS)
{
/* check that the nonlinear solver is non-null */
if (NLS == NULL) { return SUN_ERR_ARG_CORRUPT; }
Expand All @@ -626,9 +623,9 @@ int TaskLocalNewton_Initialize(SUNNonlinearSolver NLS)
return (SUNNonlinSolInitialize(LOCAL_NLS(NLS)));
}

int TaskLocalNewton_Solve(SUNNonlinearSolver NLS, N_Vector y0, N_Vector ycor,
N_Vector w, sunrealtype tol,
sunbooleantype callLSetup, void* mem)
static int TaskLocalNewton_Solve(SUNNonlinearSolver NLS, N_Vector y0,
N_Vector ycor, N_Vector w, sunrealtype tol,
sunbooleantype callLSetup, void* mem)
{
/* local variables */
MPI_Comm comm;
Expand Down Expand Up @@ -662,7 +659,7 @@ int TaskLocalNewton_Solve(SUNNonlinearSolver NLS, N_Vector y0, N_Vector ycor,
return recover;
}

int TaskLocalNewton_Free(SUNNonlinearSolver NLS)
static int TaskLocalNewton_Free(SUNNonlinearSolver NLS)
{
/* return if NLS is already free */
if (NLS == NULL) { return SUN_SUCCESS; }
Expand All @@ -688,25 +685,27 @@ int TaskLocalNewton_Free(SUNNonlinearSolver NLS)
return SUN_SUCCESS;
}

int TaskLocalNewton_SetSysFn(SUNNonlinearSolver NLS, SUNNonlinSolSysFn SysFn)
static int TaskLocalNewton_SetSysFn(SUNNonlinearSolver NLS,
SUNNonlinSolSysFn SysFn)
{
/* check that the nonlinear solver is non-null */
if (NLS == NULL) { return SUN_ERR_ARG_CORRUPT; }

return (SUNNonlinSolSetSysFn(LOCAL_NLS(NLS), SysFn));
}

int TaskLocalNewton_SetConvTestFn(SUNNonlinearSolver NLS,
SUNNonlinSolConvTestFn CTestFn,
void* ctest_data)
static int TaskLocalNewton_SetConvTestFn(SUNNonlinearSolver NLS,
SUNNonlinSolConvTestFn CTestFn,
void* ctest_data)
{
/* check that the nonlinear solver is non-null */
if (NLS == NULL) { return SUN_ERR_ARG_CORRUPT; }

return (SUNNonlinSolSetConvTestFn(LOCAL_NLS(NLS), CTestFn, ctest_data));
}

int TaskLocalNewton_GetNumConvFails(SUNNonlinearSolver NLS, long int* nconvfails)
static int TaskLocalNewton_GetNumConvFails(SUNNonlinearSolver NLS,
long int* nconvfails)
{
/* check that the nonlinear solver is non-null */
if (NLS == NULL) { return SUN_ERR_ARG_CORRUPT; }
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/advection_reaction_3D/kokkos/ida_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "sunnonlinsol/sunnonlinsol_newton.h"

/* Initial condition function */
int SetICDot(N_Vector y, N_Vector yp, UserData* udata)
static int SetICDot(N_Vector y, N_Vector yp, UserData* udata)
{
int retval;

Expand Down
8 changes: 4 additions & 4 deletions benchmarks/diffusion_2D/diffusion_2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,8 @@ int UserOutput::open(UserData* udata)
int UserOutput::write(sunrealtype t, N_Vector u, UserData* udata)
{
int flag;
sunrealtype max;
bool outproc = (udata->myid_c == 0);
sunrealtype max = ZERO;
bool outproc = (udata->myid_c == 0);

if (output > 0)
{
Expand Down Expand Up @@ -900,7 +900,7 @@ int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata)
}

// Check function return value
int check_flag(void* flagvalue, const string funcname, int opt)
int check_flag(const void* flagvalue, const string funcname, int opt)
{
// Check if the function returned a NULL pointer
if (opt == 0)
Expand All @@ -916,7 +916,7 @@ int check_flag(void* flagvalue, const string funcname, int opt)
// Check the function return flag value
else if (opt == 1 || opt == 2)
{
int errflag = *((int*)flagvalue);
const int errflag = *((const int*)flagvalue);
if ((opt == 1 && errflag < 0) || (opt == 2 && errflag != 0))
{
cerr << endl
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/diffusion_2D/diffusion_2D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ struct UserData
// Inverse of Jacobian diagonal for preconditioner
N_Vector diag = NULL;

UserData(SUNProfiler prof) : prof(prof) {}
UserData(SUNProfiler prof_) : prof(prof_) {}

~UserData();

Expand Down Expand Up @@ -280,6 +280,6 @@ int SolutionDerivative(sunrealtype t, N_Vector up, UserData* udata);
int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata);

// Check function return values
int check_flag(void* flagvalue, const string funcname, int opt);
int check_flag(const void* flagvalue, const string funcname, int opt);

#endif
Loading

0 comments on commit aee81f8

Please sign in to comment.