6 #define UNUSED(x) (void)(x) 19 m_coldata_header_size);
24 const unsigned frame_index,
25 const unsigned &num_frames,
26 unsigned *num_faulty) {
27 size_t bitfield_size = (num_frames + 7) / 8;
29 if (frame_index == 0) {
30 for (
unsigned i = 0; i < bitfield_size; i++) dst[i] = 0;
36 reinterpret_cast<WIBHeader const *
>(dst + bitfield_size);
39 bool check_failed =
false;
42 check_failed |= wib_frame_0->
sof ^ wib_frame_n->
sof;
47 check_failed |= wib_frame_0->
mm ^ wib_frame_n->
mm;
48 check_failed |= wib_frame_0->
oos ^ wib_frame_n->
oos;
50 check_failed |= wib_frame_0->
z ^ wib_frame_n->
z;
51 check_failed |= (uint64_t)(wib_frame_0->
timestamp() + 25 * frame_index) ^
55 for (
unsigned j = 0; j < 4; ++j) {
68 for (
unsigned h = 0;
h < 8; ++
h) {
69 check_failed |= col_frame_0->
hdr(
h) ^ col_frame_n->
hdr(
h);
84 dst[frame_index / 8] |= 1 << (frame_index % 8);
89 const unsigned frames_start,
90 const unsigned frames_stop,
91 const unsigned &num_frames,
92 unsigned *num_faulty) {
97 for (
unsigned fr = frames_start; fr < frames_stop; ++fr) {
99 num_frames, num_faulty);
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);
109 const unsigned &num_frames,
110 unsigned *num_faulty) noexcept {
120 const unsigned frames_start,
121 const unsigned frames_stop,
122 const unsigned &num_frames,
123 unsigned *num_faulty) noexcept {
134 void FelixReorder::reorder_avx_handle_four_segments(
135 const uint8_t *src, uint8_t *dst,
const unsigned &num_frames) {
137 __m256i noshift = _mm256_set_epi8(
156 __m256i toshift = _mm256_set_epi8(
176 __m256i afshift = _mm256_srai_epi16(toshift, 4);
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);
186 uint16_t *v1adc = (uint16_t *)&v1;
187 uint16_t *v2adc = (uint16_t *)&v2;
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);
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(
203 void FelixReorder::reorder_avx_handle_frame(
const uint8_t *src, uint8_t *dst,
205 const unsigned &num_frames,
206 unsigned *num_faulty) {
208 uint8_t *data_destination = dst + frame_num *
m_adc_size;
214 handle_headers(header_destination, src, frame_num, num_frames, num_faulty);
217 reorder_avx_handle_block(
225 const unsigned &num_frames,
226 unsigned *num_faulty) noexcept {
228 for (
unsigned i = 0; i < num_frames; i++) {
230 num_frames, num_faulty);
239 const unsigned frames_start,
240 const unsigned frames_stop,
241 const unsigned &num_frames,
242 unsigned *num_faulty) noexcept {
244 for (
unsigned i = 0; i < frames_stop - frames_start; i++) {
246 frames_start + i, num_frames, num_faulty);
256 const unsigned &num_frames,
257 unsigned *num_faulty) noexcept {
266 const unsigned frames_start,
267 const unsigned frames_stop,
268 const unsigned &num_frames,
269 unsigned *num_faulty) noexcept {
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) {
430 __m512i afshift = _mm512_srai_epi32(toshift, 4);
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);
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);
449 _mm512_i64scatter_epi64(dst, addr1, v1,
m_adc_size);
450 _mm512_i64scatter_epi64(dst, addr2, v2,
m_adc_size);
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(
462 void FelixReorder::reorder_avx512_handle_four_frames(
const uint8_t *src,
465 const unsigned &num_frames,
466 unsigned *num_faulty) {
468 uint8_t *data_destination = dst + frame_num *
m_adc_size;
475 for (
unsigned j = 0; j < 4; ++j) {
477 num_frames, num_faulty);
481 reorder_avx512_handle_four_frames_one_block(
489 const unsigned &num_frames,
490 unsigned *num_faulty) noexcept {
492 for (
unsigned i = 0; i < num_frames; i += 4) {
494 num_frames, num_faulty);
503 const unsigned frames_start,
504 const unsigned frames_stop,
505 const unsigned &num_frames,
506 unsigned *num_faulty) noexcept {
508 for (
unsigned i = 0; i < frames_stop - frames_start; i += 4) {
510 frames_start + i, num_frames,
520 const unsigned &num_frames,
521 unsigned *num_faulty) noexcept {
531 const unsigned frames_start,
532 const unsigned frames_stop,
533 const unsigned &num_frames,
534 unsigned *num_faulty) noexcept {
static const uint8_t b_adc1_ch3_p0
static const uint8_t b_adc0_ch0_p1
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
static constexpr size_t m_num_bytes_per_seg
static const unsigned b_seg_0
BIT OFFSET CONSTANTS ///.
static constexpr size_t m_num_bytes_per_frame
Framesize public constants.
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
static constexpr size_t m_wib_header_size
static constexpr unsigned m_frame3
static const uint8_t b_adc0_ch0_p0
static const uint8_t b_adc0_ch2_p1
static const uint8_t b_adc1_ch3_p1
static void copy_headers(uint8_t *dst, const uint8_t *src)
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
static constexpr unsigned m_frame2
static const uint8_t b_adc1_ch2_p0
static constexpr size_t m_num_ch_per_seg
static const uint8_t b_adc1_ch0_p0
static const unsigned b_seg_2
static const uint8_t b_adc0_ch2_p0
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
static constexpr size_t m_adc_size
static constexpr size_t m_num_bytes_per_reord_seg
static constexpr size_t m_num_ch_per_block
static const uint8_t b_adc0_ch3_p0
static const unsigned b_seg_3
static const uint8_t b_adc0_ch1_p1
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 ///.
static constexpr size_t m_num_ch_per_frame
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
static const uint8_t b_adc1_ch0_p1
static bool do_avx_reorder(uint8_t *dst, const uint8_t *src, const unsigned &num_frames, unsigned *num_faulty) noexcept
static const uint8_t b_adc1_ch1_p0
#define UNUSED(x)
Thijs Miedema, last edit 2018-08-30.
static const uint8_t b_adc0_ch3_p1
static const uint8_t b_adc1_ch2_p1
static constexpr size_t m_num_bytes_per_data
static constexpr size_t m_num_bytes_per_block
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 ///.
static void handle_headers(uint8_t *dst, const uint8_t *src, const unsigned frame_index, const unsigned &num_frames, unsigned *num_faulty)
static constexpr unsigned m_frame0
FRAME OFFSETS ///.