Add user printing mechanism (cherry pick)

This commit is contained in:
2021-11-30 12:04:44 +01:00
parent bba062bcc9
commit cdbad963b0
4 changed files with 142 additions and 37 deletions

View File

@@ -24,7 +24,7 @@ namespace atrip {
, *Vhhhp = nullptr
, *Vppph = nullptr
;
int maxIterations = 0, iterationMod = -1;
int maxIterations = 0, iterationMod = -1, percentageMod = -1;
bool barrier = false;
bool chrono = false;
Input& with_epsilon_i(CTF::Tensor<double> * t) { ei = t; return *this; }
@@ -36,6 +36,7 @@ namespace atrip {
Input& with_Vabci(CTF::Tensor<double> * t) { Vppph = t; return *this; }
Input& with_maxIterations(int i) { maxIterations = i; return *this; }
Input& with_iterationMod(int i) { iterationMod = i; return *this; }
Input& with_percentageMod(int i) { percentageMod = i; return *this; }
Input& with_barrier(bool i) { barrier = i; return *this; }
Input& with_chrono(bool i) { chrono = i; return *this; }
};

View File

@@ -1,5 +1,6 @@
// [[file:../../atrip.org::*Debug][Debug:1]]
// [[file:../../atrip.org::*Macros][Macros:1]]
#pragma once
#include <functional>
#define ATRIP_BENCHMARK
//#define ATRIP_DONT_SLICE
#define ATRIP_DEBUG 1
@@ -7,10 +8,12 @@
#define ATRIP_USE_DGEMM
//#define ATRIP_PRINT_TUPLES
#define LOG(level, name) if (Atrip::rank == 0) std::cout << name << ": "
#ifndef ATRIP_DEBUG
#define ATRIP_DEBUG 1
#endif
#if ATRIP_DEBUG == 4
# pragma message("WARNING: You have OCD debugging ABC triples "\
# pragma message("WARNING: You have OCD debugging ABC triples " \
"expect GB of output and consult your therapist")
# include <dbg.h>
# define HAVE_OCD
@@ -23,7 +26,7 @@
# define WITH_DBG
# define DBG(...) dbg(__VA_ARGS__)
#elif ATRIP_DEBUG == 3
# pragma message("WARNING: You have crazy debugging ABC triples,"\
# pragma message("WARNING: You have crazy debugging ABC triples," \
" expect GB of output")
# include <dbg.h>
# define OCD_Barrier(com)
@@ -45,7 +48,7 @@
# define WITH_CRAZY_DEBUG if (false)
# define WITH_DBG
# define DBG(...) dbg(__VA_ARGS__)
#elif ATRIP_DEBUG == 1
#else
# define OCD_Barrier(com)
# define WITH_OCD if (false)
# define WITH_ROOT if (false)
@@ -54,7 +57,35 @@
# define WITH_DBG if (false)
# define WITH_CRAZY_DEBUG if (false)
# define DBG(...)
#else
# error("ATRIP_DEBUG is not defined!")
#endif
// Debug:1 ends here
// Macros:1 ends here
// [[file:../../atrip.org::*Macros][Macros:2]]
#ifndef LOG
#define LOG(level, name) if (Atrip::rank == 0) std::cout << name << ": "
#endif
// Macros:2 ends here
// [[file:../../atrip.org::*Macros][Macros:3]]
#ifdef ATRIP_NO_OUTPUT
# undef LOG
# define LOG(level, name) if (false) std::cout << name << ": "
#endif
// Macros:3 ends here
// [[file:../../atrip.org::IterationDescriptor][IterationDescriptor]]
namespace atrip {
struct IterationDescription;
using IterationDescriptor = std::function<void(IterationDescription const&)>;
struct IterationDescription {
static IterationDescriptor descriptor;
size_t currentIteration;
size_t totalIterations;
double currentElapsedTime;
};
void registerIterationDescriptor(IterationDescriptor);
}
// IterationDescriptor ends here