Line data Source code
1 : /**
2 : * @file avx_pipeline_test.cxx
3 : *
4 : * @copyright This is part of the DUNE DAQ Software Suite, copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 :
9 : #define BOOST_TEST_MODULE boost_test_macro_overview
10 : #define FMT_HEADER_ONLY
11 :
12 : #include "tpglibs/AVXPipeline.hpp"
13 :
14 : #include "trgdataformats/Types.hpp"
15 :
16 : #include <boost/test/unit_test.hpp>
17 : #include <fmt/core.h>
18 : #include <fmt/ranges.h>
19 :
20 : namespace tpglibs {
21 :
22 2 : BOOST_AUTO_TEST_CASE(test_macro_overview)
23 : {
24 :
25 1 : #pragma GCC diagnostic push
26 1 : #pragma GCC diagnostic ignored "-Wignored-attributes"
27 1 : std::vector<__m256i> signals = {_mm256_set1_epi16(100),
28 1 : _mm256_set1_epi16(200),
29 1 : _mm256_set1_epi16(1000),
30 1 : _mm256_set1_epi16(200),
31 1 : _mm256_set1_epi16(100),
32 1 : _mm256_set1_epi16(0),
33 1 : _mm256_set1_epi16(-100),
34 1 : _mm256_set1_epi16(-200),
35 1 : _mm256_set1_epi16(-1000),
36 1 : _mm256_set1_epi16(-200),
37 1 : _mm256_set1_epi16(-100),
38 1 : _mm256_set1_epi16(0)};
39 1 : #pragma GCC diagnostic pop
40 :
41 1 : AVXPipeline pipeline = AVXPipeline();
42 :
43 1 : std::vector<std::pair<dunedaq::trgdataformats::channel_t, int16_t>>
44 : channel_plane_numbers = {{ 0, 0},
45 : { 10, 0},
46 : { 20, 0},
47 : { 30, 0},
48 : { 40, 0},
49 : {100, 1},
50 : {110, 1},
51 : {120, 1},
52 : {130, 1},
53 : {140, 1},
54 : {200, 2},
55 : {210, 2},
56 : {220, 2},
57 : {230, 2},
58 : {240, 2},
59 1 : {250, 2}};
60 :
61 : // Horrendous brackets.
62 1 : std::vector<std::pair<std::string, nlohmann::json>> configs = {
63 : {
64 : "AVXRunSumProcessor",
65 : {
66 2 : {"memory_factor_plane0", 1},
67 2 : {"memory_factor_plane1", 1},
68 2 : {"memory_factor_plane2", 1},
69 2 : {"scale_factor_plane0", 1},
70 2 : {"scale_factor_plane1", 1},
71 2 : {"scale_factor_plane2", 1},
72 2 : {"memory_divisor_plane0", 1},
73 2 : {"memory_divisor_plane1", 1},
74 2 : {"memory_divisor_plane2", 1},
75 2 : {"scale_divisor_plane0", 1},
76 2 : {"scale_divisor_plane1", 1},
77 2 : {"scale_divisor_plane2", 1}
78 : }
79 : },
80 : {
81 : "AVXThresholdProcessor",
82 : {
83 2 : {"plane0", 200},
84 2 : {"plane1", 1000},
85 2 : {"plane2", 1500}
86 : }
87 : }
88 48 : };
89 :
90 1 : std::vector<uint16_t> sot_minima = {1,1,1};
91 :
92 1 : pipeline.configure(configs, channel_plane_numbers);
93 1 : pipeline.set_sot_minima(sot_minima);
94 :
95 : // ADC peak should max at 1600 for all channels.
96 1 : bool adc_peak_at_1600 = true;
97 :
98 13 : for (const __m256i& signal : signals) {
99 12 : std::vector<dunedaq::trgdataformats::TriggerPrimitive> tps = pipeline.process(signal);
100 12 : if (tps.empty()) continue;
101 :
102 19 : for (auto tp : tps) {
103 16 : if (tp.adc_peak != 1600) {
104 0 : adc_peak_at_1600 = false;
105 0 : break;
106 : }
107 : }
108 12 : }
109 :
110 1 : BOOST_TEST(adc_peak_at_1600);
111 48 : }
112 :
113 : } // namespace tpglibs
|