DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
tpglibs::AVXPipeline Class Reference

AVX typed TPG pipeline. More...

#include <AVXPipeline.hpp>

Inheritance diagram for tpglibs::AVXPipeline:
[legend]
Collaboration diagram for tpglibs::AVXPipeline:
[legend]

Public Member Functions

__m256i save_state (const __m256i &processed_signal) override
 Save the state of the processed signals.
bool check_for_tps (const __m256i &tp_mask) override
 Check a channel mask for any TPs that need to be created.
std::vector< dunedaq::trgdataformats::TriggerPrimitive > generate_tps (const __m256i &tp_mask) override
 Finalize the details of the completed TPs and send out.
Public Member Functions inherited from tpglibs::TPGPipeline< AVXProcessor, __m256i >
virtual ~TPGPipeline ()=default
virtual void configure (const std::vector< std::pair< std::string, nlohmann::json > > configs, const std::vector< std::pair< dunedaq::trgdataformats::channel_t, int16_t > > channel_plane_numbers)
 Configure the pieces to the pipeline.
virtual std::vector< dunedaq::trgdataformats::TriggerPrimitive > process (const signal_t &signal)
 Process a signal through the pipeline.
virtual std::vector< std::shared_ptr< AbstractProcessor< signal_t > > > get_all_processor_references ()
 Return reference to all processors in this pipeline.
virtual void set_sot_minima (const std::vector< uint16_t > &sot_minima)
 Set the samples over threshold minimum values.

Private Attributes

const __m256i m_ones_register = _mm256_set1_epi16(1)
 A vector of 1s.
const __m256i m_max_value_register = _mm256_set1_epi16(-1)
 A vector of uint16_t max.

Additional Inherited Members

Public Types inherited from tpglibs::TPGPipeline< AVXProcessor, __m256i >
using processor_t
 Processor type to use. Generally AVX.
using signal_t
 Signal type to use. Generally __m256i.
Protected Attributes inherited from tpglibs::TPGPipeline< AVXProcessor, __m256i >
signal_t m_adc_integral_lo
 The on-going ADC integral for channels that are considered active.
signal_t m_adc_integral_hi
signal_t m_adc_peak
 The ADC peak for channels that are considered active.
signal_t m_samples_over_threshold
 The samples over threshold for channels that are considered active.
signal_t m_samples_to_peak
 The number of samples from time_start to the ADC peak.
std::array< dunedaq::trgdataformats::channel_t, 16 > m_channels
 Detector channel numbers for the 16 channels that are being processed.
std::array< int16_t, 16 > m_plane_numbers
 Detector plane numbers for the 16 channels that are being processed.
std::array< uint16_t, 3 > m_sot_minima
 The samples over threshold minimum that a TP from plane i must have.
std::shared_ptr< AbstractFactory< processor_t > > m_factory
 Processor factory singleton.
std::shared_ptr< processor_t > m_processor_head
 Processor head to start from.

Detailed Description

AVX typed TPG pipeline.

Definition at line 20 of file AVXPipeline.hpp.

Member Function Documentation

◆ check_for_tps()

bool tpglibs::AVXPipeline::check_for_tps ( const __m256i & tp_mask)
overridevirtual

Check a channel mask for any TPs that need to be created.

Parameters
tp_maskA vector mask of channels that have completed TPs.
Returns
True if at least 1 channel has a completed TP. False otherwise.

Implements tpglibs::TPGPipeline< AVXProcessor, __m256i >.

Definition at line 48 of file AVXPipeline.cpp.

49{
50 // tp_mask & 0xFFFF = 0 -> tp_mask == 0.
51 // True => tp_mask is all zeros and has no TPs.
52 // Negate!
53 return !_mm256_testz_si256(tp_mask, _mm256_set1_epi16(-1));
54}

◆ generate_tps()

std::vector< dunedaq::trgdataformats::TriggerPrimitive > tpglibs::AVXPipeline::generate_tps ( const __m256i & tp_mask)
overridevirtual

Finalize the details of the completed TPs and send out.

Parameters
tp_maskA vector mask of channels that have completed TPs.
Returns
A vector of completed TPs.

Implements tpglibs::TPGPipeline< AVXProcessor, __m256i >.

Definition at line 57 of file AVXPipeline.cpp.

