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), _mm256_set1_epi16(200), _mm256_set1_epi16(1000),
28 1 : _mm256_set1_epi16(200), _mm256_set1_epi16(100), _mm256_set1_epi16(0),
29 1 : _mm256_set1_epi16(-100), _mm256_set1_epi16(-200), _mm256_set1_epi16(-1000),
30 1 : _mm256_set1_epi16(-200), _mm256_set1_epi16(-100), _mm256_set1_epi16(0) };
31 1 : #pragma GCC diagnostic pop
32 :
33 1 : AVXPipeline pipeline = AVXPipeline();
34 :
35 1 : std::vector<std::pair<dunedaq::trgdataformats::channel_t, int16_t>> channel_plane_numbers = {
36 : { 0, 0 }, { 10, 0 }, { 20, 0 }, { 30, 0 }, { 40, 0 }, { 100, 1 }, { 110, 1 }, { 120, 1 },
37 : { 130, 1 }, { 140, 1 }, { 200, 2 }, { 210, 2 }, { 220, 2 }, { 230, 2 }, { 240, 2 }, { 250, 2 }
38 1 : };
39 :
40 : // Horrendous brackets.
41 1 : std::vector<std::pair<std::string, nlohmann::json>> configs = {
42 : { "AVXRunSumProcessor",
43 2 : { { "memory_factor_plane0", 1 },
44 2 : { "memory_factor_plane1", 1 },
45 2 : { "memory_factor_plane2", 1 },
46 2 : { "scale_factor_plane0", 1 },
47 2 : { "scale_factor_plane1", 1 },
48 2 : { "scale_factor_plane2", 1 },
49 2 : { "memory_divisor_plane0", 1 },
50 2 : { "memory_divisor_plane1", 1 },
51 2 : { "memory_divisor_plane2", 1 },
52 2 : { "scale_divisor_plane0", 1 },
53 2 : { "scale_divisor_plane1", 1 },
54 2 : { "scale_divisor_plane2", 1 } } },
55 6 : { "AVXThresholdProcessor", { { "plane0", 200 }, { "plane1", 1000 }, { "plane2", 1500 } } }
56 54 : };
57 :
58 1 : std::vector<uint16_t> sot_minima = { 1, 1, 1 };
59 :
60 1 : pipeline.configure(configs, channel_plane_numbers);
61 1 : pipeline.set_sot_minima(sot_minima);
62 :
63 : // ADC peak should max at 1600 for all channels.
64 1 : bool adc_peak_at_1600 = true;
65 :
66 13 : for (const __m256i& signal : signals) {
67 12 : std::vector<dunedaq::trgdataformats::TriggerPrimitive> tps = pipeline.process(signal);
68 12 : if (tps.empty())
69 9 : continue;
70 :
71 19 : for (auto tp : tps) {
72 16 : if (tp.adc_peak != 1600) {
73 0 : adc_peak_at_1600 = false;
74 0 : break;
75 : }
76 : }
77 12 : }
78 :
79 1 : BOOST_TEST(adc_peak_at_1600);
80 37 : }
81 :
82 : } // namespace tpglibs
|