FelixReorder.cc
Go to the documentation of this file.
1 /// Thijs Miedema, last edit 2018-08-30
2 
3 #include "FelixReorder.hh"
4 #include "FelixFormat.hh"
5 
6 #define UNUSED(x) (void)(x)
7 
8 namespace dune {
9 
10 void FelixReorder::copy_headers(uint8_t *dst, const uint8_t *src) {
11  /// WIB
12  memcpy(dst, src, m_wib_header_size);
13 
14  /// ColData
15  for (unsigned i = 0; i < m_num_blocks_per_frame; ++i) {
16  memcpy(dst + m_wib_header_size + i * m_coldata_header_size,
17  src + m_wib_header_size +
18  i * (m_num_bytes_per_block + m_coldata_header_size),
19  m_coldata_header_size);
20  }
21 }
22 
23 void FelixReorder::handle_headers(uint8_t *dst, const uint8_t *src,
24  const unsigned frame_index,
25  const unsigned &num_frames,
26  unsigned *num_faulty) {
27  size_t bitfield_size = (num_frames + 7) / 8;
28 
29  if (frame_index == 0) {
30  for (unsigned i = 0; i < bitfield_size; i++) dst[i] = 0;
31  copy_headers(dst + bitfield_size, src);
32  return;
33  }
34 
35  const WIBHeader *wib_frame_0 =
36  reinterpret_cast<WIBHeader const *>(dst + bitfield_size);
37  const WIBHeader *wib_frame_n = reinterpret_cast<WIBHeader const *>(src);
38 
39  bool check_failed = false;
40 
41  // WIB header checks.
42  check_failed |= wib_frame_0->sof ^ wib_frame_n->sof;
43  check_failed |= wib_frame_0->version ^ wib_frame_n->version;
44  check_failed |= wib_frame_0->fiber_no ^ wib_frame_n->fiber_no;
45  check_failed |= wib_frame_0->crate_no ^ wib_frame_n->crate_no;
46  check_failed |= wib_frame_0->slot_no ^ wib_frame_n->slot_no;
47  check_failed |= wib_frame_0->mm ^ wib_frame_n->mm;
48  check_failed |= wib_frame_0->oos ^ wib_frame_n->oos;
49  check_failed |= wib_frame_0->wib_errors ^ wib_frame_n->wib_errors;
50  check_failed |= wib_frame_0->z ^ wib_frame_n->z;
51  check_failed |= (uint64_t)(wib_frame_0->timestamp() + 25 * frame_index) ^
52  wib_frame_n->timestamp();
53 
54  // COLDATA header checks.
55  for (unsigned j = 0; j < 4; ++j) {
56  const ColdataHeader *col_frame_0 = reinterpret_cast<ColdataHeader const *>(
57  dst + bitfield_size + m_wib_header_size + j * m_coldata_header_size);
58  const ColdataHeader *col_frame_n = reinterpret_cast<ColdataHeader const *>(
59  src + m_wib_header_size +
61 
62  check_failed |= col_frame_0->s1_error ^ col_frame_n->s1_error;
63  check_failed |= col_frame_0->s2_error ^ col_frame_n->s2_error;
64  check_failed |= col_frame_0->checksum_a() ^ col_frame_n->checksum_a();
65  check_failed |= col_frame_0->checksum_b() ^ col_frame_n->checksum_b();
66  check_failed |= col_frame_0->error_register ^ col_frame_n->error_register;
67 
68  for (unsigned h = 0; h < 8; ++h) {
69  check_failed |= col_frame_0->hdr(h) ^ col_frame_n->hdr(h);
70  }
71  check_failed |=
72  (uint16_t)(col_frame_0->coldata_convert_count + 1 * frame_index) ^
73  col_frame_n->coldata_convert_count;
74  }
75 
76  if (check_failed) {
78  dst + bitfield_size +
79  (*num_faulty + 1) * (m_wib_header_size + m_num_blocks_per_frame *
81  src);
82 
83  (*num_faulty)++;
84  dst[frame_index / 8] |= 1 << (frame_index % 8);
85  }
86 }
87 
88 void FelixReorder::baseline_handle_frames(uint8_t *dst, const uint8_t *psrc,
89  const unsigned frames_start,
90  const unsigned frames_stop,
91  const unsigned &num_frames,
92  unsigned *num_faulty) {
93  // Store all ADC values in uint16_t.
94  const FelixFrame *src = reinterpret_cast<FelixFrame const *>(psrc);
95  uint8_t *end = dst + num_frames * m_num_bytes_per_data;
96 
97  for (unsigned fr = frames_start; fr < frames_stop; ++fr) {
98  handle_headers(end, psrc + m_num_bytes_per_frame * (fr - frames_start), fr,
99  num_frames, num_faulty);
100 
101  for (unsigned ch = 0; ch < m_num_ch_per_frame; ++ch) {
102  adc_t curr_val = (src + fr - frames_start)->channel(ch);
103  memcpy(dst + (ch * num_frames + fr) * m_adc_size, &curr_val, m_adc_size);
104  }
105  }
106 }
107 
108 bool FelixReorder::do_reorder(uint8_t *dst, const uint8_t *src,
109  const unsigned &num_frames,
110  unsigned *num_faulty) noexcept {
111  try {
112  baseline_handle_frames(dst, src, 0, num_frames, num_frames, num_faulty);
113  } catch (...) {
114  return false;
115  }
116  return true;
117 }
118 
119 bool FelixReorder::do_reorder_part(uint8_t *dst, const uint8_t *src,
120  const unsigned frames_start,
121  const unsigned frames_stop,
122  const unsigned &num_frames,
123  unsigned *num_faulty) noexcept {
124  try {
125  baseline_handle_frames(dst, src, frames_start, frames_stop, num_frames,
126  num_faulty);
127  } catch (...) {
128  return false;
129  }
130  return true;
131 }
132 
133 #ifdef __AVX2__
134 void FelixReorder::reorder_avx_handle_four_segments(
135  const uint8_t *src, uint8_t *dst, const unsigned &num_frames) {
136  /// Set up the two registers
137  __m256i noshift = _mm256_set_epi8(
146 
154  src[b_seg_0 + b_adc0_ch0_p1], src[b_seg_0 + b_adc0_ch0_p0]);
155 
156  __m256i toshift = _mm256_set_epi8(
165 
173  src[b_seg_0 + b_adc0_ch1_p1], src[b_seg_0 + b_adc0_ch1_p0]);
174 
175  /// Shift 4 bits right, all bits align now
176  __m256i afshift = _mm256_srai_epi16(toshift, 4);
177 
178  /// Mask upper four bits of each 16 bit part
179  const __m256i mask = _mm256_set_epi16(
180  0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
181  0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0xfff);
182  __m256i v1 = _mm256_and_si256(noshift, mask);
183  __m256i v2 = _mm256_and_si256(afshift, mask);
184 
185  /// Memcopy out values
186  uint16_t *v1adc = (uint16_t *)&v1;
187  uint16_t *v2adc = (uint16_t *)&v2;
188 
189  for (uint8_t i = 0; i < 2 * m_num_ch_per_seg; i++) {
190  memcpy(((uint16_t *)dst) + 2 * i * num_frames, v1adc + i, m_adc_size);
191  memcpy(((uint16_t *)dst) + (2 * i + 1) * num_frames, v2adc + i, m_adc_size);
192  }
193 }
194 
195 void FelixReorder::reorder_avx_handle_block(const uint8_t *src, uint8_t *dst,
196  const unsigned &num_frames) {
197  reorder_avx_handle_four_segments(src, dst, num_frames);
198  reorder_avx_handle_four_segments(
199  src + 4 * m_num_bytes_per_seg,
200  dst + 4 * m_num_bytes_per_reord_seg * num_frames, num_frames);
201 }
202 
203 void FelixReorder::reorder_avx_handle_frame(const uint8_t *src, uint8_t *dst,
204  unsigned frame_num,
205  const unsigned &num_frames,
206  unsigned *num_faulty) {
207  /// Destinations
208  uint8_t *data_destination = dst + frame_num * m_adc_size;
209  uint8_t *header_destination = dst + num_frames * m_num_bytes_per_data;
210 
211  /// Sources
212  const uint8_t *data_start = src + m_wib_header_size + m_coldata_header_size;
213 
214  handle_headers(header_destination, src, frame_num, num_frames, num_faulty);
215 
216  for (unsigned i = 0; i < m_num_blocks_per_frame; ++i) {
217  reorder_avx_handle_block(
218  data_start + i * (m_coldata_header_size + m_num_bytes_per_block),
219  data_destination + i * m_num_ch_per_block * m_adc_size * num_frames,
220  num_frames);
221  }
222 }
223 
224 bool FelixReorder::do_avx_reorder(uint8_t *dst, const uint8_t *src,
225  const unsigned &num_frames,
226  unsigned *num_faulty) noexcept {
227  try {
228  for (unsigned i = 0; i < num_frames; i++) {
229  reorder_avx_handle_frame(src + i * m_num_bytes_per_frame, dst, i,
230  num_frames, num_faulty);
231  }
232  } catch (...) {
233  return false;
234  }
235  return true;
236 }
237 
238 bool FelixReorder::do_avx_reorder_part(uint8_t *dst, const uint8_t *src,
239  const unsigned frames_start,
240  const unsigned frames_stop,
241  const unsigned &num_frames,
242  unsigned *num_faulty) noexcept {
243  try {
244  for (unsigned i = 0; i < frames_stop - frames_start; i++) {
245  reorder_avx_handle_frame(src + i * m_num_bytes_per_frame, dst,
246  frames_start + i, num_frames, num_faulty);
247  }
248  } catch (...) {
249  return false;
250  }
251  return true;
252 }
253 
254 #else
255 bool FelixReorder::do_avx_reorder(uint8_t *dst, const uint8_t *src,
256  const unsigned &num_frames,
257  unsigned *num_faulty) noexcept {
258  UNUSED(dst);
259  UNUSED(src);
260  UNUSED(num_frames);
261  UNUSED(num_faulty);
262  return false;
263 }
264 
265 bool FelixReorder::do_avx_reorder_part(uint8_t *dst, const uint8_t *src,
266  const unsigned frames_start,
267  const unsigned frames_stop,
268  const unsigned &num_frames,
269  unsigned *num_faulty) noexcept {
270  UNUSED(dst);
271  UNUSED(src);
272  UNUSED(num_frames);
273  UNUSED(frames_start);
274  UNUSED(frames_stop);
275  UNUSED(num_faulty);
276 
277  return false;
278 }
279 #endif
280 
281 #ifdef __AVX512__REMOVE_ME_AFTER_GCC_PATCH
282 void FelixReorder::reorder_avx512_handle_four_frames_two_segments(
283  const uint8_t *src, uint8_t *dst, const unsigned &num_frames) {
284  /// Set up the two registers
285  __m512i noshift = _mm512_set_epi8(src[m_frame3 + b_seg_1 + b_adc1_ch2_p1],
286  src[m_frame3 + b_seg_1 + b_adc1_ch2_p0],
287  src[m_frame2 + b_seg_1 + b_adc1_ch2_p1],
288  src[m_frame2 + b_seg_1 + b_adc1_ch2_p0],
289  src[m_frame1 + b_seg_1 + b_adc1_ch2_p1],
290  src[m_frame1 + b_seg_1 + b_adc1_ch2_p0],
291  src[m_frame0 + b_seg_1 + b_adc1_ch2_p1],
292  src[m_frame0 + b_seg_1 + b_adc1_ch2_p0],
293 
294  src[m_frame3 + b_seg_1 + b_adc1_ch0_p1],
295  src[m_frame3 + b_seg_1 + b_adc1_ch0_p0],
296  src[m_frame2 + b_seg_1 + b_adc1_ch0_p1],
297  src[m_frame2 + b_seg_1 + b_adc1_ch0_p0],
298  src[m_frame1 + b_seg_1 + b_adc1_ch0_p1],
299  src[m_frame1 + b_seg_1 + b_adc1_ch0_p0],
300  src[m_frame0 + b_seg_1 + b_adc1_ch0_p1],
301  src[m_frame0 + b_seg_1 + b_adc1_ch0_p0],
302 
303  src[m_frame3 + b_seg_0 + b_adc1_ch2_p1],
304  src[m_frame3 + b_seg_0 + b_adc1_ch2_p0],
305  src[m_frame2 + b_seg_0 + b_adc1_ch2_p1],
306  src[m_frame2 + b_seg_0 + b_adc1_ch2_p0],
307  src[m_frame1 + b_seg_0 + b_adc1_ch2_p1],
308  src[m_frame1 + b_seg_0 + b_adc1_ch2_p0],
309  src[m_frame0 + b_seg_0 + b_adc1_ch2_p1],
310  src[m_frame0 + b_seg_0 + b_adc1_ch2_p0],
311 
312  src[m_frame3 + b_seg_0 + b_adc1_ch0_p1],
313  src[m_frame3 + b_seg_0 + b_adc1_ch0_p0],
314  src[m_frame2 + b_seg_0 + b_adc1_ch0_p1],
315  src[m_frame2 + b_seg_0 + b_adc1_ch0_p0],
316  src[m_frame1 + b_seg_0 + b_adc1_ch0_p1],
317  src[m_frame1 + b_seg_0 + b_adc1_ch0_p0],
318  src[m_frame0 + b_seg_0 + b_adc1_ch0_p1],
319  src[m_frame0 + b_seg_0 + b_adc1_ch0_p0],
320 
321  src[m_frame3 + b_seg_1 + b_adc0_ch2_p1],
322  src[m_frame3 + b_seg_1 + b_adc0_ch2_p0],
323  src[m_frame2 + b_seg_1 + b_adc0_ch2_p1],
324  src[m_frame2 + b_seg_1 + b_adc0_ch2_p0],
325  src[m_frame1 + b_seg_1 + b_adc0_ch2_p1],
326  src[m_frame1 + b_seg_1 + b_adc0_ch2_p0],
327  src[m_frame0 + b_seg_1 + b_adc0_ch2_p1],
328  src[m_frame0 + b_seg_1 + b_adc0_ch2_p0],
329 
330  src[m_frame3 + b_seg_1 + b_adc0_ch0_p1],
331  src[m_frame3 + b_seg_1 + b_adc0_ch0_p0],
332  src[m_frame2 + b_seg_1 + b_adc0_ch0_p1],
333  src[m_frame2 + b_seg_1 + b_adc0_ch0_p0],
334  src[m_frame1 + b_seg_1 + b_adc0_ch0_p1],
335  src[m_frame1 + b_seg_1 + b_adc0_ch0_p0],
336  src[m_frame0 + b_seg_1 + b_adc0_ch0_p1],
337  src[m_frame0 + b_seg_1 + b_adc0_ch0_p0],
338 
339  src[m_frame3 + b_seg_0 + b_adc0_ch2_p1],
340  src[m_frame3 + b_seg_0 + b_adc0_ch2_p0],
341  src[m_frame2 + b_seg_0 + b_adc0_ch2_p1],
342  src[m_frame2 + b_seg_0 + b_adc0_ch2_p0],
343  src[m_frame1 + b_seg_0 + b_adc0_ch2_p1],
344  src[m_frame1 + b_seg_0 + b_adc0_ch2_p0],
345  src[m_frame0 + b_seg_0 + b_adc0_ch2_p1],
346  src[m_frame0 + b_seg_0 + b_adc0_ch2_p0],
347 
348  src[m_frame3 + b_seg_0 + b_adc0_ch0_p1],
349  src[m_frame3 + b_seg_0 + b_adc0_ch0_p0],
350  src[m_frame2 + b_seg_0 + b_adc0_ch0_p1],
351  src[m_frame2 + b_seg_0 + b_adc0_ch0_p0],
352  src[m_frame1 + b_seg_0 + b_adc0_ch0_p1],
353  src[m_frame1 + b_seg_0 + b_adc0_ch0_p0],
354  src[m_frame0 + b_seg_0 + b_adc0_ch0_p1],
355  src[m_frame0 + b_seg_0 + b_adc0_ch0_p0]);
356 
357  __m512i toshift = _mm512_set_epi8(src[m_frame3 + b_seg_1 + b_adc1_ch3_p1],
358  src[m_frame3 + b_seg_1 + b_adc1_ch3_p0],
359  src[m_frame2 + b_seg_1 + b_adc1_ch3_p1],
360  src[m_frame2 + b_seg_1 + b_adc1_ch3_p0],
361  src[m_frame1 + b_seg_1 + b_adc1_ch3_p1],
362  src[m_frame1 + b_seg_1 + b_adc1_ch3_p0],
363  src[m_frame0 + b_seg_1 + b_adc1_ch3_p1],
364  src[m_frame0 + b_seg_1 + b_adc1_ch3_p0],
365 
366  src[m_frame3 + b_seg_1 + b_adc1_ch1_p1],
367  src[m_frame3 + b_seg_1 + b_adc1_ch1_p0],
368  src[m_frame2 + b_seg_1 + b_adc1_ch1_p1],
369  src[m_frame2 + b_seg_1 + b_adc1_ch1_p0],
370  src[m_frame1 + b_seg_1 + b_adc1_ch1_p1],
371  src[m_frame1 + b_seg_1 + b_adc1_ch1_p0],
372  src[m_frame0 + b_seg_1 + b_adc1_ch1_p1],
373  src[m_frame0 + b_seg_1 + b_adc1_ch1_p0],
374 
375  src[m_frame3 + b_seg_0 + b_adc1_ch3_p1],
376  src[m_frame3 + b_seg_0 + b_adc1_ch3_p0],
377  src[m_frame2 + b_seg_0 + b_adc1_ch3_p1],
378  src[m_frame2 + b_seg_0 + b_adc1_ch3_p0],
379  src[m_frame1 + b_seg_0 + b_adc1_ch3_p1],
380  src[m_frame1 + b_seg_0 + b_adc1_ch3_p0],
381  src[m_frame0 + b_seg_0 + b_adc1_ch3_p1],
382  src[m_frame0 + b_seg_0 + b_adc1_ch3_p0],
383 
384  src[m_frame3 + b_seg_0 + b_adc1_ch1_p1],
385  src[m_frame3 + b_seg_0 + b_adc1_ch1_p0],
386  src[m_frame2 + b_seg_0 + b_adc1_ch1_p1],
387  src[m_frame2 + b_seg_0 + b_adc1_ch1_p0],
388  src[m_frame1 + b_seg_0 + b_adc1_ch1_p1],
389  src[m_frame1 + b_seg_0 + b_adc1_ch1_p0],
390  src[m_frame0 + b_seg_0 + b_adc1_ch1_p1],
391  src[m_frame0 + b_seg_0 + b_adc1_ch1_p0],
392 
393  src[m_frame3 + b_seg_1 + b_adc0_ch3_p1],
394  src[m_frame3 + b_seg_1 + b_adc0_ch3_p0],
395  src[m_frame2 + b_seg_1 + b_adc0_ch3_p1],
396  src[m_frame2 + b_seg_1 + b_adc0_ch3_p0],
397  src[m_frame1 + b_seg_1 + b_adc0_ch3_p1],
398  src[m_frame1 + b_seg_1 + b_adc0_ch3_p0],
399  src[m_frame0 + b_seg_1 + b_adc0_ch3_p1],
400  src[m_frame0 + b_seg_1 + b_adc0_ch3_p0],
401 
402  src[m_frame3 + b_seg_1 + b_adc0_ch1_p1],
403  src[m_frame3 + b_seg_1 + b_adc0_ch1_p0],
404  src[m_frame2 + b_seg_1 + b_adc0_ch1_p1],
405  src[m_frame2 + b_seg_1 + b_adc0_ch1_p0],
406  src[m_frame1 + b_seg_1 + b_adc0_ch1_p1],
407  src[m_frame1 + b_seg_1 + b_adc0_ch1_p0],
408  src[m_frame0 + b_seg_1 + b_adc0_ch1_p1],
409  src[m_frame0 + b_seg_1 + b_adc0_ch1_p0],
410 
411  src[m_frame3 + b_seg_0 + b_adc0_ch3_p1],
412  src[m_frame3 + b_seg_0 + b_adc0_ch3_p0],
413  src[m_frame2 + b_seg_0 + b_adc0_ch3_p1],
414  src[m_frame2 + b_seg_0 + b_adc0_ch3_p0],
415  src[m_frame1 + b_seg_0 + b_adc0_ch3_p1],
416  src[m_frame1 + b_seg_0 + b_adc0_ch3_p0],
417  src[m_frame0 + b_seg_0 + b_adc0_ch3_p1],
418  src[m_frame0 + b_seg_0 + b_adc0_ch3_p0],
419 
420  src[m_frame3 + b_seg_0 + b_adc0_ch1_p1],
421  src[m_frame3 + b_seg_0 + b_adc0_ch1_p0],
422  src[m_frame2 + b_seg_0 + b_adc0_ch1_p1],
423  src[m_frame2 + b_seg_0 + b_adc0_ch1_p0],
424  src[m_frame1 + b_seg_0 + b_adc0_ch1_p1],
425  src[m_frame1 + b_seg_0 + b_adc0_ch1_p0],
426  src[m_frame0 + b_seg_0 + b_adc0_ch1_p1],
427  src[m_frame0 + b_seg_0 + b_adc0_ch1_p0]);
428 
429  /// Shift 4 bits right, all bits align now
430  __m512i afshift = _mm512_srai_epi32(toshift, 4);
431 
432  /// Mask upper four bits of each 16 bit part
433  const __m512i mask = _mm512_set_epi16(
434  0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
435  0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0xfff, 0x0fff, 0x0fff,
436  0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff, 0x0fff,
437  0x0fff, 0x0fff, 0x0fff, 0x0fff, 0xfff);
438  __m512i v1 = _mm512_and_si512(noshift, mask);
439  __m512i v2 = _mm512_and_si512(afshift, mask);
440 
441  /// Adressing vector
442  __m512i addr1 = _mm512_set_epi64(
443  14 * num_frames, 12 * num_frames, 10 * num_frames, 8 * num_frames,
444  6 * num_frames, 4 * num_frames, 2 * num_frames, 0 * num_frames);
445  __m512i addr2 = _mm512_set_epi64(
446  15 * num_frames, 13 * num_frames, 11 * num_frames, 9 * num_frames,
447  7 * num_frames, 5 * num_frames, 3 * num_frames, 1 * num_frames);
448 
449  _mm512_i64scatter_epi64(dst, addr1, v1, m_adc_size);
450  _mm512_i64scatter_epi64(dst, addr2, v2, m_adc_size);
451 }
452 
453 void FelixReorder::reorder_avx512_handle_four_frames_one_block(
454  const uint8_t *src, uint8_t *dst, const unsigned &num_frames) {
455  for (unsigned i = 0; i < 4; ++i) {
456  reorder_avx512_handle_four_frames_two_segments(
457  src + 2 * i * m_num_bytes_per_seg,
458  dst + 2 * i * m_num_bytes_per_reord_seg * num_frames, num_frames);
459  }
460 }
461 
462 void FelixReorder::reorder_avx512_handle_four_frames(const uint8_t *src,
463  uint8_t *dst,
464  unsigned frame_num,
465  const unsigned &num_frames,
466  unsigned *num_faulty) {
467  /// Destinations
468  uint8_t *data_destination = dst + frame_num * m_adc_size;
469 
470  /// Sources
471  const uint8_t *data_start = src + m_wib_header_size + m_coldata_header_size;
472  uint8_t *end = dst + num_frames * m_num_bytes_per_data;
473 
474  /// Copies
475  for (unsigned j = 0; j < 4; ++j) {
476  handle_headers(end, src + j * m_num_bytes_per_frame, frame_num + j,
477  num_frames, num_faulty);
478  }
479 
480  for (unsigned i = 0; i < m_num_blocks_per_frame; ++i) {
481  reorder_avx512_handle_four_frames_one_block(
482  data_start + i * (m_coldata_header_size + m_num_bytes_per_block),
483  data_destination + i * m_num_ch_per_block * m_adc_size * num_frames,
484  num_frames);
485  }
486 }
487 
488 bool FelixReorder::do_avx512_reorder(uint8_t *dst, const uint8_t *src,
489  const unsigned &num_frames,
490  unsigned *num_faulty) noexcept {
491  try {
492  for (unsigned i = 0; i < num_frames; i += 4) {
493  reorder_avx512_handle_four_frames(src + i * m_num_bytes_per_frame, dst, i,
494  num_frames, num_faulty);
495  }
496  } catch (...) {
497  return false;
498  }
499  return true;
500 }
501 
502 bool FelixReorder::do_avx512_reorder_part(uint8_t *dst, const uint8_t *src,
503  const unsigned frames_start,
504  const unsigned frames_stop,
505  const unsigned &num_frames,
506  unsigned *num_faulty) noexcept {
507  try {
508  for (unsigned i = 0; i < frames_stop - frames_start; i += 4) {
509  reorder_avx512_handle_four_frames(src + i * m_num_bytes_per_frame, dst,
510  frames_start + i, num_frames,
511  num_faulty);
512  }
513  } catch (...) {
514  return false;
515  }
516  return true;
517 }
518 #else
519 bool FelixReorder::do_avx512_reorder(uint8_t *dst, const uint8_t *src,
520  const unsigned &num_frames,
521  unsigned *num_faulty) noexcept {
522  UNUSED(dst);
523  UNUSED(src);
524  UNUSED(num_frames);
525  UNUSED(num_faulty);
526 
527  return false;
528 }
529 
530 bool FelixReorder::do_avx512_reorder_part(uint8_t *dst, const uint8_t *src,
531  const unsigned frames_start,
532  const unsigned frames_stop,
533  const unsigned &num_frames,
534  unsigned *num_faulty) noexcept {
535  UNUSED(dst);
536  UNUSED(src);
537  UNUSED(num_frames);
538  UNUSED(frames_start);
539  UNUSED(frames_stop);
540  UNUSED(num_faulty);
541 
542  return false;
543 }
544 
545 } // namespace dune
546 #endif
static const uint8_t b_adc1_ch3_p0
Definition: FelixReorder.hh:61
static const uint8_t b_adc0_ch0_p1
Definition: FelixReorder.hh:48
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
uint16_t adc_t
Definition: FelixFormat.hh:18
static constexpr size_t m_num_bytes_per_seg
Definition: FelixReorder.hh:30
static const unsigned b_seg_0
BIT OFFSET CONSTANTS ///.
Definition: FelixReorder.hh:41
static constexpr size_t m_num_bytes_per_frame
Framesize public constants.
Definition: FelixReorder.hh:66
static bool do_avx512_reorder(uint8_t *dst, const uint8_t *src, const unsigned &num_frames, unsigned *num_faulty) noexcept
static constexpr size_t m_coldata_header_size
Definition: FelixReorder.hh:34
static constexpr size_t m_wib_header_size
Definition: FelixReorder.hh:35
static constexpr unsigned m_frame3
static const uint8_t b_adc0_ch0_p0
Definition: FelixReorder.hh:47
static const uint8_t b_adc0_ch2_p1
Definition: FelixReorder.hh:52
static const uint8_t b_adc1_ch3_p1
Definition: FelixReorder.hh:62
static void copy_headers(uint8_t *dst, const uint8_t *src)
Definition: FelixReorder.cc:10
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
static const uint8_t b_adc1_ch1_p1
Definition: FelixReorder.hh:58
static constexpr unsigned m_frame2
uint8_t channel
Definition: CRTFragment.hh:201
word_t coldata_convert_count
Definition: FelixFormat.hh:90
static const uint8_t b_adc1_ch2_p0
Definition: FelixReorder.hh:59
static constexpr size_t m_num_ch_per_seg
Definition: FelixReorder.hh:28
static const uint8_t b_adc1_ch0_p0
Definition: FelixReorder.hh:55
static const unsigned b_seg_2
Definition: FelixReorder.hh:43
static const uint8_t b_adc0_ch2_p0
Definition: FelixReorder.hh:51
static bool do_reorder(uint8_t *dst, const uint8_t *src, const unsigned &num_frames, unsigned *num_faulty) noexcept
METHODS ///.
static const unsigned b_seg_1
Definition: FelixReorder.hh:42
static constexpr size_t m_adc_size
Definition: FelixReorder.hh:37
static constexpr size_t m_num_bytes_per_reord_seg
Definition: FelixReorder.hh:31
static constexpr size_t m_num_ch_per_block
Definition: FelixReorder.hh:26
static const uint8_t b_adc0_ch3_p0
Definition: FelixReorder.hh:53
static const unsigned b_seg_3
Definition: FelixReorder.hh:44
uint64_t timestamp() const
Definition: FelixFormat.hh:31
static const uint8_t b_adc0_ch1_p1
Definition: FelixReorder.hh:50
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 constexpr size_t m_num_blocks_per_frame
SIZE CONSTANTS ///.
Definition: FelixReorder.hh:24
static constexpr size_t m_num_ch_per_frame
Definition: FelixReorder.hh:25
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
static const uint8_t b_adc0_ch1_p0
Definition: FelixReorder.hh:49
static const uint8_t b_adc1_ch0_p1
Definition: FelixReorder.hh:56
static bool do_avx_reorder(uint8_t *dst, const uint8_t *src, const unsigned &num_frames, unsigned *num_faulty) noexcept
uint8_t hdr(const uint8_t i) const
Definition: FelixFormat.hh:101
static const uint8_t b_adc1_ch1_p0
Definition: FelixReorder.hh:57
#define UNUSED(x)
Thijs Miedema, last edit 2018-08-30.
Definition: FelixReorder.cc:6
static const uint8_t b_adc0_ch3_p1
Definition: FelixReorder.hh:54
static const uint8_t b_adc1_ch2_p1
Definition: FelixReorder.hh:60
static constexpr size_t m_num_bytes_per_data
Definition: FelixReorder.hh:36
static constexpr size_t m_num_bytes_per_block
Definition: FelixReorder.hh:32
static constexpr unsigned m_frame1
static void baseline_handle_frames(uint8_t *dst, const uint8_t *src, const unsigned frames_start, const unsigned frames_stop, const unsigned &num_frames, unsigned *num_faulty)
BASELINE REORDERING ///.
Definition: FelixReorder.cc:88
uint16_t checksum_a() const
Definition: FelixFormat.hh:95
static void handle_headers(uint8_t *dst, const uint8_t *src, const unsigned frame_index, const unsigned &num_frames, unsigned *num_faulty)
Definition: FelixReorder.cc:23
static constexpr unsigned m_frame0
FRAME OFFSETS ///.
uint16_t checksum_b() const
Definition: FelixFormat.hh:98