19 for (
auto& buf : m_metric_store_buffers) {
21 buf.m_data =
static_cast<__m256i*
>(
22 _mm_malloc(buf.m_size *
sizeof(__m256i),
alignof(__m256i))
35 if (config.contains(
"metric_collect_time_sample_period"))
m_sample_period = config[
"metric_collect_time_sample_period"];
36 if (config.contains(
"metric_collect_toggle_state"))
m_collect_metric_flag = config[
"metric_collect_toggle_state"];
45 __m256i is_gt = _mm256_cmpgt_epi16(signal,
m_pedestal);
46 __m256i is_lt = _mm256_cmpgt_epi16(
m_pedestal, signal);
49 __m256i to_add = _mm256_setzero_si256();
50 to_add = _mm256_blendv_epi8(to_add, _mm256_set1_epi16(1), is_gt);
51 to_add = _mm256_blendv_epi8(to_add, _mm256_set1_epi16(-1), is_lt);
59 to_add = _mm256_setzero_si256();
60 to_add = _mm256_blendv_epi8(to_add, _mm256_set1_epi16(1), is_gt);
61 to_add = _mm256_blendv_epi8(to_add, _mm256_set1_epi16(-1), is_lt);
67 __m256i need_reset = _mm256_or_si256(is_lt, is_gt);
68 m_accum = _mm256_blendv_epi8(
m_accum, _mm256_setzero_si256(), need_reset);
79 seq.fetch_add(1, std::memory_order_release);
87 seq.fetch_add(1, std::memory_order_release);
95 start_seq =
seq.load(std::memory_order_acquire);
96 }
while (start_seq & 1);
106 return *current_active;
111 return {
"m_pedestal",
"m_accum"};
#define REGISTER_AVXPROCESSOR_CREATOR(processor_name, processor_class)
Factory registration macro.
AVX signal processor: Estimates the pedestal and subtracts.
void save_metric_to_store_buffer() override
Save metrics to store buffer.
uint64_t m_sample_period
Adjustable period for storing metric to buffer, in terms of number of time process happens (sampling ...
void configure(const nlohmann::json &config, const int16_t *plane_numbers) override
Configure the accumulation limit according to plane number.
__m256i process(const __m256i &signal) override
Estimate the pedestal using the given signal and subtract.
ProcessorMetricArray< __m256i > read_from_metric_store_buffer() override
Read metrics from store buffer.
~AVXFrugalPedestalSubtractProcessor() noexcept
Release buffer memory.
__m256i m_pedestal
Vector of estimated pedestals for each channel.
std::atomic< ProcessorMetricArray< __m256i > * > m_active_buffer
virtual std::vector< std::string > get_metric_items() override
returns the metrics being recorded and can be read by this processor
ProcessorMetricArray< __m256i > m_metric_store_buffers[2]
int16_t m_accum_limit
Count limit before committing to a pedestal shift.
bool m_collect_metric_flag
__m256i m_accum
Vector of counts that a channel's signal was above or below m_pedestal.
std::atomic< uint16_t > seq
virtual __m256i process(const __m256i &signal) override
Simple signal pass-through on __m256i type.
Dynamic array of processor metrics, templated on signal type.