]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/blobdiff - src/debug.h
Remove debug printf
[hercules2020/kcf.git] / src / debug.h
index 73ff1e95e292f81ccf1e2e6caaa03565c9e82044..cce8327201b44732d131ff4f080a01bed7813180 100644 (file)
@@ -11,6 +11,7 @@
 
 #ifdef CUFFT
 #include <cufft.h>
+#include "nvToolsExt.h"
 #endif
 
 
@@ -41,6 +42,7 @@ class DbgTracer {
 
   public:
     bool debug = false;
+    static constexpr int precision = 2;
 
     std::string indent() { return std::string(indentLvl * 4, ' '); }
 
@@ -51,6 +53,9 @@ class DbgTracer {
       public:
         FTrace(DbgTracer &dt, const char *fn, const char *format, ...) : t(dt), funcName(fn)
         {
+#ifdef CUFFT
+            nvtxRangePushA(fn);
+#endif
             if (!t.debug) return;
             char *arg;
             va_list vl;
@@ -64,6 +69,9 @@ class DbgTracer {
         }
         ~FTrace()
         {
+#ifdef CUFFT
+            nvtxRangePop();
+#endif
             if (!t.debug) return;
             t.indentLvl--;
             std::cerr << t.indent() << "}" << std::endl;
@@ -75,9 +83,8 @@ class DbgTracer {
     {
         (void)line;
         if (debug || always) {
-#ifdef CUFFT
-            CudaSafeCall(cudaStreamSynchronize(cudaStreamPerThread));
-#endif
+            IOSave s(std::cerr);
+            std::cerr << std::setprecision(precision);
             std::cerr << indent() << name /*<< " @" << line */ << " " << print(obj) << std::endl;
         }
     }