From f8b7981be4905accc3f9851ba01f9eed6c2fc852 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Tue, 19 Jul 2022 13:48:03 +0100 Subject: [PATCH] Make use of FST writer thread switchable at run-time. Always build the FST libray with -DFST_WRITER_PARALLEL, iff VL_THREADED. This supports run-time enablement of the FST writer thread, and has no measurable performance impact on single threaded tracing but simplifies the library build. Note: the actual choice of using the fst writer thread is still compile time, but can now be made run-time easily. --- include/verilated_fst_c.cpp | 6 ++---- include/verilated_fst_c.h | 8 ++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/verilated_fst_c.cpp b/include/verilated_fst_c.cpp index e6ea9f99f..8c9523de5 100644 --- a/include/verilated_fst_c.cpp +++ b/include/verilated_fst_c.cpp @@ -28,7 +28,7 @@ #include "verilated_fst_c.h" // GTKWave configuration -#ifdef VL_TRACE_FST_WRITER_THREAD +#ifdef VL_THREADED # define HAVE_LIBPTHREAD # define FST_WRITER_PARALLEL #endif @@ -116,9 +116,7 @@ void VerilatedFst::open(const char* filename) VL_MT_SAFE_EXCLUDES(m_mutex) { m_fst = fstWriterCreate(filename, 1); fstWriterSetPackType(m_fst, FST_WR_PT_LZ4); fstWriterSetTimescaleFromString(m_fst, timeResStr().c_str()); // lintok-begin-on-ref -#ifdef VL_TRACE_FST_WRITER_THREAD - fstWriterSetParallelMode(m_fst, 1); -#endif + if (useFstWriterThread()) fstWriterSetParallelMode(m_fst, 1); fullDump(true); // First dump must be full for fst m_curScope.clear(); diff --git a/include/verilated_fst_c.h b/include/verilated_fst_c.h index 0587527f6..b391c8de6 100644 --- a/include/verilated_fst_c.h +++ b/include/verilated_fst_c.h @@ -60,6 +60,14 @@ private: void declare(uint32_t code, const char* name, int dtypenum, fstVarDir vardir, fstVarType vartype, bool array, int arraynum, bool bussed, int msb, int lsb); + static constexpr bool useFstWriterThread() { +#ifdef VL_TRACE_FST_WRITER_THREAD + return true; +#else + return false; +#endif + } + protected: //========================================================================= // Implementation of VerilatedTrace interface