Skip to content

Commit

Permalink
linear sum order update
Browse files Browse the repository at this point in the history
  • Loading branch information
maggul committed Feb 3, 2025
1 parent 0725fdb commit e477552
Show file tree
Hide file tree
Showing 67 changed files with 116 additions and 116 deletions.
2 changes: 1 addition & 1 deletion benchmarks/advection_reaction_3D/kokkos/rhs3D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ static int AdvectionReactionResidual(sunrealtype t, N_Vector y, N_Vector ydot,
if (check_retval((void*)&retval, "Reaction", 1, udata->myid)) { return (-1); }

/* F = ydot - h(t,y) = ydot + c y_x - g(t,y) */
N_VLinearSum(1.0, ydot, -1.0, F, F);
N_VLinearSum(-1.0, F, 1.0, ydot, F);

/* return success */
return (0);
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/advection_reaction_3D/raja/rhs3D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ static int AdvectionReactionResidual(sunrealtype t, N_Vector y, N_Vector ydot,
if (check_retval((void*)&retval, "Reaction", 1, udata->myid)) { return (-1); }

/* F = ydot - h(t,y) = ydot + c y_x - g(t,y) */
N_VLinearSum(1.0, ydot, -1.0, F, F);
N_VLinearSum(-1.0, F, 1.0, ydot, F);

/* return success */
return (0);
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/diffusion_2D/diffusion_2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int diffusion(sunrealtype t, N_Vector u, N_Vector up, N_Vector res,
if (check_flag(&flag, "laplacian", 1)) return -1;

// Compute the residual
N_VLinearSum(ONE, up, -ONE, res, res);
N_VLinearSum(-ONE, res, ONE, up, res);

return 0;
}
Expand Down Expand Up @@ -893,7 +893,7 @@ int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata)
if (flag != 0) { return -1; }

// Compute absolute error
N_VLinearSum(ONE, u, -ONE, e, e);
N_VLinearSum(-ONE, e, ONE, u, e);
N_VAbs(e, e);

return 0;
Expand Down
12 changes: 6 additions & 6 deletions benchmarks/nvector/test_nvector_performance.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int Test_N_VLinearSum(N_Vector X, sunindextype local_length, int ntests)

ClearCache();
start_time = get_time();
N_VLinearSum(ONE, X, ONE, Y, Y);
N_VLinearSum(ONE, Y, ONE, X, Y);
sync_device(X);
stop_time = get_time();

Expand All @@ -114,7 +114,7 @@ int Test_N_VLinearSum(N_Vector X, sunindextype local_length, int ntests)

ClearCache();
start_time = get_time();
N_VLinearSum(NEG_ONE, X, ONE, Y, Y);
N_VLinearSum(ONE, Y, NEG_ONE, X, Y);
sync_device(X);
stop_time = get_time();

Expand All @@ -138,7 +138,7 @@ int Test_N_VLinearSum(N_Vector X, sunindextype local_length, int ntests)

ClearCache();
start_time = get_time();
N_VLinearSum(a, X, ONE, Y, Y);
N_VLinearSum(ONE, Y, a, X, Y);
sync_device(X);
stop_time = get_time();

Expand Down Expand Up @@ -1573,7 +1573,7 @@ int Test_N_VScaleAddMulti(N_Vector X, sunindextype local_length, int nvecs,
{
ClearCache();
start_time = get_time();
for (j = 0; j < nvecs; j++) { N_VLinearSum(c[j], X, ONE, Y[j], Y[j]); }
for (j = 0; j < nvecs; j++) { N_VLinearSum(ONE, Y[j], c[j], X, Y[j]); }
sync_device(X);
stop_time = get_time();

Expand Down Expand Up @@ -2270,7 +2270,7 @@ int Test_N_VScaleAddMultiVectorArray(N_Vector V, sunindextype local_length,
{
for (j = 0; j < nsums; j++)
{
N_VLinearSum(c[j], X[k], ONE, Y[j][k], Y[j][k]);
N_VLinearSum(ONE, Y[j][k], c[j], X[k], Y[j][k]);
}
}
sync_device(V);
Expand Down Expand Up @@ -2344,7 +2344,7 @@ int Test_N_VScaleAddMultiVectorArray(N_Vector V, sunindextype local_length,
{
for (j = 0; j < nsums; j++)
{
N_VLinearSum(c[j], X[k], ONE, Y[j][k], Z[j][k]);
N_VLinearSum(ONE, Y[j][k], c[j], X[k], Z[j][k]);
}
}
sync_device(V);
Expand Down
2 changes: 1 addition & 1 deletion doc/shared/nvectors/NVector_Operations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ operations below.
.. math::
z_i = a x_i + b y_i, \quad i=0,\ldots,n-1.
The output vector *z* can be the same as either of the input vectors (*x* or *y*).
The output vector *z* can be the same as the input vector (*x*).
Usage:
Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/CXX_parallel/ark_heat2D_lsrk_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata)
if (flag != 0) { return -1; }

// Compute absolute error
N_VLinearSum(ONE, u, -ONE, e, e);
N_VLinearSum(-ONE, e, ONE, u, e);
N_VAbs(e, e);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/CXX_parallel/ark_heat2D_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata)
if (flag != 0) { return -1; }

// Compute absolute error
N_VLinearSum(ONE, u, -ONE, e, e);
N_VLinearSum(-ONE, e, ONE, u, e);
N_VAbs(e, e);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/CXX_parhyp/ark_heat2D_hypre_ls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata)
if (flag != 0) { return -1; }

// Compute absolute error
N_VLinearSum(ONE, u, -ONE, e, e);
N_VLinearSum(-ONE, e, ONE, u, e);
N_VAbs(e, e);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/CXX_parhyp/ark_heat2D_hypre_pfmg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2457,7 +2457,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata)
if (flag != 0) { return -1; }

// Compute absolute error
N_VLinearSum(ONE, u, -ONE, e, e);
N_VLinearSum(-ONE, e, ONE, u, e);
N_VAbs(e, e);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/CXX_serial/ark_heat2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata)
if (flag != 0) { return -1; }

