File: PD.h

package info (click to toggle)
ntl 11.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 8,820 kB
  • sloc: cpp: 92,194; sh: 10,577; ansic: 3,058; makefile: 536
file content (679 lines) | stat: -rw-r--r-- 15,691 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
#ifndef NTL_PD__H
#define NTL_PD__H

#include <NTL/tools.h>
#include <immintrin.h>

NTL_OPEN_NNS


template<int N>
struct PD {
private:
   PD();
};


// FIXME: should distinguish more carefully:
//   AVX512DQ for long/double conversions
//   AVX512VL for certain ops applied to shorter types:
//      long/double conversions and mask ops
// may need to translate long/double conversions for non-AVXDQ512



//=================== PD<8> implementation ===============

#ifdef NTL_HAVE_AVX512F

template<>
struct PD<8> {
   __m512d data;

   enum { size = 8};

   PD() { }
   PD(double x) : data(_mm512_set1_pd(x)) { }
   PD(__m512d _data) : data(_data) { }

   PD(double d0, double d1, double d2, double d3,
      double d4, double d5, double d6, double d7)
      : data(_mm512_set_pd(d7, d6, d5, d4, d3, d2, d1, d0)) { }

   static PD load(const double *p) { return _mm512_load_pd(p); } 

   // load from unaligned address
   static PD loadu(const double *p) { return _mm512_loadu_pd(p); } 
};

inline void
load(PD<8>& x, const double *p) 
{ x = PD<8>::load(p); }

// load from unaligned address
inline void
loadu(PD<8>& x, const double *p) 
{ x = PD<8>::loadu(p); }

inline void 
store(double *p, PD<8> a) 
{ _mm512_store_pd(p, a.data); }

// store to unaligned address
inline void 
storeu(double *p, PD<8> a) 
{ _mm512_storeu_pd(p, a.data); }

// load and convert
inline void
load(PD<8>& x, const long *p)
{ __m512i a = _mm512_load_epi64(p);  x = _mm512_cvtepi64_pd(a); }

// load unaligned and convert
inline void
loadu(PD<8>& x, const long *p)
{ __m512i a = _mm512_loadu_si512(p);  x = _mm512_cvtepi64_pd(a); }

// convert and store
inline void 
store(long *p, PD<8> a)
{  __m512i b = _mm512_cvtpd_epi64(a.data); _mm512_store_epi64(p, b); }

// convert and store unaligned
inline void 
storeu(long *p, PD<8> a)
{  __m512i b = _mm512_cvtpd_epi64(a.data); _mm512_storeu_si512(p, b); }


// swap even/odd slots
// e.g., 01234567 -> 10325476
inline PD<8> 
swap2(PD<8> a) 
{ return _mm512_permute_pd(a.data, 0x55); }

// swap even/odd slot-pairs
// e.g., 01234567 -> 23016745
inline PD<8> 
swap4(PD<8> a) 
{ return _mm512_permutex_pd(a.data, 0x4e); }

// 01234567 -> 00224466
inline PD<8> 
dup2even(PD<8> a)
{ return _mm512_permute_pd(a.data, 0);   }

// 01234567 -> 11335577
inline PD<8> 
dup2odd(PD<8> a)
{ return _mm512_permute_pd(a.data, 0xff);   }

// 01234567 -> 01014545
inline PD<8> 
dup4even(PD<8> a)
{ return _mm512_permutex_pd(a.data, 0x44);   }

// 01234567 -> 23236767
inline PD<8> 
dup4odd(PD<8> a)
{ return _mm512_permutex_pd(a.data, 0xee);   }

// blend even/odd slots
// 01234567, 89abcdef -> 092b4d6f
inline PD<8> 
blend2(PD<8> a, PD<8> b)
{ return _mm512_mask_blend_pd(0xaa, a.data, b.data); }
// FIXME: why isn't there an intrinsic that doesn't require a mask register?

// blend even/odd slot-pairs
// 01234567, 89abcdef -> 01ab45ef
inline PD<8>
blend4(PD<8> a, PD<8> b)
{ return _mm512_mask_blend_pd(0xcc, a.data, b.data); }
// FIXME: why isn't there an intrinsic that doesn't require a mask register?

// res[i] = a[i] < b[i] ? a[i] : a[i]-b[i]
inline PD<8>
correct_excess(PD<8> a, PD<8> b)
{ 
   __mmask8 k = _mm512_cmp_pd_mask(a.data, b.data, _CMP_GE_OQ);
   return _mm512_mask_sub_pd(a.data, k, a.data, b.data); 
}

