Roland sipos/zero out optimization#44
Draft
roland-sipos wants to merge 3 commits into
Draft
Conversation
roland-sipos
requested review from
ShyamB97,
aeoranday,
alessandrothea,
denizergonul and
xinyue-uoft
June 30, 2026 19:17
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.
Description
Addresses issue #43
Changes Made
AVX Threshold Processor
File: AVXThresholdProcessor.cpp
Optimization: Replaced
_mm256_blendv_epi8(_mm256_setzero_si256(), signal, mask)with_mm256_and_si256(signal, mask).Latency/Throughput Improvement: Reduced a variable-blend instruction down to a single bitwise AND instruction, increasing throughput and port availability (releasing Port 5 constraints).
AVX Frugal Pedestal Subtract Processor
File: AVXFrugalPedestalSubtractProcessor.cpp
Optimizations: Replaced the two 3-instruction blocks generating
to_add = (is_gt ? 1 : 0) + (is_lt ? -1 : 0)(which materialized zero, 1, -1 and ran blendv) with_mm256_sub_epi16(is_lt, is_gt). Since comparison masks contain elements that are either 0 or 0xFFFF (which is signed -1), is_lt - is_gt mathematically computes the exact desired addition/subtraction.Replaced
_mm256_blendv_epi8(m_accum, _mm256_setzero_si256(), need_reset)with_mm256_andnot_si256(need_reset, m_accum).Latency/Throughput Improvement: Avoided 4 slow blendv instructions, 2 zero-vector initializations, and 4 constant-vector initializations. The operations now use single-cycle arithmetic subtraction and bitwise ANDNOT.
AVX Pipeline
File: AVXPipeline.cpp
Optimizations: Replaced
_mm256_blendv_epi8(_mm256_setzero_si256(), m_ones_register, active)with_mm256_and_si256(m_ones_register, active).Replaced 5 blendv calls masking fields in generate_tps with fast
_mm256_and_si256.Replaced 5 blendv calls resetting fields in generate_tps with fast
_mm256_andnot_si256.Latency/Throughput Improvement: Eliminated 11 slow variable-blend (blendv) intrinsics in the critical path of trigger primitive generation.
Standalone Benchmark and Verification App
A self-contained validation and performance benchmark app is located in /test/app/test_benchmark_tpg.cxx
You can build this benchmark application on any Linux system with GCC and AVX2 support without needing the DUNE-DAQ environment:
Compile
g++ -O3 -mavx2 test/apps/test_benchmark_tpg.cxx -o tpglibs_benchmark
Run
./tpglibs_benchmark
Type of change
Testing checklist
dbt-build --unittest)pytest -s minimal_system_quick_test.py)dunedaq_integtest_bundle.sh)python -m pytest)pre-commit run --all-files)Comments here on the testing
Further checks
dbt-build --lint, and/or see https://dune-daq-sw.readthedocs.io/en/latest/packages/styleguide/)(Indicate issue here: # (issue))