Skip to content

Commit

Permalink
add memory movement estimates to solvers
Browse files Browse the repository at this point in the history
Co-authored-by: Hartwig Anzt <hanzt@icl.utk.edu>
  • Loading branch information
upsj and hartwiganzt committed Jan 7, 2021
1 parent 6be7430 commit 4edc7e1
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/solver/bicg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ void Bicg<ValueType>::apply_impl(const LinOp *b, LinOp *x) const

int iter = -1;

/* Memory movement summary:
* 27n * values + 2 * matrix/preconditioner storage
* 2x SpMV: 4n * values + 2 * storage
* 2x Preconditioner: 4n * values + 2 * storage
* 2x dot 4n
* 1x step 1 (axpys) 6n
* 1x step 2 (axpys) 9n
*/
while (true) {
get_preconditioner()->apply(r.get(), z.get());
conj_trans_preconditioner->apply(r2.get(), z2.get());
Expand Down
11 changes: 11 additions & 0 deletions core/solver/bicgstab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ void Bicgstab<ValueType>::apply_impl(const LinOp *b, LinOp *x) const
rr->copy_from(r.get());

int iter = -1;

/* Memory movement summary:
* 29n * values + 2 * matrix/preconditioner storage
* 2x SpMV: 4n * values + 2 * storage
* 2x Preconditioner: 4n * values + 2 * storage
* 3x dot 6n
* 1x norm2 n
* 1x step 1 (fused axpys) 4n
* 1x step 2 (axpy) 3n
* 1x step 3 (fused axpys) 7n
*/
while (true) {
++iter;
this->template log<log::Logger::iteration_complete>(this, iter, r.get(),
Expand Down
8 changes: 8 additions & 0 deletions core/solver/cg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ void Cg<ValueType>::apply_impl(const LinOp *b, LinOp *x) const
x, r.get());

int iter = -1;
/* Memory movement summary:
* 17n * values + matrix/preconditioner storage
* 1x SpMV: 2n * values + storage
* 1x Preconditioner: 2n * values + storage
* 2x dot 4n
* 1x step 1 (axpy) 3n
* 1x step 2 (axpys) 6n
*/
while (true) {
get_preconditioner()->apply(r.get(), z.get());
r->compute_dot(z.get(), rho.get());
Expand Down
9 changes: 9 additions & 0 deletions core/solver/cgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ void Cgs<ValueType>::apply_impl(const LinOp *b, LinOp *x) const
r_tld->copy_from(r.get());

int iter = 0;
/* Memory movement summary:
* 27n * values + 2 * matrix/preconditioner storage
* 2x SpMV: 4n * values + 2 * storage
* 2x Preconditioner: 4n * values + 2 * storage
* 2x dot 4n
* 1x step 1 (fused axpys) 5n
* 1x step 2 (fused axpys) 4n
* 1x step 3 (axpys) 6n
*/
while (true) {
r->compute_dot(r_tld.get(), rho.get());
// beta = rho / rho_prev
Expand Down
8 changes: 8 additions & 0 deletions core/solver/fcg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ void Fcg<ValueType>::apply_impl(const LinOp *b, LinOp *x) const
x, r.get());

int iter = -1;
/* Memory movement summary:
* 20n * values + matrix/preconditioner storage
* 1x SpMV: 2n * values + storage
* 1x Preconditioner: 2n * values + storage
* 3x dot 6n
* 1x step 1 (axpy) 3n
* 1x step 2 (fused axpys) 7n
*/
while (true) {
get_preconditioner()->apply(r.get(), z.get());
r->compute_dot(z.get(), rho.get());
Expand Down
11 changes: 11 additions & 0 deletions core/solver/gmres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,17 @@ void Gmres<ValueType>::apply_impl(const LinOp *b, LinOp *x) const
auto after_preconditioner =
matrix::Dense<ValueType>::create_with_config_of(dense_x);

/* Memory movement summary for iteration in Krylov subspace of dimension d
* (== krylov_dim / 2 on average), ignoring restarts:
* (5d+7)n * values + matrix/preconditioner storage
* 1x SpMV: 2n * values + storage
* 1x Preconditioner: 2n * values + storage
* MGS: (5d+3)n
* dx dot 2dn
* dx axpys 3dn
* 1x norm2 n
* 1x scal 2n
*/
while (true) {
++total_iter;
this->template log<log::Logger::iteration_complete>(
Expand Down
16 changes: 16 additions & 0 deletions core/solver/idr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,22 @@ void Idr<ValueType>::iterate(const LinOp *b, LinOp *x) const

int total_iter = -1;

/* Memory movement summary for iteration with subspace dimension d
* (3d²+12(d+1))n * values + d * matrix/preconditioner storage
* dx SpMV: 2dn * values + d * storage
* dx Preconditioner: 2dn * values + d * storage
* 1x multidot (gemm) (d+1)n
* dx step 1 (fused axpys) d(d/2+2)n on average
* dx step 2 (fused axpys) d(d/2+2)n on average
* dx step 3: d(2d+4)n on average
* 1x orthogonalize g+u (3k+2)n in kth iteration
* 1x multidot (gemm) kn in (d-k)th iteration
* 2x axpy 6n
* 2x dot 4n
* 1x norm2 n
* 1x scale 2n
* 2x axpy 4n
*/
while (true) {
++total_iter;
this->template log<log::Logger::iteration_complete>(
Expand Down

0 comments on commit 4edc7e1

Please sign in to comment.