FelixReordererFacility.hh
Go to the documentation of this file.
1 #ifndef REORDER_FACILITY_HH_
2 #define REORDER_FACILITY_HH_
3 
4 /*
5  * ReorderFacility
6  * Author: Thijs Miedema
7  * Description: Simple wrapper around FelixReorder to make it plug and play
8  * Date: July 2018
9  */
10 
11 #include <atomic>
12 #include <chrono>
13 #include <string>
14 #include <vector>
15 
16 #include "FelixReorder.hh"
17 #include "artdaq-core/Data/Fragment.hh"
18 
19 namespace dune {
20 
22  public:
23  ReorderFacility(bool force_no_avx = false) : m_force_no_avx(force_no_avx) {}
24 
25  bool do_reorder(uint8_t *dst, const uint8_t *src, const unsigned num_frames) {
26  if (m_force_no_avx) {
27  return FelixReorder::do_reorder(dst, src, num_frames,
29  }
31  return FelixReorder::do_avx512_reorder(dst, src, num_frames,
33  }
35  return FelixReorder::do_avx_reorder(dst, src, num_frames,
37  }
38  return FelixReorder::do_reorder(dst, src, num_frames, &m_num_faulty_frames);
39  }
40 
41  void do_reorder_start(unsigned num_frames) {
43  m_num_frames = num_frames;
44  }
45 
46  unsigned reorder_final_size() {
49  }
50 
51  bool do_reorder_part(uint8_t *dst, const uint8_t *src, const unsigned frames_start,
52  const unsigned frames_stop, const unsigned num_frames) {
53  if (m_force_no_avx) {
54  return FelixReorder::do_reorder_part(dst, src, frames_start, frames_stop,
55  num_frames, &m_num_faulty_frames);
56  }
58  return FelixReorder::do_avx512_reorder_part(dst, src, frames_start,
59  frames_stop, num_frames,
61  }
63  return FelixReorder::do_avx_reorder_part(dst, src, frames_start,
64  frames_stop, num_frames,
66  }
67  return FelixReorder::do_reorder_part(dst, src, frames_start, frames_stop,
68  num_frames, &m_num_faulty_frames);
69  }
70 
72  if (m_force_no_avx) {
73  return "Forced by config to not use AVX.";
74  }
76  return "Going to use AVX512.";
77  }
79  return "Going to use AVX2.";
80  }
81  return "Going to use baseline.";
82  }
83 
85  unsigned m_num_frames;
86 
87  private:
89 };
90 
91 artdaq::Fragment FelixReorder(const uint8_t *src,
92  const uint16_t &num_frames = 6000) {
93  artdaq::Fragment result;
94  dune::FelixFragmentBase::Metadata meta = {0xabc, 1, 1, 0, num_frames, 0, num_frames};
95  result.setMetadata(meta);
96  result.resizeBytes(num_frames * (256*sizeof(adc_t) + sizeof(WIBHeader) + 4*sizeof(ColdataHeader))+ (num_frames+7)/8);
97  uint8_t *dest = result.dataBeginBytes();
98 
99  ReorderFacility facility(false);
100  facility.do_reorder_start(num_frames);
101  facility.do_reorder(dest, src, num_frames);
102  std::cout << "INFO: " << facility.get_info() << '\n';
103  unsigned size = facility.reorder_final_size();
104  result.resizeBytes(size);
105 
106  return result;
107 }
108 
109 } // namespace dune
110 
111 #endif /* REORDER_FACILITY_HH_ */
uint16_t adc_t
Definition: FelixFormat.hh:18
bool do_reorder(uint8_t *dst, const uint8_t *src, const unsigned num_frames)
static QCString result
static bool do_avx512_reorder(uint8_t *dst, const uint8_t *src, const unsigned &num_frames, unsigned *num_faulty) noexcept
std::string string
Definition: nybbler.cc:12
artdaq::Fragment FelixReorder(const uint8_t *src, const uint16_t &num_frames=6000)
static bool do_reorder_part(uint8_t *dst, const uint8_t *src, const unsigned frames_start, const unsigned frames_stop, const unsigned &num_frames, unsigned *num_faulty) noexcept
void do_reorder_start(unsigned num_frames)
static const bool avx512_available
static const bool avx_available
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
static bool do_reorder(uint8_t *dst, const uint8_t *src, const unsigned &num_frames, unsigned *num_faulty) noexcept
METHODS ///.
static bool do_avx512_reorder_part(uint8_t *dst, const uint8_t *src, const unsigned frames_start, const unsigned frames_stop, const unsigned &num_frames, unsigned *num_faulty) noexcept
static bool do_avx_reorder_part(uint8_t *dst, const uint8_t *src, const unsigned frames_start, const unsigned frames_stop, const unsigned &num_frames, unsigned *num_faulty) noexcept
ReorderFacility(bool force_no_avx=false)
static bool do_avx_reorder(uint8_t *dst, const uint8_t *src, const unsigned &num_frames, unsigned *num_faulty) noexcept
bool do_reorder_part(uint8_t *dst, const uint8_t *src, const unsigned frames_start, const unsigned frames_stop, const unsigned num_frames)
static unsigned calculate_reordered_size(unsigned num_frames, unsigned num_faulty)