// Compute absolute error
N_VLinearSum(ONE, u, -ONE, e, e);
N_VLinearSum(-ONE, e, ONE, u, e);
N_VAbs(e, e);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/CXX_serial/ark_heat2D_lsrk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata)
if (flag != 0) { return -1; }

// Compute absolute error
N_VLinearSum(ONE, u, -ONE, e, e);
N_VLinearSum(-ONE, e, ONE, u, e);
N_VAbs(e, e);

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2771,7 +2771,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata)
if (flag != 0) { return -1; }

// Compute absolute error
N_VLinearSum(ONE, u, -ONE, e, e);
N_VLinearSum(-ONE, e, ONE, u, e);
N_VAbs(e, e);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/CXX_xbraid/ark_heat2D_p_xbraid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata)
if (flag != 0) { return -1; }

// Compute absolute error
N_VLinearSum(ONE, u, -ONE, e, e);
N_VLinearSum(-ONE, e, ONE, u, e);
N_VAbs(e, e);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/CXX_xbraid/ark_heat2D_xbraid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata)
if (flag != 0) { return -1; }

// Compute absolute error
N_VLinearSum(ONE, u, -ONE, e, e);
N_VLinearSum(-ONE, e, ONE, u, e);
N_VAbs(e, e);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/C_serial/ark_harmonic_symplectic.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ int main(int argc, char* argv[])
Solution(tret, y, solution, &udata);

/* Compute L2 error */
N_VLinearSum(SUN_RCONST(1.0), y, -SUN_RCONST(1.0), solution, solution);
N_VLinearSum(-SUN_RCONST(1.0), solution, SUN_RCONST(1.0), y, solution);
err = sqrt(N_VDotProd(solution, solution));

/* Output current integration status */
Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/C_serial/ark_onewaycouple_mri.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ static int ans(sunrealtype t, N_Vector ytrue, void* user_data)
static int err(N_Vector y, N_Vector ytrue, sunrealtype* e)
{
/* compute the error and store it in ytrue */
N_VLinearSum(SUN_RCONST(1.0), y, SUN_RCONST(-1.0), ytrue, ytrue);
N_VLinearSum(SUN_RCONST(-1.0), ytrue, SUN_RCONST(1.0), y, ytrue);

/* compute the max norm of the error */
*e = N_VMaxNorm(ytrue);
Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/C_serial/ark_robertson.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, sunrealtype at
N_VInv(ewt, ewt);

/* compute the solution error */
N_VLinearSum(ONE, y, -ONE, ref, ref);
N_VLinearSum(-ONE, ref, ONE, y, ref);
err = N_VWrmsNorm(ref, ewt);

/* is the solution within the tolerances? */
Expand Down
2 changes: 1 addition & 1 deletion examples/arkode/C_serial/ark_robertson_constraints.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, sunrealtype at
N_VInv(ewt, ewt);

/* compute the solution error */
N_VLinearSum(ONE, y, -ONE, ref, ref);
N_VLinearSum(-ONE, ref, ONE, y, ref);
err = N_VWrmsNorm(ref, ewt);

/* is the solution within the tolerances? */
Expand Down
2 changes: 1 addition & 1 deletion examples/cvode/CXX_parallel/cv_heat2D_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata)
if (flag != 0) { return -1; }