58{
59 // Mask everything that's relevant.
60 __m256i samples_over_threshold = _mm256_blendv_epi8(_mm256_setzero_si256(), m_samples_over_threshold, tp_mask);
61 __m256i adc_integral_lo = _mm256_blendv_epi8(_mm256_setzero_si256(), m_adc_integral_lo, tp_mask);
62 __m256i adc_integral_hi = _mm256_blendv_epi8(_mm256_setzero_si256(), m_adc_integral_hi, tp_mask);
63 __m256i adc_peak = _mm256_blendv_epi8(_mm256_setzero_si256(), m_adc_peak, tp_mask);
64 __m256i samples_to_peak = _mm256_blendv_epi8(_mm256_setzero_si256(), m_samples_to_peak, tp_mask);
65
66 // Convert to uint16_t.
67 uint16_t tp_sot[16], tp_integral_lo[16], tp_integral_hi[16], tp_adc_peak[16], tp_samples_to_peak[16];
68 _mm256_storeu_si256(reinterpret_cast<__m256i*>(tp_sot), samples_over_threshold);
69 _mm256_storeu_si256(reinterpret_cast<__m256i*>(tp_integral_lo), adc_integral_lo);
70 _mm256_storeu_si256(reinterpret_cast<__m256i*>(tp_integral_hi), adc_integral_hi);
71 _mm256_storeu_si256(reinterpret_cast<__m256i*>(tp_adc_peak), adc_peak);
72 _mm256_storeu_si256(reinterpret_cast<__m256i*>(tp_samples_to_peak), samples_to_peak);
73
74 std::vector<dunedaq::trgdataformats::TriggerPrimitive> tps;
75 for (int i = 0; i < 16; i++) {
76 if (tp_sot[i] < m_sot_minima[m_plane_numbers[i]])
77 continue; // Don't track short TPs.
78 dunedaq::trgdataformats::TriggerPrimitive tp;
79 tp.adc_integral = uint32_t(tp_integral_lo[i]) + (uint32_t(tp_integral_hi[i]) << 16);
80 tp.adc_peak = tp_adc_peak[i];
81 tp.channel = m_channels[i];
82 tp.samples_to_peak = tp_samples_to_peak[i];
83 tp.samples_over_threshold = tp_sot[i];
84
85 // time_start is handled at the next level up, since it is aware of the true and relative times.
86 tps.push_back(tp);
87 }
88
89 // Reset the channels that generated tps.
90 m_samples_over_threshold = _mm256_blendv_epi8(m_samples_over_threshold, _mm256_setzero_si256(), tp_mask);
91 m_adc_integral_lo = _mm256_blendv_epi8(m_adc_integral_lo, _mm256_setzero_si256(), tp_mask);
92 m_adc_integral_hi = _mm256_blendv_epi8(m_adc_integral_hi, _mm256_setzero_si256(), tp_mask);
93 m_adc_peak = _mm256_blendv_epi8(m_adc_peak, _mm256_setzero_si256(), tp_mask);
94 m_samples_to_peak = _mm256_blendv_epi8(m_samples_to_peak, _mm256_setzero_si256(), tp_mask);
95
96 // Finalize.
97 return tps;
98}
std::array< dunedaq::trgdataformats::channel_t, 16 > m_channels

◆ save_state()

__m256i tpglibs::AVXPipeline::save_state ( const __m256i & processed_signal)
overridevirtual

Save the state of the processed signals.

Used for keeping track of TPs that are still on-going.

Parameters
processed_signalResultant signal after completing the pipeline.
Returns
A vector mask of channels that have completed TPs.

Implements tpglibs::TPGPipeline< AVXProcessor, __m256i >.

Definition at line 13 of file AVXPipeline.cpp.

14{
15 __m256i active = _mm256_cmpgt_epi16(processed_signal, _mm256_setzero_si256());
16 __m256i inactive = _mm256_cmpeq_epi16(processed_signal, _mm256_setzero_si256());
17 __m256i was_inactive = _mm256_cmpeq_epi16(m_samples_over_threshold, _mm256_setzero_si256());
18
19 // If it was *not* inactive and is now inactive, then it must be a new TP.
20 __m256i new_tps = _mm256_andnot_si256(was_inactive, inactive);
21
22 // Get the potentially saturated integral and overflown integral.
23 __m256i adc_integral_sat = _mm256_adds_epu16(m_adc_integral_lo, processed_signal);
24 m_adc_integral_lo = _mm256_add_epi16(m_adc_integral_lo, processed_signal);
25
26 // If it is saturated, then increment the hi. The overflown integral already "reset".
27 __m256i is_saturated = _mm256_cmpeq_epi16(adc_integral_sat, m_max_value_register);
28 // If lo and sat are the same, then it is *not* saturated and happened to exactly sum to 0xFFFF.
29 __m256i exact = _mm256_cmpeq_epi16(m_adc_integral_lo, adc_integral_sat);
30 // So, (!exact) & is_saturated == [truly saturated].
31 is_saturated = _mm256_andnot_si256(exact, is_saturated);
32
33 __m256i to_add = _mm256_and_si256(m_ones_register, is_saturated);
34 m_adc_integral_hi = _mm256_adds_epu16(m_adc_integral_hi, to_add);
35
36 __m256i above_peak = _mm256_cmpgt_epi16(processed_signal, m_adc_peak);
37
38 m_adc_peak = _mm256_max_epi16(m_adc_peak, processed_signal);
39 m_samples_to_peak = _mm256_blendv_epi8(m_samples_to_peak, m_samples_over_threshold, above_peak);
40
41 __m256i time_add = _mm256_blendv_epi8(_mm256_setzero_si256(), m_ones_register, active);
42 m_samples_over_threshold = _mm256_adds_epi16(m_samples_over_threshold, time_add);
43
44 return new_tps;
45}
const __m256i m_ones_register
A vector of 1s.
const __m256i m_max_value_register
A vector of uint16_t max.

Member Data Documentation

◆ m_max_value_register

const __m256i tpglibs::AVXPipeline::m_max_value_register = _mm256_set1_epi16(-1)
private

A vector of uint16_t max.

Definition at line 26 of file AVXPipeline.hpp.

◆ m_ones_register

const __m256i tpglibs::AVXPipeline::m_ones_register = _mm256_set1_epi16(1)
private

A vector of 1s.

Definition at line 23 of file AVXPipeline.hpp.


The documentation for this class was generated from the following files: