ginkgo-project / ginkgo

Numerical linear algebra software package
https://ginkgo-project.github.io/
BSD 3-Clause "New" or "Revised" License
384 stars 86 forks source link

Add debug logger for solvers #1620

Open upsj opened 1 month ago

upsj commented 1 month ago

This debug logger prints out the value of all scalars inside the solver after each iteration:

Here we see the output of the simple-solver example with the logger running

gko::solver::Cg<double>::apply(0x124f04b60,0x124f04f00) of dimensions (19, 19) and 1 rhs
       Iteration           alpha            beta        prev_rho             rho
               0               0               0               1              19
               1               0             765       5.3109419              19
               2               0       151.51792       5.3109419       2.1541599
               3               0       56.610294      0.96997901       2.1541599
               4               0        22.91651      0.96997901      0.55031615
               5               0       13.637587      0.26380868      0.55031615
               6               0       5.8524907      0.26380868      0.14758275
               7               0       3.2949066      0.10013392      0.14758275
               8               0       2.3026212      0.10013392     0.051851311
               9               0       1.1447493     0.029006197     0.051851311
              10               0      0.64935163     0.029006197    0.0094813452
              11               0      0.22821574    0.0038048001    0.0094813452
              12               0     0.075631164    0.0038048001    0.0020622776
              13               0     0.047698364     0.001020997    0.0020622776
              14               0     0.023026955     0.001020997   0.00026116441
              15               0    0.0072957469   4.3166892e-05   0.00026116441
              16               0   0.00078229883   4.3166892e-05   6.9889839e-06
              17               0   0.00017981764   7.3755266e-07   6.9889839e-06
              18               0   1.9199351e-05   7.3755266e-07   8.2060081e-08
              19               0   1.9866215e-06   8.9249994e-28   8.2060081e-08

Should be useful for debugging #1563

upsj commented 1 month ago

Also relevant for investigating #1026 (which is where this idea came up originally)

upsj commented 1 month ago

Wondering about the name here - it might make sense to also have a version that stores all scalars and intermediate vectors in files - should it be SolverDebugPrint or similar?

upsj commented 3 weeks ago

@tcojean There is now a printing and a storing variant + tests