// Compute absolute error
N_VLinearSum(ONE, u, -ONE, e, e);
N_VLinearSum(-ONE, e, ONE, u, e);
N_VAbs(e, e);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/cvode/CXX_parhyp/cv_heat2D_hypre_ls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1784,7 +1784,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata)
if (flag != 0) { return -1; }

// Compute absolute error
N_VLinearSum(ONE, u, -ONE, e, e);
N_VLinearSum(-ONE, e, ONE, u, e);
N_VAbs(e, e);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/cvode/CXX_parhyp/cv_heat2D_hypre_pfmg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2296,7 +2296,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData* udata)
if (flag != 0) { return -1; }

// Compute absolute error
N_VLinearSum(ONE, u, -ONE, e, e);
N_VLinearSum(-ONE, e, ONE, u, e);
N_VAbs(e, e);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/cvode/CXX_serial/cv_heat2D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData& udata)
if (flag != 0) { return -1; }

// Compute absolute error
N_VLinearSum(ONE, u, -ONE, e, e);
N_VLinearSum(-ONE, e, ONE, u, e);
N_VAbs(e, e);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/cvode/ginkgo/cv_heat2D_ginkgo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static int SolutionError(sunrealtype t, N_Vector u, N_Vector e, UserData& udata)
if (flag != 0) { return -1; }

// Compute absolute error
N_VLinearSum(ONE, u, -ONE, e, e);
N_VLinearSum(-ONE, e, ONE, u, e);
N_VAbs(e, e);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/cvode/serial/cvParticle_dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ static int ComputeError(sunrealtype t, N_Vector y, N_Vector e, sunrealtype* ec,
/* solution error */
retval = ComputeSolution(t, e, udata);
if (check_retval(&retval, "ComputeSolution", 1)) { return (1); }
N_VLinearSum(ONE, y, -ONE, e, e);
N_VLinearSum(-ONE, e, ONE, y, e);

/* constraint error */
*ec = ydata[0] * ydata[0] + ydata[1] * ydata[1] - ONE;
Expand Down
2 changes: 1 addition & 1 deletion examples/cvode/serial/cvRoberts_dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, N_Vector atol)
N_VInv(ewt, ewt);

/* compute the solution error */
N_VLinearSum(ONE, y, -ONE, ref, ref);
N_VLinearSum(-ONE, ref, ONE, y, ref);
err = N_VWrmsNorm(ref, ewt);

/* is the solution within the tolerances? */
Expand Down
2 changes: 1 addition & 1 deletion examples/cvode/serial/cvRoberts_dns_constraints.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, N_Vector atol)
N_VInv(ewt, ewt);

/* compute the solution error */
N_VLinearSum(ONE, y, -ONE, ref, ref);
N_VLinearSum(-ONE, ref, ONE, y, ref);
err = N_VWrmsNorm(ref, ewt);

/* is the solution within the tolerances? */
Expand Down
2 changes: 1 addition & 1 deletion examples/cvodes/serial/cvsParticle_dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ static int ComputeError(sunrealtype t, N_Vector y, N_Vector e, sunrealtype* ec,
/* solution error */
retval = ComputeSolution(t, e, udata);
if (check_retval(&retval, "ComputeSolution", 1)) { return (1); }
N_VLinearSum(ONE, y, -ONE, e, e);
N_VLinearSum(-ONE, e, ONE, y, e);

/* constraint error */
*ec = ydata[0] * ydata[0] + ydata[1] * ydata[1] - ONE;
Expand Down
2 changes: 1 addition & 1 deletion examples/cvodes/serial/cvsRoberts_dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, N_Vector atol)
N_VInv(ewt, ewt);