// res[i] = a[i] >= 0 ? a[i] : a[i]+b[i]
inline PD<8>
correct_deficit(PD<8> a, PD<8> b)
{ 
   __mmask8 k = _mm512_cmp_pd_mask(a.data, _mm512_setzero_pd(), _CMP_LT_OQ);
   return _mm512_mask_add_pd(a.data, k, a.data, b.data); 
}

inline void 
clear(PD<8>& x) 
{ x.data = _mm512_setzero_pd(); }

inline PD<8> 
operator+(PD<8> a, PD<8> b) 
{ return _mm512_add_pd(a.data, b.data); }

inline PD<8> 
operator-(PD<8> a, PD<8> b) 
{ return _mm512_sub_pd(a.data, b.data); }

inline PD<8> 
operator*(PD<8> a, PD<8> b) 
{ return _mm512_mul_pd(a.data, b.data); }

inline PD<8> 
operator/(PD<8> a, PD<8> b) 
{ return _mm512_div_pd(a.data, b.data); }

inline PD<8>&
operator+=(PD<8>& a, PD<8> b)
{ a = a + b; return a; }

inline PD<8>&
operator-=(PD<8>& a, PD<8> b)
{ a = a - b; return a; }

inline PD<8>&
operator*=(PD<8>& a, PD<8> b)
{ a = a * b; return a; }

inline PD<8>&
operator/=(PD<8>& a, PD<8> b)
{ a = a / b; return a; }

// a*b+c (fused)
inline PD<8> 
fused_muladd(PD<8> a, PD<8> b, PD<8> c) 
{ return _mm512_fmadd_pd(a.data, b.data, c.data); }

// a*b-c (fused)
inline PD<8> 
fused_mulsub(PD<8> a, PD<8> b, PD<8> c) 
{ return _mm512_fmsub_pd(a.data, b.data, c.data); }

// -a*b+c (fused)
inline PD<8> 
fused_negmuladd(PD<8> a, PD<8> b, PD<8> c) 
{ return _mm512_fnmadd_pd(a.data, b.data, c.data); }

#endif

//=================== PD<4> implementation ===============

#if (defined(NTL_HAVE_AVX2) && defined(NTL_HAVE_FMA))

template<>
struct PD<4> {
   __m256d data;

   enum { size = 4};

   PD() { }
   PD(double x) : data(_mm256_set1_pd(x)) { }
   PD(__m256d _data) : data(_data) { }
   PD(double d0, double d1, double d2, double d3)
      : data(_mm256_set_pd(d3, d2, d1, d0)) { }

   static PD load(const double *p) { return _mm256_load_pd(p); } 

   // load from unaligned address
   static PD loadu(const double *p) { return _mm256_loadu_pd(p); } 
};

inline void
load(PD<4>& x, const double *p) 
{ x = PD<4>::load(p); }

// load from unaligned address
inline void
loadu(PD<4>& x, const double *p) 
{ x = PD<4>::loadu(p); }

inline void 
store(double *p, PD<4> a) 
{ _mm256_store_pd(p, a.data); }

// store to unaligned address
inline void 
storeu(double *p, PD<4> a) 
{ _mm256_storeu_pd(p, a.data); }





// The following assume all numbers are integers
// in the range [0, 2^52).   The idea is taken from here:
// https://stackoverflow.com/questions/41144668/how-to-efficiently-perform-double-int64-conversions-with-sse-avx


// Some of the Intel intrinsics for loading and storing packed
// integers from memory require casting between long* and __m256i*.
// Strictly speaking, this can break strict aliasing rules, but
// this is hopefully not a problem. 
// See discussion here:
// https://stackoverflow.com/questions/24787268/how-to-implement-mm-storeu-epi64-without-aliasing-problems


// load and convert
inline void
load(PD<4>& x, const long *p)
{ 
#ifdef NTL_HAVE_AVX512F
   __m256i a = _mm256_load_si256((const __m256i*)p);  
   x = _mm256_cvtepi64_pd(a); 
#else
   __m256i a = _mm256_load_si256((const __m256i*)p);
   a = _mm256_or_si256(a, _mm256_castpd_si256(_mm256_set1_pd(1L << 52)));
   x = _mm256_sub_pd(_mm256_castsi256_pd(a), _mm256_set1_pd(1L << 52));
#endif
}

