Skip to content

Commit

Permalink
Logger instead of printfs
Browse files Browse the repository at this point in the history
  • Loading branch information
kswirydo committed Nov 29, 2023
1 parent abf20be commit 8eb6d19
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
1 change: 0 additions & 1 deletion resolve/LinSolverDirectCuSparseILU0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ namespace ReSolve
error_sum += status_cusparse_;
cusparseDestroyDnVec(vec_X_);
cusparseDestroyDnVec(vec_Y_);
printf("this is setup, error sum is %d \n", error_sum);
return error_sum;
}

Expand Down
21 changes: 16 additions & 5 deletions resolve/LinSolverIterativeRandFGMRES.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include <iostream>
#include <cassert>
#include <cmath>
#include <iomanip>

#include <resolve/utilities/logger/Logger.hpp>
#include <resolve/matrix/MatrixHandler.hpp>
#include "LinSolverIterativeRandFGMRES.hpp"
#include <resolve/RandSketchingCountSketch.hpp>
#include <resolve/RandSketchingFWHT.hpp>


namespace ReSolve
{
using out = io::Logger;
Expand Down Expand Up @@ -198,7 +198,9 @@ namespace ReSolve
//rnorm = ||V_1||
rnorm = sqrt(rnorm);
bnorm = sqrt(bnorm);
printf("it 0: norm %16.16e bnorm %16.16e \n", rnorm, bnorm);
io::Logger::misc() << "it 0: norm of residual "
<< std::scientific << std::setprecision(16)
<< rnorm << " Norm of rhs: " << bnorm << "\n";
initial_residual_norm_ = rnorm;
while(outer_flag) {
// check if maybe residual is already small enough?
Expand Down Expand Up @@ -308,14 +310,19 @@ namespace ReSolve

// residual norm estimate
rnorm = fabs(h_rs_[i + 1]);
printf("it %d: norm %16.16e \n",it, rnorm);

io::Logger::misc() << "it: "<<it<< "norm of residual "
<< std::scientific << std::setprecision(16)
<< rnorm << "\n";
// check convergence
if (i + 1 >= restart_ || rnorm <= tolrel || it >= maxit_) {
notconv = 0;
}
} // inner while

printf("end of cycle, estimated norm %16.16e, flexible?%d \n", rnorm, flexible_);
io::Logger::misc() << "End of cycle, ESTIMATED norm of residual "
<< std::scientific << std::setprecision(16)
<< rnorm << "\n";
// solve tri system
h_rs_[i] = h_rs_[i] / h_H_[i * (restart_ + 1) + i];
for (int ii = 2; ii <= i + 1; ii++) {
Expand Down Expand Up @@ -379,7 +386,11 @@ namespace ReSolve
rnorm = vector_handler_->dot(d_V_, d_V_, memspace_);
// rnorm = ||V_0||
rnorm = sqrt(rnorm);
printf("end of cycle, true norm (after sqrt) %16.16e \n", rnorm);

io::Logger::misc() << "End of cycle, COMPUTER norm of residual "
<< std::scientific << std::setprecision(16)
<< rnorm << "\n";

final_residual_norm_ = rnorm;
fgmres_iters_ = it;
}
Expand Down
18 changes: 0 additions & 18 deletions runResolveOneMatrix

This file was deleted.

0 comments on commit 8eb6d19

Please sign in to comment.