Open ankithadas opened 11 months ago
Hi Ankith,
I have been working on optimizing MLCGSolverT::solve_bicgstab()
and I found that the initial setVal(RT(0.0))
are necessary to avoid errors. I believe this is because it fills the grow/ghost cells as well, whereas the LocalCopy operations may not.
As an example,
MF p = Lp.make(amrlev,mglev,sol.nGrowVect())
will initialize p
with the same grow/ghost cells as sol
. If we do
p.LocalCopy(r,0,ncomp,IntVect(0))
this will fill in p
with values from r
except for the grow/ghost cells if sol.nGrowVect()
is nonzero. The boundary cells will be undefined.
Hey Eebaso,
That makes a bit of sense. I believe your last PR as cut down considerable amount of setVal
already. However, I think there are still areas we could optimize further.
bottomSolveWithCG
after setting x
to zero (line number 1450). That means there is no need to store sorig
and compute initial residual r
in MLCGSolver::solve_bicgstab
and solve_cg
MLLinOp::apply
took the input vector x
as const. This would require changing the way the matrix multiplication operations are performed when boundary conditions are inhomogeneous. One way is we change b
vector for inhomogeneous boundary conditions.Again, thank you for your response. Looking forward to hear your thoughts
Hey everyone
I am currently writing a steady state Navier Stokes solver using AMReX. I am using MLABecLaplacian for solving the pressure correction Eq and a modified version of MLABecLaplacian for solving the advection equation. Running a simple Lid Driven Cavity example (512x512 Re = 400) shows that considerable amount of time is spent in setting FABs to zero (or some constant value)
Upon review, it looks like MLMG repeatedly sets FABs to zero multiple times even though some of them are not required. Removing some of the setVals in MLMG does reduce the total call count (tested with Debug build with NaN fill).
My overall solver structure is
I hope that gives a brief idea of my code structure (happy to elaborate more).
Few areas we could cut down the number of times setVal is called in MLMG are
MLMG::prepareForSolve()
. Here the residual and correction fields are set to zero. I believe this is unnecessary as these fields are either filled in or set to zero in other areas of MLMG solverMLCGSolverT::solve_bicgstab()
. HereMF ph, sh
are set to zero. However, these fields are set using LocalCopy later in the iteration loop. AlsoMF sol
is already set to zero atMLMGT::actualBottomSolve ()
Making these modifications does reduce the overall call count (I will put up performance comparison soon) considerably. I believe there are still many cases where setVal is unnecessarily called.
Please let me know your thoughts