// load unaligned and convert
inline void
loadu(PD<4>& x, const long *p)
{ 
#ifdef NTL_HAVE_AVX512F
   __m256i a = _mm256_loadu_si256((const __m256i*)p);  x = _mm256_cvtepi64_pd(a); 
#else
   __m256i a = _mm256_loadu_si256((const __m256i*)p);
   a = _mm256_or_si256(a, _mm256_castpd_si256(_mm256_set1_pd(1L << 52)));
   x = _mm256_sub_pd(_mm256_castsi256_pd(a), _mm256_set1_pd(1L << 52));
#endif
}

// convert and store
inline void 
store(long *p, PD<4> a)
{  
#ifdef NTL_HAVE_AVX512F
   __m256i b = _mm256_cvtpd_epi64(a.data); 
#ifdef __clang__
   _mm256_store_si256((__m256i*)p, b);
#else
// clang doesn't define this...why??
   _mm256_store_epi64(p, b); 
#endif
#else
    __m256d x = a.data;
    x = _mm256_add_pd(x, _mm256_set1_pd(1L << 52));
    __m256i b = _mm256_xor_si256(
        _mm256_castpd_si256(x),
        _mm256_castpd_si256(_mm256_set1_pd(1L << 52)));
    _mm256_store_si256((__m256i*)p, b);
#endif
}

// convert and store unaligned
inline void 
storeu(long *p, PD<4> a)
{  
#ifdef NTL_HAVE_AVX512F
   __m256i b = _mm256_cvtpd_epi64(a.data); 
  _mm256_storeu_si256((__m256i*)p, b); 
#else
    __m256d x = a.data;
    x = _mm256_add_pd(x, _mm256_set1_pd(1L << 52));
    __m256i b = _mm256_xor_si256(
        _mm256_castpd_si256(x),
        _mm256_castpd_si256(_mm256_set1_pd(1L << 52)));
    _mm256_storeu_si256((__m256i*)p, b);
#endif
}


// swap even/odd slots
// e.g., 0123 -> 1032
inline PD<4> 
swap2(PD<4> a) 
{ return _mm256_permute_pd(a.data, 0x5); }

// 0123 -> 0022
inline PD<4> 
dup2even(PD<4> a)
{ return _mm256_permute_pd(a.data, 0);   }

// 0123 -> 1133
inline PD<4> 
dup2odd(PD<4> a)
{ return _mm256_permute_pd(a.data, 0xf);   }

// blend even/odd slots
// 0123, 4567 -> 0527
inline PD<4> 
blend2(PD<4> a, PD<4> b)
{ return _mm256_blend_pd(a.data, b.data, 0xa); }

// res[i] = a[i] < b[i] ? a[i] : a[i]-b[i]
inline PD<4>
correct_excess(PD<4> a, PD<4> b)
{ 
#ifdef NTL_HAVE_AVX512F
   __mmask8 k = _mm256_cmp_pd_mask(a.data, b.data, _CMP_GE_OQ);
   return _mm256_mask_sub_pd(a.data, k, a.data, b.data); 
#else
   __m256d mask = _mm256_cmp_pd(a.data, b.data, _CMP_GE_OQ);
   __m256d corrected = _mm256_sub_pd(a.data, b.data);
   return _mm256_blendv_pd(a.data, corrected, mask);
#endif
}

// res[i] = a[i] >= 0 ? a[i] : a[i]+b[i]
inline PD<4>
correct_deficit(PD<4> a, PD<4> b)
{ 
#ifdef NTL_HAVE_AVX512F
   __mmask8 k = _mm256_cmp_pd_mask(a.data, _mm256_setzero_pd(), _CMP_LT_OQ);
   return _mm256_mask_add_pd(a.data, k, a.data, b.data); 
#else
   __m256d mask = _mm256_cmp_pd(a.data, _mm256_setzero_pd(), _CMP_LT_OQ);
   __m256d corrected = _mm256_add_pd(a.data, b.data);
   return _mm256_blendv_pd(a.data, corrected, mask);
#endif
}

inline void 
clear(PD<4>& x) 
{ x.data = _mm256_setzero_pd(); }

inline PD<4> 
operator+(PD<4> a, PD<4> b) 
{ return _mm256_add_pd(a.data, b.data); }

inline PD<4> 
operator-(PD<4> a, PD<4> b) 
{ return _mm256_sub_pd(a.data, b.data); }

inline PD<4> 
operator*(PD<4> a, PD<4> b) 
{ return _mm256_mul_pd(a.data, b.data); }

inline PD<4> 
operator/(PD<4> a, PD<4> b) 
{ return _mm256_div_pd(a.data, b.data); }

