From 267830387fb26dedcc826fb0488fa169632c1ce4 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Mon, 7 Oct 2024 15:57:35 +0200 Subject: [PATCH] PajeTrace - option to write only (small) html charts and no trace file --- libsrc/core/paje_trace.cpp | 20 +++++++++++++------- libsrc/core/paje_trace.hpp | 10 ++++++++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/libsrc/core/paje_trace.cpp b/libsrc/core/paje_trace.cpp index dc218e8a..3ffbd716 100644 --- a/libsrc/core/paje_trace.cpp +++ b/libsrc/core/paje_trace.cpp @@ -41,6 +41,7 @@ namespace ngcore bool PajeTrace::trace_thread_counter = false; bool PajeTrace::trace_threads = true; bool PajeTrace::mem_tracing_enabled = true; + bool PajeTrace::write_paje_file = true; PajeTrace :: PajeTrace(int anthreads, std::string aname) { @@ -124,7 +125,7 @@ namespace ngcore #endif if(comm.Size()==1) { - Write(tracefile_name); + Write(); } else { @@ -136,7 +137,7 @@ namespace ngcore event.timer_id += NgProfiler::SIZE*comm.Rank(); if(comm.Rank() == MPI_PAJE_WRITER) - Write(tracefile_name); + Write(); else SendData(); } @@ -443,7 +444,16 @@ namespace ngcore NGCORE_API PajeTrace *trace; - void PajeTrace::Write( const std::string & filename ) + void PajeTrace::Write( ) + { + if(write_paje_file) WritePajeFile( tracefile_name ); + WriteTimingChart(); +#ifdef NETGEN_TRACE_MEMORY + WriteMemoryChart(""); +#endif // NETGEN_TRACE_MEMORY + } + + void PajeTrace::WritePajeFile( const std::string & filename ) { auto n_events = jobs.size() + timer_events.size(); for(auto & vtasks : tasks) @@ -849,10 +859,6 @@ namespace ngcore } } } - WriteTimingChart(); -#ifdef NETGEN_TRACE_MEMORY - WriteMemoryChart(""); -#endif // NETGEN_TRACE_MEMORY paje.WriteEvents(); } diff --git a/libsrc/core/paje_trace.hpp b/libsrc/core/paje_trace.hpp index 7adc6c58..7154feb2 100644 --- a/libsrc/core/paje_trace.hpp +++ b/libsrc/core/paje_trace.hpp @@ -25,6 +25,7 @@ namespace ngcore NGCORE_API static bool trace_thread_counter; NGCORE_API static bool trace_threads; NGCORE_API static bool mem_tracing_enabled; + NGCORE_API static bool write_paje_file; bool tracing_enabled; TTimePoint start_time; @@ -32,6 +33,8 @@ namespace ngcore size_t n_memory_events_at_start; public: + NGCORE_API void Write(); + NGCORE_API void WritePajeFile( const std::string & filename ); NGCORE_API void WriteTimingChart(); #ifdef NETGEN_TRACE_MEMORY NGCORE_API void WriteMemoryChart( std::string fname ); @@ -61,6 +64,11 @@ namespace ngcore max_tracefile_size = max_size; } + static void SetWritePajeFile( bool write ) + { + write_paje_file = write; + } + std::string tracefile_name; struct Job @@ -262,8 +270,6 @@ namespace ngcore links[thread_id].push_back( ThreadLink{thread_id, key, GetTimeCounter(), false} ); } - void Write( const std::string & filename ); - void SendData(); // MPI parallel data reduction };