log iso-timestamp instead of seconds-since-start

This commit is contained in:
Simon Bürger 2023-06-28 13:29:58 +01:00
parent 5103c2a592
commit 2351edf3f7

View File

@ -22,15 +22,20 @@ json json_results;
using namespace quda; using namespace quda;
// timestamp = seconds since program start. // thanks chatGPT :)
// these are written to the json output with the goal of later matching them against std::string get_timestamp()
// power-measurments to determine energy efficiency.
using Clock = std::chrono::steady_clock;
Clock::time_point program_start_time = Clock::now();
double get_timestamp()
{ {
auto dur = Clock::now() - program_start_time; // Get the current time
return std::chrono::duration_cast<std::chrono::microseconds>(dur).count() * 1.0e-6; auto now = std::chrono::system_clock::now();
// Convert the current time to a time_t object
std::time_t currentTime = std::chrono::system_clock::to_time_t(now);
// Format the time using std::put_time
std::stringstream ss;
ss << std::put_time(std::localtime(&currentTime), "%Y%m%d %H:%M:%S");
return ss.str();
} }
// This is the MPI grid, i.e. the layout of ranks // This is the MPI grid, i.e. the layout of ranks
@ -235,9 +240,9 @@ void benchmark_wilson(std::vector<int> const &L_list, double target_time)
double flops = 1.0 * dirac.Flops(); double flops = 1.0 * dirac.Flops();
// actual benchmarking // actual benchmarking
double start_time = get_timestamp(); auto start_time = get_timestamp();
double secs = bench(f, target_time); double secs = bench(f, target_time);
double end_time = get_timestamp(); auto end_time = get_timestamp();
#ifdef FLOP_COUNTING_GRID #ifdef FLOP_COUNTING_GRID
// this is the flop counting from Benchmark_Grid // this is the flop counting from Benchmark_Grid
@ -297,9 +302,9 @@ void benchmark_dwf(std::vector<int> const &L_list, double target_time)
double flops = 1.0 * dirac.Flops(); double flops = 1.0 * dirac.Flops();
// actual benchmarking // actual benchmarking
double start_time = get_timestamp(); auto start_time = get_timestamp();
double secs = bench(f, target_time); double secs = bench(f, target_time);
double end_time = get_timestamp(); auto end_time = get_timestamp();
#ifdef FLOP_COUNTING_GRID #ifdef FLOP_COUNTING_GRID
// this is the flop counting from Benchmark_Grid // this is the flop counting from Benchmark_Grid
@ -385,9 +390,9 @@ void benchmark_axpy(std::vector<int> const &L_list, double target_time)
f(); f();
// actual benchmarking // actual benchmarking
double start_time = get_timestamp(); auto start_time = get_timestamp();
double secs = bench(f, target_time); double secs = bench(f, target_time);
double end_time = get_timestamp(); auto end_time = get_timestamp();
double mem_MiB = memory / 1024. / 1024.; double mem_MiB = memory / 1024. / 1024.;
double GBps = mem_MiB / 1024 / secs; double GBps = mem_MiB / 1024 / secs;