inline PD<4>&
operator+=(PD<4>& a, PD<4> b)
{ a = a + b; return a; }

inline PD<4>&
operator-=(PD<4>& a, PD<4> b)
{ a = a - b; return a; }

inline PD<4>&
operator*=(PD<4>& a, PD<4> b)
{ a = a * b; return a; }

inline PD<4>&
operator/=(PD<4>& a, PD<4> b)
{ a = a / b; return a; }

// a*b+c (fused)
inline PD<4> 
fused_muladd(PD<4> a, PD<4> b, PD<4> c) 
{ return _mm256_fmadd_pd(a.data, b.data, c.data); }

// a*b-c (fused)
inline PD<4> 
fused_mulsub(PD<4> a, PD<4> b, PD<4> c) 
{ return _mm256_fmsub_pd(a.data, b.data, c.data); }

// -a*b+c (fused)
inline PD<4> 
fused_negmuladd(PD<4> a, PD<4> b, PD<4> c) 
{ return _mm256_fnmadd_pd(a.data, b.data, c.data); }


//=================== PD<2> implementation ===============


template<>
struct PD<2> {
   __m128d data;

   enum { size = 2};

   PD() { }
   PD(double x) : data(_mm_set1_pd(x)) { }
   PD(__m128d _data) : data(_data) { }
   PD(double d0, double d1)
      : data(_mm_set_pd(d1, d0)) { }

   static PD load(const double *p) { return _mm_load_pd(p); } 

   // load from unaligned address
   static PD loadu(const double *p) { return _mm_loadu_pd(p); } 
};

inline void
load(PD<2>& x, const double *p) 
{ x = PD<2>::load(p); }

// load from unaligned address
inline void
loadu(PD<2>& x, const double *p) 
{ x = PD<2>::loadu(p); }

inline void 
store(double *p, PD<2> a) 
{ _mm_store_pd(p, a.data); }

// store to unaligned address
inline void 
storeu(double *p, PD<2> a) 
{ _mm_storeu_pd(p, a.data); }





// The following assume all numbers are integers
// in the range [0, 2^52).   The idea is taken from here:
// https://stackoverflow.com/questions/41144668/how-to-efficiently-perform-double-int64-conversions-with-sse-avx

// load and convert
inline void
load(PD<2>& x, const long *p)
{ 
#ifdef NTL_HAVE_AVX512F
   __m128i a = _mm_load_si128((const __m128i*)p);  
   x = _mm_cvtepi64_pd(a); 
#else
   __m128i a = _mm_load_si128((const __m128i*)p);
   a = _mm_or_si128(a, _mm_castpd_si128(_mm_set1_pd(1L << 52)));
   x = _mm_sub_pd(_mm_castsi128_pd(a), _mm_set1_pd(1L << 52));
#endif
}

// load unaligned and convert
inline void
loadu(PD<2>& x, const long *p)
{ 
#ifdef NTL_HAVE_AVX512F
   __m128i a = _mm_loadu_si128((const __m128i*)p);  x = _mm_cvtepi64_pd(a); 
#else
   __m128i a = _mm_loadu_si128((const __m128i*)p);
   a = _mm_or_si128(a, _mm_castpd_si128(_mm_set1_pd(1L << 52)));
   x = _mm_sub_pd(_mm_castsi128_pd(a), _mm_set1_pd(1L << 52));
#endif
}

// convert and store
inline void 
store(long *p, PD<2> a)
{  
#ifdef NTL_HAVE_AVX512F
   __m128i b = _mm_cvtpd_epi64(a.data); 
#ifdef __clang__
   _mm_store_si128((__m128i*)p, b);
#else
// clang doesn't define this...why??
   _mm_store_epi64(p, b); 
#endif
#else
    __m128d x = a.data;
    x = _mm_add_pd(x, _mm_set1_pd(1L << 52));
    __m128i b = _mm_xor_si128(
        _mm_castpd_si128(x),
        _mm_castpd_si128(_mm_set1_pd(1L << 52)));
    _mm_store_si128((__m128i*)p, b);
#endif
}

// convert and store unaligned
inline void 
storeu(long *p, PD<2> a)
{  
#ifdef NTL_HAVE_AVX512F
   __m128i b = _mm_cvtpd_epi64(a.data); 
  _mm_storeu_si128((__m128i*)p, b); 
#else
    __m128d x = a.data;
    x = _mm_add_pd(x, _mm_set1_pd(1L << 52));
    __m128i b = _mm_xor_si128(
        _mm_castpd_si128(x),
        _mm_castpd_si128(_mm_set1_pd(1L << 52)));
    _mm_storeu_si128((__m128i*)p, b);
#endif
}


