From: Michal Sojka Date: Thu, 4 Oct 2018 10:44:54 +0000 (+0200) Subject: debug: Allow setting trace float precision globally X-Git-Url: http://rtime.felk.cvut.cz/gitweb/hercules2020/kcf.git/commitdiff_plain/0670f19eba22721adb2c48aab8c5bddb2b59d352 debug: Allow setting trace float precision globally --- diff --git a/src/debug.cpp b/src/debug.cpp index 19d5a8c..94cba13 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -4,7 +4,7 @@ std::ostream &operator<<(std::ostream &os, const DbgTracer::Printer &p) { IOSave s(os); - os << std::setprecision(3); + os << std::setprecision(DbgTracer::precision); os << p.obj.size << " " << p.obj.channels() << "ch ";// << static_cast(p.obj.data); os << " = [ "; constexpr size_t num = 10; @@ -17,7 +17,7 @@ std::ostream &operator<<(std::ostream &os, const DbgTracer::Printer &p) std::ostream &operator<<(std::ostream &os, const DbgTracer::Printer &p) { IOSave s(os); - os << std::setprecision(3); + os << std::setprecision(DbgTracer::precision); os << " " << p.obj.size() << " " << p.obj.channels() << "ch "; // << p.obj.get_p_data(); constexpr int num = 10; for (uint s = 0; s < p.obj.n_scales; ++s) { diff --git a/src/debug.h b/src/debug.h index 73ff1e9..6ad1d18 100644 --- a/src/debug.h +++ b/src/debug.h @@ -41,6 +41,7 @@ class DbgTracer { public: bool debug = false; + static constexpr int precision = 2; std::string indent() { return std::string(indentLvl * 4, ' '); } @@ -78,6 +79,8 @@ class DbgTracer { #ifdef CUFFT CudaSafeCall(cudaStreamSynchronize(cudaStreamPerThread)); #endif + IOSave s(std::cerr); + std::cerr << std::setprecision(precision); std::cerr << indent() << name /*<< " @" << line */ << " " << print(obj) << std::endl; } }