Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solve_bicgstab: cut use of s #3629

Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
41f4a99
Initial commit. Possible improvements to BiCGSTAB and CG algorithms a…
eebasso Aug 31, 2023
75a0587
Possible improvements to MLCGSolver
eebasso Sep 5, 2023
235bddc
Possible improvements to linear solver algorithms
eebasso Sep 5, 2023
d390b17
Merge branch 'development' of https://github.com/AMReX-Codes/amrex in…
eebasso Sep 21, 2023
ef3fd02
Merge branch 'development' of https://github.com/AMReX-Codes/amrex in…
eebasso Sep 21, 2023
06d6c83
Merge branch 'bicgstab' of github.com:eebasso/amrex into bicgstab
eebasso Oct 6, 2023
2cd04e3
Moved rho == 0 check in solve_cg
eebasso Oct 6, 2023
a079351
Remove commented code
eebasso Oct 6, 2023
c8e6d6d
Removed unused omega in solve_cg
eebasso Oct 9, 2023
a4017cf
More fixes
eebasso Oct 9, 2023
babd315
Merge branch 'development' of https://github.com/AMReX-Codes/amrex in…
eebasso Oct 16, 2023
7961129
More minor fixes
eebasso Oct 16, 2023
4d1a6f0
Merge branch 'development' into bicgstab
eebasso Oct 19, 2023
6eaddb1
Merge branch 'development' of https://github.com/AMReX-Codes/amrex in…
eebasso Nov 2, 2023
2c13963
Avoid use of `s` in solve_bicgstab
eebasso Nov 2, 2023
4fe136e
Merge branch 'development' of https://github.com/AMReX-Codes/amrex in…
eebasso Nov 14, 2023
8d6200b
Merge branch 'development' of https://github.com/AMReX-Codes/amrex in…
eebasso Nov 14, 2023
95900ec
Merge branch 'development' of https://github.com/AMReX-Codes/amrex in…
eebasso Nov 15, 2023
dbb7f18
Change comments from "r -= ..." to "r += -..."
eebasso Nov 15, 2023
7e634e9
Merge branch 'development' of https://github.com/AMReX-Codes/amrex in…
eebasso Nov 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Src/LinearSolvers/MLMG/AMReX_MLCGSolver.H
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ MLCGSolverT<MF>::solve_bicgstab (MF& sol, const MF& rhs, RT eps_rel, RT eps_abs)
MF sorig = Lp.make(amrlev, mglev, nghost);
MF p = Lp.make(amrlev, mglev, nghost);
MF r = Lp.make(amrlev, mglev, nghost);
MF s = Lp.make(amrlev, mglev, nghost);
MF rh = Lp.make(amrlev, mglev, nghost);
MF v = Lp.make(amrlev, mglev, nghost);
MF t = Lp.make(amrlev, mglev, nghost);
Expand Down Expand Up @@ -166,9 +165,9 @@ MLCGSolverT<MF>::solve_bicgstab (MF& sol, const MF& rhs, RT eps_rel, RT eps_abs)
ret = 2; break;
}
MF::Saxpy(sol, alpha, ph, 0, 0, ncomp, nghost); // sol += alpha * ph
MF::LinComb(s, RT(1.0), r, 0, -alpha, v, 0, 0, ncomp, nghost); // s = r - alpha * v
MF::Saxpy(r, -alpha, v, 0, 0, ncomp, nghost); // r += -alpha * v

rnorm = norm_inf(s);
rnorm = norm_inf(r);

if ( verbose > 2 && ParallelDescriptor::IOProcessor() )
{
Expand All @@ -180,15 +179,15 @@ MLCGSolverT<MF>::solve_bicgstab (MF& sol, const MF& rhs, RT eps_rel, RT eps_abs)

if ( rnorm < eps_rel*rnorm0 || rnorm < eps_abs ) { break; }

sh.LocalCopy(s,0,0,ncomp,nghost);
sh.LocalCopy(r,0,0,ncomp,nghost);
Lp.apply(amrlev, mglev, t, sh, MLLinOpT<MF>::BCMode::Homogeneous, MLLinOpT<MF>::StateMode::Correction);
Lp.normalize(amrlev, mglev, t);
//
// This is a little funky. I want to elide one of the reductions
// in the following two dotxy()s. We do that by calculating the "local"
// values and then reducing the two local values at the same time.
//
RT tvals[2] = { dotxy(t,t,true), dotxy(t,s,true) };
RT tvals[2] = { dotxy(t,t,true), dotxy(t,r,true) };

BL_PROFILE_VAR("MLCGSolver::ParallelAllReduce", blp_par);
ParallelAllReduce::Sum(tvals,2,Lp.BottomCommunicator());
Expand All @@ -203,7 +202,7 @@ MLCGSolverT<MF>::solve_bicgstab (MF& sol, const MF& rhs, RT eps_rel, RT eps_abs)
ret = 3; break;
}
MF::Saxpy(sol, omega, sh, 0, 0, ncomp, nghost); // sol += omega * sh
MF::LinComb(r, RT(1.0), s, 0, -omega, t, 0, 0, ncomp, nghost); // r = s - omega * t
MF::Saxpy(r, -omega, t, 0, 0, ncomp, nghost); // r += -omega * t

rnorm = norm_inf(r);

Expand Down