// res[i] = a[i] < b[i] ? a[i] : a[i]-b[i]
inline PD<2>
correct_excess(PD<2> a, PD<2> b)
{ 
#ifdef NTL_HAVE_AVX512F
   __mmask8 k = _mm_cmp_pd_mask(a.data, b.data, _CMP_GE_OQ);
   return _mm_mask_sub_pd(a.data, k, a.data, b.data); 
#else
   __m128d mask = _mm_cmp_pd(a.data, b.data, _CMP_GE_OQ);
   __m128d corrected = _mm_sub_pd(a.data, b.data);
   return _mm_blendv_pd(a.data, corrected, mask);
#endif
}

// res[i] = a[i] >= 0 ? a[i] : a[i]+b[i]
inline PD<2>
correct_deficit(PD<2> a, PD<2> b)
{ 
#ifdef NTL_HAVE_AVX512F
   __mmask8 k = _mm_cmp_pd_mask(a.data, _mm_setzero_pd(), _CMP_LT_OQ);
   return _mm_mask_add_pd(a.data, k, a.data, b.data); 
#else
   __m128d mask = _mm_cmp_pd(a.data, _mm_setzero_pd(), _CMP_LT_OQ);
   __m128d corrected = _mm_add_pd(a.data, b.data);
   return _mm_blendv_pd(a.data, corrected, mask);
#endif
}

inline void 
clear(PD<2>& x) 
{ x.data = _mm_setzero_pd(); }

inline PD<2> 
operator+(PD<2> a, PD<2> b) 
{ return _mm_add_pd(a.data, b.data); }

inline PD<2> 
operator-(PD<2> a, PD<2> b) 
{ return _mm_sub_pd(a.data, b.data); }

inline PD<2> 
operator*(PD<2> a, PD<2> b) 
{ return _mm_mul_pd(a.data, b.data); }

inline PD<2> 
operator/(PD<2> a, PD<2> b) 
{ return _mm_div_pd(a.data, b.data); }

inline PD<2>&
operator+=(PD<2>& a, PD<2> b)
{ a = a + b; return a; }

inline PD<2>&
operator-=(PD<2>& a, PD<2> b)
{ a = a - b; return a; }

inline PD<2>&
operator*=(PD<2>& a, PD<2> b)
{ a = a * b; return a; }

inline PD<2>&
operator/=(PD<2>& a, PD<2> b)
{ a = a / b; return a; }

// a*b+c (fused)
inline PD<2> 
fused_muladd(PD<2> a, PD<2> b, PD<2> c) 
{ return _mm_fmadd_pd(a.data, b.data, c.data); }

// a*b-c (fused)
inline PD<2> 
fused_mulsub(PD<2> a, PD<2> b, PD<2> c) 
{ return _mm_fmsub_pd(a.data, b.data, c.data); }

// -a*b+c (fused)
inline PD<2> 
fused_negmuladd(PD<2> a, PD<2> b, PD<2> c) 
{ return _mm_fnmadd_pd(a.data, b.data, c.data); }




//================== PD<8>/PD<4> conversions ================

#ifdef NTL_HAVE_AVX512F 

// 0123, 4567 -> 01234567
inline PD<8> 
join(PD<4> a, PD<4> b)
{ 
   __m512d c = _mm512_castpd256_pd512(a.data);
   return _mm512_insertf64x4(c, b.data, 1);
}

// 01234567 -> 0123
inline PD<4>
get_lo(PD<8> a)
{  return _mm512_extractf64x4_pd(a.data, 0); }

// 01234567 -> 4567
inline PD<4>
get_hi(PD<8> a)
{  return _mm512_extractf64x4_pd(a.data, 1); }

#endif

//================== PD<4>/PD<2> conversions ================

// 01, 23 -> 0123
inline PD<4> 
join(PD<2> a, PD<2> b)
#if 0
// some versions of gcc are buggy and don't define this function
{ return _mm256_set_m128d(b.data, a.data); }
#else
{ return _mm256_insertf128_pd(_mm256_castpd128_pd256(a.data), b.data, 1); }
#endif


// 0123 -> 01
inline PD<2>
get_lo(PD<4> a)
{  return _mm256_extractf128_pd(a.data, 0); }

// 0123 -> 23
inline PD<2>
get_hi(PD<4> a)
{  return _mm256_extractf128_pd(a.data, 1); }


#endif


NTL_CLOSE_NNS


#endif