rtl: Add gzip-compressed and disabled traces support - #152
Draft
Smephite wants to merge 1 commit into
Draft
Conversation
* hw: add a DPI trace writer with a threaded gzip backend * hw: gate both core tracers on RTL_TRACE=gz/off * hw: select the backend per run with +trace_mode or TW_MODE * mk: wire trace_dpi.c and -lz into verilator, vsim and vcs builds * mk: forward extra arguments through the vsim run wrappers * mk: rebuild when an included .svh header changes * mk: handle .dasm.gz in make traces and make annotate * chore: exempt the tracer sources from the trace_* ignore rule * README: document RTL_TRACE and the tuning knobs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
RTL_TRACEto select the instruction-trace backend in simulation:plain(default, unchanged$fwriteto.dasm)gz(DPI writer producing.dasm.gz)off(no tracer)A compression ratio of 34x is reached on the traces without regressing simulation time.
Motivation
The uncompressed per-hart tracers in
spatz_ccandspatz_mempool_cccan accumulate many Gigabytes of data which are potentially not needed anyhow.The generated traces are highly compressible: A 1.4 GB dasm trace compresses to 40 MB with gzip-6 (34x).
What changed
hw/ip/snitch_test/src/trace_dpi.c: new DPI writer.Backends are
thr:gz<N>(defaultthr:gz6),thr:plain,gz<N>,plainandnull.hw/ip/snitch/include/snitch/trace_writer.svh:SNITCH_TRACE_GZselects the DPI writer,SNITCH_TRACE_DISABLEremoves the tracer. -spatz_cc.sv/spatz_mempool_cc.sv: Updated to use new tracerhw/system/spatz_cluster/Makefile,util/Makefrag:RTL_TRACEwires the defines, added required DPI compilesVerification
Verified on QuestaSim 2021.3_2, Verilator 5.020 (GCC 11.2.0) and VCS 2022.06, default cluster config:
Traces decompress byte-identical to the same run under plain, 23.5 MiB → 1015 KiB (23.7x).
Compression does not affect simulation time:
In this implementation, the compression task is offloaded to a worker thread, so it never stalls the main simulation.
Due to the optimized DPI, the per-write latency even drops from 155ns to 61ns compared to
$fwire.Behavior on crashes was investigated:
On
SIGKILL, the.gzstill decompresses; every complete line is intact and in order; only the final line is cut, and ~920 KB is lost against ~690 KB for plain$fwrite, which buffers too.Notes
This work was supported by Claudio (claude.ai).