/* compute the solution error */
N_VLinearSum(ONE, y, -ONE, ref, ref);
N_VLinearSum(-ONE, ref, ONE, y, ref);
err = N_VWrmsNorm(ref, ewt);

/* is the solution within the tolerances? */
Expand Down
2 changes: 1 addition & 1 deletion examples/cvodes/serial/cvsRoberts_dns_constraints.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, N_Vector atol)
N_VInv(ewt, ewt);

/* compute the solution error */
N_VLinearSum(ONE, y, -ONE, ref, ref);
N_VLinearSum(-ONE, ref, ONE, y, ref);
err = N_VWrmsNorm(ref, ewt);

/* is the solution within the tolerances? */
Expand Down
2 changes: 1 addition & 1 deletion examples/ida/serial/idaAnalytic_mels.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, sunrealtype at
N_VInv(ewt, ewt);

/* compute the solution error */
N_VLinearSum(ONE, y, -ONE, ytrue, ytrue);
N_VLinearSum(-ONE, ytrue, ONE, y, ytrue);
err = N_VWrmsNorm(ytrue, ewt);

/* is the solution within the tolerances? */
Expand Down
2 changes: 1 addition & 1 deletion examples/ida/serial/idaRoberts_dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, N_Vector atol)
N_VInv(ewt, ewt);

/* compute the solution error */
N_VLinearSum(ONE, y, -ONE, ref, ref);
N_VLinearSum(-ONE, ref, ONE, y, ref);
err = N_VWrmsNorm(ref, ewt);

/* is the solution within the tolerances? */
Expand Down
2 changes: 1 addition & 1 deletion examples/idas/serial/idasAnalytic_mels.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, sunrealtype at
N_VInv(ewt, ewt);

/* compute the solution error */
N_VLinearSum(ONE, y, -ONE, ytrue, ytrue);
N_VLinearSum(-ONE, ytrue, ONE, y, ytrue);
err = N_VWrmsNorm(ytrue, ewt);

/* is the solution within the tolerances? */
Expand Down
2 changes: 1 addition & 1 deletion examples/idas/serial/idasRoberts_dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ static int check_ans(N_Vector y, sunrealtype t, sunrealtype rtol, N_Vector atol)
N_VInv(ewt, ewt);

/* compute the solution error */
N_VLinearSum(ONE, y, -ONE, ref, ref);
N_VLinearSum(-ONE, ref, ONE, y, ref);
err = N_VWrmsNorm(ref, ewt);

/* is the solution within the tolerances? */
Expand Down
10 changes: 5 additions & 5 deletions examples/kinsol/CXX_parallel/kin_heat2D_nonlin_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,13 +620,13 @@ static int FPFunction(N_Vector u, N_Vector f, void* user_data)
// Add c(u)
retval = c(u, udata->vtemp, user_data);
if (check_retval(&retval, "c(u)", 1)) { return 1; }
N_VLinearSum(ONE, udata->vtemp, ONE, f, f);
N_VLinearSum(ONE, f, ONE, udata->vtemp, f);

// Add u
N_VLinearSum(ONE, u, ONE, f, f);
N_VLinearSum(ONE, f, ONE, u, f);

// Subtract b
N_VLinearSum(-ONE, udata->b, ONE, f, f);
N_VLinearSum(ONE, f, -ONE, udata->b, f);

// Stop timer
double t2 = MPI_Wtime();
Expand Down Expand Up @@ -746,7 +746,7 @@ static int SetupRHS(void* user_data)
if (check_retval(&retval, "c(u)", 1)) { return 1; }

// b = kx u_xx (u_exact) + ky u_yy (u_exact) + c(u_exact)
N_VLinearSum(ONE, udata->vtemp, ONE, udata->b, udata->b);
N_VLinearSum(ONE, udata->b, ONE, udata->vtemp, udata->b);

// Return success
return 0;
Expand Down Expand Up @@ -1284,7 +1284,7 @@ static int SolutionError(N_Vector u, N_Vector e, UserData* udata)
if (retval != 0) { return -1; }

// Compute absolute error
N_VLinearSum(ONE, u, -ONE, e, e);
N_VLinearSum(-ONE, e, ONE, u, e);
N_VAbs(e, e);

return 0;
Expand Down
Loading

0 comments on commit e477552

Please sign in to comment.