forked from kunpengcompute/AvxToNeon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
avx512intrin.h
1834 lines (1668 loc) · 71.6 KB
/
avx512intrin.h
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
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2019. Huawei Technologies Co., Ltd. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef AVX2NEON_H
#error Never use <avx512intrin.h> directly; include " avx2neon.h" instead.
#endif
#include <arm_neon.h>
#include <math.h>
#ifdef __cplusplus
using namespace std;
#endif
#include "typedefs.h"
typedef union {
int8x16_t vect_s8[4];
int16x8_t vect_s16[4];
int32x4_t vect_s32[4];
int64x2_t vect_s64[4];
uint8x16_t vect_u8[4];
uint16x8_t vect_u16[4];
uint32x4_t vect_u32[4];
uint64x2_t vect_u64[4];
__m256i vect_i256[2];
__m128i vect_i128[4];
} __m512i __attribute__((aligned(64)));
typedef struct {
float32x4_t vect_f32[4];
} __m512;
typedef struct {
float64x2_t vect_f64[4];
} __m512d;
#define _MM_FROUND_TO_NEAREST_INT 0x00
#define _MM_FROUND_TO_NEG_INF 0x01
#define _MM_FROUND_TO_POS_INF 0x02
#define _MM_FROUND_TO_ZERO 0x03
#define _MM_FROUND_CUR_DIRECTION 0x04
#define _MM_FROUND_RAISE_EXC 0x00
#define _MM_FROUND_NO_EXC 0x08
FORCE_INLINE __m512i _mm512_div_epi8(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_i128[0] = _mm_div_epi8(a.vect_i128[0], b.vect_i128[0]);
res_m512i.vect_i128[1] = _mm_div_epi8(a.vect_i128[1], b.vect_i128[1]);
res_m512i.vect_i128[2] = _mm_div_epi8(a.vect_i128[2], b.vect_i128[2]);
res_m512i.vect_i128[3] = _mm_div_epi8(a.vect_i128[3], b.vect_i128[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_div_epi16(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_i128[0] = _mm_div_epi16(a.vect_i128[0], b.vect_i128[0]);
res_m512i.vect_i128[1] = _mm_div_epi16(a.vect_i128[1], b.vect_i128[1]);
res_m512i.vect_i128[2] = _mm_div_epi16(a.vect_i128[2], b.vect_i128[2]);
res_m512i.vect_i128[3] = _mm_div_epi16(a.vect_i128[3], b.vect_i128[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_div_epi32(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_i256[0] = _mm256_div_epi32(a.vect_i256[0], b.vect_i256[0]);
res_m512i.vect_i256[1] = _mm256_div_epi32(a.vect_i256[1], b.vect_i256[1]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_div_epi64(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_i256[0] = _mm256_div_epi64(a.vect_i256[0], b.vect_i256[0]);
res_m512i.vect_i256[1] = _mm256_div_epi64(a.vect_i256[1], b.vect_i256[1]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_div_epu8(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_i128[0] = _mm_div_epu8(a.vect_i128[0], b.vect_i128[0]);
res_m512i.vect_i128[1] = _mm_div_epu8(a.vect_i128[1], b.vect_i128[1]);
res_m512i.vect_i128[2] = _mm_div_epu8(a.vect_i128[2], b.vect_i128[2]);
res_m512i.vect_i128[3] = _mm_div_epu8(a.vect_i128[3], b.vect_i128[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_div_epu16(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_i128[0] = _mm_div_epu16(a.vect_i128[0], b.vect_i128[0]);
res_m512i.vect_i128[1] = _mm_div_epu16(a.vect_i128[1], b.vect_i128[1]);
res_m512i.vect_i128[2] = _mm_div_epu16(a.vect_i128[2], b.vect_i128[2]);
res_m512i.vect_i128[3] = _mm_div_epu16(a.vect_i128[3], b.vect_i128[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_div_epu32(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_i256[0] = _mm256_div_epu32(a.vect_i256[0], b.vect_i256[0]);
res_m512i.vect_i256[1] = _mm256_div_epu32(a.vect_i256[1], b.vect_i256[1]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_div_epu64(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_i256[0] = _mm256_div_epu64(a.vect_i256[0], b.vect_i256[0]);
res_m512i.vect_i256[1] = _mm256_div_epu64(a.vect_i256[1], b.vect_i256[1]);
return res_m512i;
}
FORCE_INLINE __m512 _mm512_div_ps(__m512 a, __m512 b)
{
__m512 res_m512;
res_m512.vect_f32[0] = vdivq_f32(a.vect_f32[0], b.vect_f32[0]);
res_m512.vect_f32[1] = vdivq_f32(a.vect_f32[1], b.vect_f32[1]);
res_m512.vect_f32[2] = vdivq_f32(a.vect_f32[2], b.vect_f32[2]);
res_m512.vect_f32[3] = vdivq_f32(a.vect_f32[3], b.vect_f32[3]);
return res_m512;
}
FORCE_INLINE __m512d _mm512_div_pd(__m512d a, __m512d b)
{
__m512d res_m512d;
res_m512d.vect_f64[0] = vdivq_f64(a.vect_f64[0], b.vect_f64[0]);
res_m512d.vect_f64[1] = vdivq_f64(a.vect_f64[1], b.vect_f64[1]);
res_m512d.vect_f64[2] = vdivq_f64(a.vect_f64[2], b.vect_f64[2]);
res_m512d.vect_f64[3] = vdivq_f64(a.vect_f64[3], b.vect_f64[3]);
return res_m512d;
}
FORCE_INLINE __m512 _mm512_div_round_ps(__m512 a, __m512 b, int rounding)
{
assert((rounding == (_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC)) ||
(rounding == _MM_FROUND_CUR_DIRECTION));
(void)rounding;
__m512 res_m512;
res_m512.vect_f32[0] = vdivq_f32(a.vect_f32[0], b.vect_f32[0]);
res_m512.vect_f32[1] = vdivq_f32(a.vect_f32[1], b.vect_f32[1]);
res_m512.vect_f32[2] = vdivq_f32(a.vect_f32[2], b.vect_f32[2]);
res_m512.vect_f32[3] = vdivq_f32(a.vect_f32[3], b.vect_f32[3]);
return res_m512;
}
FORCE_INLINE __m512d _mm512_div_round_pd(__m512d a, __m512d b, int rounding)
{
assert((rounding == (_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC)) ||
(rounding == _MM_FROUND_CUR_DIRECTION));
(void)rounding;
__m512d res_m512d;
res_m512d.vect_f64[0] = vdivq_f64(a.vect_f64[0], b.vect_f64[0]);
res_m512d.vect_f64[1] = vdivq_f64(a.vect_f64[1], b.vect_f64[1]);
res_m512d.vect_f64[2] = vdivq_f64(a.vect_f64[2], b.vect_f64[2]);
res_m512d.vect_f64[3] = vdivq_f64(a.vect_f64[3], b.vect_f64[3]);
return res_m512d;
}
FORCE_INLINE __m512i _mm512_add_epi8(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_s8[0] = vaddq_s8(a.vect_s8[0], b.vect_s8[0]);
res_m512i.vect_s8[1] = vaddq_s8(a.vect_s8[1], b.vect_s8[1]);
res_m512i.vect_s8[2] = vaddq_s8(a.vect_s8[2], b.vect_s8[2]);
res_m512i.vect_s8[3] = vaddq_s8(a.vect_s8[3], b.vect_s8[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_add_epi16(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_s16[0] = vaddq_s16(a.vect_s16[0], b.vect_s16[0]);
res_m512i.vect_s16[1] = vaddq_s16(a.vect_s16[1], b.vect_s16[1]);
res_m512i.vect_s16[2] = vaddq_s16(a.vect_s16[2], b.vect_s16[2]);
res_m512i.vect_s16[3] = vaddq_s16(a.vect_s16[3], b.vect_s16[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_add_epi32(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_s32[0] = vaddq_s32(a.vect_s32[0], b.vect_s32[0]);
res_m512i.vect_s32[1] = vaddq_s32(a.vect_s32[1], b.vect_s32[1]);
res_m512i.vect_s32[2] = vaddq_s32(a.vect_s32[2], b.vect_s32[2]);
res_m512i.vect_s32[3] = vaddq_s32(a.vect_s32[3], b.vect_s32[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_add_epi64(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_s64[0] = vaddq_s64(a.vect_s64[0], b.vect_s64[0]);
res_m512i.vect_s64[1] = vaddq_s64(a.vect_s64[1], b.vect_s64[1]);
res_m512i.vect_s64[2] = vaddq_s64(a.vect_s64[2], b.vect_s64[2]);
res_m512i.vect_s64[3] = vaddq_s64(a.vect_s64[3], b.vect_s64[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_adds_epi8(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_s8[0] = vqaddq_s8(a.vect_s8[0], b.vect_s8[0]);
res_m512i.vect_s8[1] = vqaddq_s8(a.vect_s8[1], b.vect_s8[1]);
res_m512i.vect_s8[2] = vqaddq_s8(a.vect_s8[2], b.vect_s8[2]);
res_m512i.vect_s8[3] = vqaddq_s8(a.vect_s8[3], b.vect_s8[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_adds_epi16(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_s16[0] = vqaddq_s16(a.vect_s16[0], b.vect_s16[0]);
res_m512i.vect_s16[1] = vqaddq_s16(a.vect_s16[1], b.vect_s16[1]);
res_m512i.vect_s16[2] = vqaddq_s16(a.vect_s16[2], b.vect_s16[2]);
res_m512i.vect_s16[3] = vqaddq_s16(a.vect_s16[3], b.vect_s16[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_adds_epu8(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_u8[0] = vqaddq_u8(a.vect_u8[0], b.vect_u8[0]);
res_m512i.vect_u8[1] = vqaddq_u8(a.vect_u8[1], b.vect_u8[1]);
res_m512i.vect_u8[2] = vqaddq_u8(a.vect_u8[2], b.vect_u8[2]);
res_m512i.vect_u8[3] = vqaddq_u8(a.vect_u8[3], b.vect_u8[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_adds_epu16(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_u16[0] = vqaddq_u16(a.vect_u16[0], b.vect_u16[0]);
res_m512i.vect_u16[1] = vqaddq_u16(a.vect_u16[1], b.vect_u16[1]);
res_m512i.vect_u16[2] = vqaddq_u16(a.vect_u16[2], b.vect_u16[2]);
res_m512i.vect_u16[3] = vqaddq_u16(a.vect_u16[3], b.vect_u16[3]);
return res_m512i;
}
FORCE_INLINE __m512 _mm512_add_ps(__m512 a, __m512 b)
{
__m512 res_m512;
res_m512.vect_f32[0] = vaddq_f32(a.vect_f32[0], b.vect_f32[0]);
res_m512.vect_f32[1] = vaddq_f32(a.vect_f32[1], b.vect_f32[1]);
res_m512.vect_f32[2] = vaddq_f32(a.vect_f32[2], b.vect_f32[2]);
res_m512.vect_f32[3] = vaddq_f32(a.vect_f32[3], b.vect_f32[3]);
return res_m512;
}
FORCE_INLINE __m512d _mm512_add_pd(__m512d a, __m512d b)
{
__m512d res_m512d;
res_m512d.vect_f64[0] = vaddq_f64(a.vect_f64[0], b.vect_f64[0]);
res_m512d.vect_f64[1] = vaddq_f64(a.vect_f64[1], b.vect_f64[1]);
res_m512d.vect_f64[2] = vaddq_f64(a.vect_f64[2], b.vect_f64[2]);
res_m512d.vect_f64[3] = vaddq_f64(a.vect_f64[3], b.vect_f64[3]);
return res_m512d;
}
FORCE_INLINE __m512 _mm512_add_round_ps (__m512 a, __m512 b, int rounding)
{
assert((rounding == (_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC)) ||
(rounding == (_MM_FROUND_CUR_DIRECTION)));
(void)rounding;
a.vect_f32[0] = vaddq_f32(a.vect_f32[0], b.vect_f32[0]);
a.vect_f32[1] = vaddq_f32(a.vect_f32[1], b.vect_f32[1]);
a.vect_f32[2] = vaddq_f32(a.vect_f32[2], b.vect_f32[2]);
a.vect_f32[3] = vaddq_f32(a.vect_f32[3], b.vect_f32[3]);
return a;
}
FORCE_INLINE __m512d _mm512_add_round_pd (__m512d a, __m512d b, int rounding)
{
assert((rounding == (_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC)) ||
(rounding == (_MM_FROUND_CUR_DIRECTION)));
(void)rounding;
a.vect_f64[0] = vaddq_f64(a.vect_f64[0], b.vect_f64[0]);
a.vect_f64[1] = vaddq_f64(a.vect_f64[1], b.vect_f64[1]);
a.vect_f64[2] = vaddq_f64(a.vect_f64[2], b.vect_f64[2]);
a.vect_f64[3] = vaddq_f64(a.vect_f64[3], b.vect_f64[3]);
return a;
}
FORCE_INLINE __m512 _mm512_addn_ps (__m512 a, __m512 b)
{
a.vect_f32[0] = vnegq_f32(vaddq_f32(a.vect_f32[0], b.vect_f32[0]));
a.vect_f32[1] = vnegq_f32(vaddq_f32(a.vect_f32[1], b.vect_f32[1]));
a.vect_f32[2] = vnegq_f32(vaddq_f32(a.vect_f32[2], b.vect_f32[2]));
a.vect_f32[3] = vnegq_f32(vaddq_f32(a.vect_f32[3], b.vect_f32[3]));
return a;
}
FORCE_INLINE __m512d _mm512_addn_pd (__m512d a, __m512d b)
{
a.vect_f64[0] = vnegq_f64(vaddq_f64(a.vect_f64[0], b.vect_f64[0]));
a.vect_f64[1] = vnegq_f64(vaddq_f64(a.vect_f64[1], b.vect_f64[1]));
a.vect_f64[2] = vnegq_f64(vaddq_f64(a.vect_f64[2], b.vect_f64[2]));
a.vect_f64[3] = vnegq_f64(vaddq_f64(a.vect_f64[3], b.vect_f64[3]));
return a;
}
FORCE_INLINE __m512 _mm512_addn_round_ps (__m512 a, __m512 b, int rounding)
{
assert((rounding == (_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC)) ||
(rounding == (_MM_FROUND_CUR_DIRECTION)));
(void)rounding;
a.vect_f32[0] = vnegq_f32(vaddq_f32(a.vect_f32[0], b.vect_f32[0]));
a.vect_f32[1] = vnegq_f32(vaddq_f32(a.vect_f32[1], b.vect_f32[1]));
a.vect_f32[2] = vnegq_f32(vaddq_f32(a.vect_f32[2], b.vect_f32[2]));
a.vect_f32[3] = vnegq_f32(vaddq_f32(a.vect_f32[3], b.vect_f32[3]));
return a;
}
FORCE_INLINE __m512d _mm512_addn_round_pd (__m512d a, __m512d b, int rounding)
{
assert((rounding == (_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC)) ||
(rounding == (_MM_FROUND_CUR_DIRECTION)));
(void)rounding;
a.vect_f64[0] = vnegq_f64(vaddq_f64(a.vect_f64[0], b.vect_f64[0]));
a.vect_f64[1] = vnegq_f64(vaddq_f64(a.vect_f64[1], b.vect_f64[1]));
a.vect_f64[2] = vnegq_f64(vaddq_f64(a.vect_f64[2], b.vect_f64[2]));
a.vect_f64[3] = vnegq_f64(vaddq_f64(a.vect_f64[3], b.vect_f64[3]));
return a;
}
FORCE_INLINE __m512i _mm512_addsetc_epi32 (__m512i v2, __m512i v3, __mmask16 *k2_res)
{
__m512i res, carry;
res.vect_u32[0] = vaddq_u32(v2.vect_u32[0], v3.vect_u32[0]);
res.vect_u32[1] = vaddq_u32(v2.vect_u32[1], v3.vect_u32[1]);
res.vect_u32[2] = vaddq_u32(v2.vect_u32[2], v3.vect_u32[2]);
res.vect_u32[3] = vaddq_u32(v2.vect_u32[3], v3.vect_u32[3]);
carry.vect_u32[0] = vcltq_u32(res.vect_u32[0], v3.vect_u32[0]);
carry.vect_u32[1] = vcltq_u32(res.vect_u32[1], v3.vect_u32[1]);
carry.vect_u32[2] = vcltq_u32(res.vect_u32[2], v3.vect_u32[2]);
carry.vect_u32[3] = vcltq_u32(res.vect_u32[3], v3.vect_u32[3]);
PICK_HB_32x16(carry, k2_res);
return res;
}
FORCE_INLINE __m512i _mm512_addsets_epi32 (__m512i v2, __m512i v3, __mmask16 *sign)
{
__m512i res, tmp;
res.vect_s32[0] = vaddq_s32(v2.vect_s32[0], v3.vect_s32[0]);
res.vect_s32[1] = vaddq_s32(v2.vect_s32[1], v3.vect_s32[1]);
res.vect_s32[2] = vaddq_s32(v2.vect_s32[2], v3.vect_s32[2]);
res.vect_s32[3] = vaddq_s32(v2.vect_s32[3], v3.vect_s32[3]);
tmp.vect_u32[0] = vandq_u32(v2.vect_u32[0], v3.vect_u32[0]);
tmp.vect_u32[1] = vandq_u32(v2.vect_u32[1], v3.vect_u32[1]);
tmp.vect_u32[2] = vandq_u32(v2.vect_u32[2], v3.vect_u32[2]);
tmp.vect_u32[3] = vandq_u32(v2.vect_u32[3], v3.vect_u32[3]);
PICK_HB_32x16(tmp, sign);
return res;
}
FORCE_INLINE __m512 _mm512_addsets_ps (__m512 v2, __m512 v3, __mmask16 *sign)
{
__m512 res;
__m512i tmp;
res.vect_f32[0] = vaddq_f32(v2.vect_f32[0], v3.vect_f32[0]);
res.vect_f32[1] = vaddq_f32(v2.vect_f32[1], v3.vect_f32[1]);
res.vect_f32[2] = vaddq_f32(v2.vect_f32[2], v3.vect_f32[2]);
res.vect_f32[3] = vaddq_f32(v2.vect_f32[3], v3.vect_f32[3]);
tmp.vect_u32[0] = vandq_u32(vreinterpretq_u32_f32(v2.vect_f32[0]), vreinterpretq_u32_f32(v3.vect_f32[0]));
tmp.vect_u32[1] = vandq_u32(vreinterpretq_u32_f32(v2.vect_f32[1]), vreinterpretq_u32_f32(v3.vect_f32[1]));
tmp.vect_u32[2] = vandq_u32(vreinterpretq_u32_f32(v2.vect_f32[2]), vreinterpretq_u32_f32(v3.vect_f32[2]));
tmp.vect_u32[3] = vandq_u32(vreinterpretq_u32_f32(v2.vect_f32[3]), vreinterpretq_u32_f32(v3.vect_f32[3]));
PICK_HB_32x16(tmp, sign);
return res;
}
FORCE_INLINE __m512 _mm512_addsets_round_ps (__m512 v2, __m512 v3, __mmask16 *sign, int rounding)
{
assert((rounding == (_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC)) ||
(rounding == (_MM_FROUND_CUR_DIRECTION)));
(void)rounding;
return _mm512_addsets_ps(v2, v3, sign);
}
FORCE_INLINE __m512i _mm512_sub_epi16(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_s16[0] = vsubq_s16(a.vect_s16[0], b.vect_s16[0]);
res_m512i.vect_s16[1] = vsubq_s16(a.vect_s16[1], b.vect_s16[1]);
res_m512i.vect_s16[2] = vsubq_s16(a.vect_s16[2], b.vect_s16[2]);
res_m512i.vect_s16[3] = vsubq_s16(a.vect_s16[3], b.vect_s16[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_sub_epi32(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_s32[0] = vsubq_s32(a.vect_s32[0], b.vect_s32[0]);
res_m512i.vect_s32[1] = vsubq_s32(a.vect_s32[1], b.vect_s32[1]);
res_m512i.vect_s32[2] = vsubq_s32(a.vect_s32[2], b.vect_s32[2]);
res_m512i.vect_s32[3] = vsubq_s32(a.vect_s32[3], b.vect_s32[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_sub_epi64(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_s64[0] = vsubq_s64(a.vect_s64[0], b.vect_s64[0]);
res_m512i.vect_s64[1] = vsubq_s64(a.vect_s64[1], b.vect_s64[1]);
res_m512i.vect_s64[2] = vsubq_s64(a.vect_s64[2], b.vect_s64[2]);
res_m512i.vect_s64[3] = vsubq_s64(a.vect_s64[3], b.vect_s64[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_sub_epi8(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_s8[0] = vsubq_s8(a.vect_s8[0], b.vect_s8[0]);
res_m512i.vect_s8[1] = vsubq_s8(a.vect_s8[1], b.vect_s8[1]);
res_m512i.vect_s8[2] = vsubq_s8(a.vect_s8[2], b.vect_s8[2]);
res_m512i.vect_s8[3] = vsubq_s8(a.vect_s8[3], b.vect_s8[3]);
return res_m512i;
}
FORCE_INLINE __m512d _mm512_sub_pd(__m512d a, __m512d b)
{
__m512d res_m512d;
res_m512d.vect_f64[0] = vsubq_f64(a.vect_f64[0], b.vect_f64[0]);
res_m512d.vect_f64[1] = vsubq_f64(a.vect_f64[1], b.vect_f64[1]);
res_m512d.vect_f64[2] = vsubq_f64(a.vect_f64[2], b.vect_f64[2]);
res_m512d.vect_f64[3] = vsubq_f64(a.vect_f64[3], b.vect_f64[3]);
return res_m512d;
}
FORCE_INLINE __m512 _mm512_sub_ps(__m512 a, __m512 b)
{
__m512 res_m512;
res_m512.vect_f32[0] = vsubq_f32(a.vect_f32[0], b.vect_f32[0]);
res_m512.vect_f32[1] = vsubq_f32(a.vect_f32[1], b.vect_f32[1]);
res_m512.vect_f32[2] = vsubq_f32(a.vect_f32[2], b.vect_f32[2]);
res_m512.vect_f32[3] = vsubq_f32(a.vect_f32[3], b.vect_f32[3]);
return res_m512;
}
FORCE_INLINE __m512d _mm512_sub_round_pd(__m512d a, __m512d b, int rounding)
{
assert((rounding == (_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC)) ||
(rounding == _MM_FROUND_CUR_DIRECTION));
(void)rounding;
__m512d res_m512d;
res_m512d.vect_f64[0] = vsubq_f64(a.vect_f64[0], b.vect_f64[0]);
res_m512d.vect_f64[1] = vsubq_f64(a.vect_f64[1], b.vect_f64[1]);
res_m512d.vect_f64[2] = vsubq_f64(a.vect_f64[2], b.vect_f64[2]);
res_m512d.vect_f64[3] = vsubq_f64(a.vect_f64[3], b.vect_f64[3]);
return res_m512d;
}
FORCE_INLINE __m512 _mm512_sub_round_ps(__m512 a, __m512 b, int rounding)
{
assert((rounding == (_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC)) ||
(rounding == _MM_FROUND_CUR_DIRECTION));
(void)rounding;
__m512 res_m512;
res_m512.vect_f32[0] = vsubq_f32(a.vect_f32[0], b.vect_f32[0]);
res_m512.vect_f32[1] = vsubq_f32(a.vect_f32[1], b.vect_f32[1]);
res_m512.vect_f32[2] = vsubq_f32(a.vect_f32[2], b.vect_f32[2]);
res_m512.vect_f32[3] = vsubq_f32(a.vect_f32[3], b.vect_f32[3]);
return res_m512;
}
FORCE_INLINE __m512i _mm512_subr_epi32 (__m512i v2, __m512i v3)
{
__m512i res_m512i;
res_m512i.vect_s32[0] = vsubq_s32(v3.vect_s32[0], v2.vect_s32[0]);
res_m512i.vect_s32[1] = vsubq_s32(v3.vect_s32[1], v2.vect_s32[1]);
res_m512i.vect_s32[2] = vsubq_s32(v3.vect_s32[2], v2.vect_s32[2]);
res_m512i.vect_s32[3] = vsubq_s32(v3.vect_s32[3], v2.vect_s32[3]);
return res_m512i;
}
FORCE_INLINE __m512 _mm512_subr_ps (__m512 v2, __m512 v3)
{
__m512 res_m512;
res_m512.vect_f32[0] = vsubq_f32(v3.vect_f32[0], v2.vect_f32[0]);
res_m512.vect_f32[1] = vsubq_f32(v3.vect_f32[1], v2.vect_f32[1]);
res_m512.vect_f32[2] = vsubq_f32(v3.vect_f32[2], v2.vect_f32[2]);
res_m512.vect_f32[3] = vsubq_f32(v3.vect_f32[3], v2.vect_f32[3]);
return res_m512;
}
FORCE_INLINE __m512d _mm512_subr_pd (__m512d v2, __m512d v3)
{
__m512d res_m512d;
res_m512d.vect_f64[0] = vsubq_f64(v3.vect_f64[0], v2.vect_f64[0]);
res_m512d.vect_f64[1] = vsubq_f64(v3.vect_f64[1], v2.vect_f64[1]);
res_m512d.vect_f64[2] = vsubq_f64(v3.vect_f64[2], v2.vect_f64[2]);
res_m512d.vect_f64[3] = vsubq_f64(v3.vect_f64[3], v2.vect_f64[3]);
return res_m512d;
}
FORCE_INLINE __m512 _mm512_subr_round_ps (__m512 v2, __m512 v3, int rounding)
{
assert((rounding == (_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC)) ||
(rounding == _MM_FROUND_CUR_DIRECTION));
(void)rounding;
return _mm512_subr_ps(v2, v3);
}
FORCE_INLINE __m512d _mm512_subr_round_pd (__m512d v2, __m512d v3, int rounding)
{
assert((rounding == (_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC)) ||
(rounding == _MM_FROUND_CUR_DIRECTION));
(void)rounding;
return _mm512_subr_pd(v2, v3);
}
FORCE_INLINE __m512i _mm512_subsetb_epi32 (__m512i v2, __m512i v3, __mmask16 *borrow)
{
__m512i res, carry;
res.vect_s32[0] = vsubq_s32(v2.vect_s32[0], v3.vect_s32[0]);
res.vect_s32[1] = vsubq_s32(v2.vect_s32[1], v3.vect_s32[1]);
res.vect_s32[2] = vsubq_s32(v2.vect_s32[2], v3.vect_s32[2]);
res.vect_s32[3] = vsubq_s32(v2.vect_s32[3], v3.vect_s32[3]);
carry.vect_u32[0] = vcltq_u32(v2.vect_u32[0], v3.vect_u32[0]);
carry.vect_u32[1] = vcltq_u32(v2.vect_u32[1], v3.vect_u32[1]);
carry.vect_u32[2] = vcltq_u32(v2.vect_u32[2], v3.vect_u32[2]);
carry.vect_u32[3] = vcltq_u32(v2.vect_u32[3], v3.vect_u32[3]);
PICK_HB_32x16(carry, borrow);
return res;
}
FORCE_INLINE __m512i _mm512_subrsetb_epi32 (__m512i v2, __m512i v3, __mmask16 *borrow)
{
return _mm512_subsetb_epi32(v3, v2, borrow);
}
FORCE_INLINE __m512i _mm512_subs_epi16(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_s16[0] = vqsubq_s16(a.vect_s16[0], b.vect_s16[0]);
res_m512i.vect_s16[1] = vqsubq_s16(a.vect_s16[1], b.vect_s16[1]);
res_m512i.vect_s16[2] = vqsubq_s16(a.vect_s16[2], b.vect_s16[2]);
res_m512i.vect_s16[3] = vqsubq_s16(a.vect_s16[3], b.vect_s16[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_subs_epi8(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_s8[0] = vqsubq_s8(a.vect_s8[0], b.vect_s8[0]);
res_m512i.vect_s8[1] = vqsubq_s8(a.vect_s8[1], b.vect_s8[1]);
res_m512i.vect_s8[2] = vqsubq_s8(a.vect_s8[2], b.vect_s8[2]);
res_m512i.vect_s8[3] = vqsubq_s8(a.vect_s8[3], b.vect_s8[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_subs_epu16(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_u16[0] = vqsubq_u16(a.vect_u16[0], b.vect_u16[0]);
res_m512i.vect_u16[1] = vqsubq_u16(a.vect_u16[1], b.vect_u16[1]);
res_m512i.vect_u16[2] = vqsubq_u16(a.vect_u16[2], b.vect_u16[2]);
res_m512i.vect_u16[3] = vqsubq_u16(a.vect_u16[3], b.vect_u16[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_subs_epu8(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_u8[0] = vqsubq_u8(a.vect_u8[0], b.vect_u8[0]);
res_m512i.vect_u8[1] = vqsubq_u8(a.vect_u8[1], b.vect_u8[1]);
res_m512i.vect_u8[2] = vqsubq_u8(a.vect_u8[2], b.vect_u8[2]);
res_m512i.vect_u8[3] = vqsubq_u8(a.vect_u8[3], b.vect_u8[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_permutexvar_epi32 (__m512i idx, __m512i a)
{
__m512i res;
int32x4_t low4bit = vdupq_n_s32(0x0f);
idx.vect_s32[0] = vandq_s32(idx.vect_s32[0], low4bit);
idx.vect_s32[1] = vandq_s32(idx.vect_s32[1], low4bit);
idx.vect_s32[2] = vandq_s32(idx.vect_s32[2], low4bit);
idx.vect_s32[3] = vandq_s32(idx.vect_s32[3], low4bit);
int32_t p_a[16], p_i[16];
vst1q_s32(p_a, a.vect_s32[0]);
vst1q_s32(p_a + 4, a.vect_s32[1]);
vst1q_s32(p_a + 8, a.vect_s32[2]);
vst1q_s32(p_a + 12, a.vect_s32[3]);
vst1q_s32(p_i, idx.vect_s32[0]);
vst1q_s32(p_i + 4, idx.vect_s32[1]);
vst1q_s32(p_i + 8, idx.vect_s32[2]);
vst1q_s32(p_i + 12, idx.vect_s32[3]);
res.vect_s32[0] = vsetq_lane_s32(p_a[p_i[0]], res.vect_s32[0], 0);
res.vect_s32[0] = vsetq_lane_s32(p_a[p_i[1]], res.vect_s32[0], 1);
res.vect_s32[0] = vsetq_lane_s32(p_a[p_i[2]], res.vect_s32[0], 2);
res.vect_s32[0] = vsetq_lane_s32(p_a[p_i[3]], res.vect_s32[0], 3);
res.vect_s32[1] = vsetq_lane_s32(p_a[p_i[4]], res.vect_s32[1], 0);
res.vect_s32[1] = vsetq_lane_s32(p_a[p_i[5]], res.vect_s32[1], 1);
res.vect_s32[1] = vsetq_lane_s32(p_a[p_i[6]], res.vect_s32[1], 2);
res.vect_s32[1] = vsetq_lane_s32(p_a[p_i[7]], res.vect_s32[1], 3);
res.vect_s32[2] = vsetq_lane_s32(p_a[p_i[8]], res.vect_s32[2], 0);
res.vect_s32[2] = vsetq_lane_s32(p_a[p_i[9]], res.vect_s32[2], 1);
res.vect_s32[2] = vsetq_lane_s32(p_a[p_i[10]], res.vect_s32[2], 2);
res.vect_s32[2] = vsetq_lane_s32(p_a[p_i[11]], res.vect_s32[2], 3);
res.vect_s32[3] = vsetq_lane_s32(p_a[p_i[12]], res.vect_s32[3], 0);
res.vect_s32[3] = vsetq_lane_s32(p_a[p_i[13]], res.vect_s32[3], 1);
res.vect_s32[3] = vsetq_lane_s32(p_a[p_i[14]], res.vect_s32[3], 2);
res.vect_s32[3] = vsetq_lane_s32(p_a[p_i[15]], res.vect_s32[3], 3);
return res;
}
FORCE_INLINE __m512i _mm512_permutexvar_epi64(__m512i idx, __m512i a)
{
__m512i res;
int64x2_t low3bit = vdupq_n_s64(0x07);
idx.vect_s64[0] = vandq_s64(idx.vect_s64[0], low3bit);
idx.vect_s64[1] = vandq_s64(idx.vect_s64[1], low3bit);
idx.vect_s64[2] = vandq_s64(idx.vect_s64[2], low3bit);
idx.vect_s64[3] = vandq_s64(idx.vect_s64[3], low3bit);
int64_t p_a[8], p_i[8];
vst1q_s64(p_a, a.vect_s64[0]);
vst1q_s64(p_a + 2, a.vect_s64[1]);
vst1q_s64(p_a + 4, a.vect_s64[2]);
vst1q_s64(p_a + 6, a.vect_s64[3]);
vst1q_s64(p_i, idx.vect_s64[0]);
vst1q_s64(p_i + 2, idx.vect_s64[1]);
vst1q_s64(p_i + 4, idx.vect_s64[2]);
vst1q_s64(p_i + 6, idx.vect_s64[3]);
res.vect_s64[0] = vsetq_lane_s64(p_a[p_i[0]], res.vect_s64[0], 0);
res.vect_s64[0] = vsetq_lane_s64(p_a[p_i[1]], res.vect_s64[0], 1);
res.vect_s64[1] = vsetq_lane_s64(p_a[p_i[2]], res.vect_s64[1], 0);
res.vect_s64[1] = vsetq_lane_s64(p_a[p_i[3]], res.vect_s64[1], 1);
res.vect_s64[2] = vsetq_lane_s64(p_a[p_i[4]], res.vect_s64[2], 0);
res.vect_s64[2] = vsetq_lane_s64(p_a[p_i[5]], res.vect_s64[2], 1);
res.vect_s64[3] = vsetq_lane_s64(p_a[p_i[6]], res.vect_s64[3], 0);
res.vect_s64[3] = vsetq_lane_s64(p_a[p_i[7]], res.vect_s64[3], 1);
return res;
}
FORCE_INLINE __mmask64 _mm512_test_epi8_mask(__m512i a, __m512i b)
{
uint8x16_t mask_and = vld1q_u8(g_mask_epi8);
__m512i tmp;
tmp.vect_u8[0] = vandq_u8(vtstq_u8(a.vect_u8[0], b.vect_u8[0]), mask_and);
tmp.vect_u8[1] = vandq_u8(vtstq_u8(a.vect_u8[1], b.vect_u8[1]), mask_and);
tmp.vect_u8[2] = vandq_u8(vtstq_u8(a.vect_u8[2], b.vect_u8[2]), mask_and);
tmp.vect_u8[3] = vandq_u8(vtstq_u8(a.vect_u8[3], b.vect_u8[3]), mask_and);
uint8_t r[8];
__asm__ __volatile__ (
"addv %b[r0], %[t0].8b \n\t"
"addv %b[r2], %[t1].8b \n\t"
"addv %b[r4], %[t2].8b \n\t"
"addv %b[r6], %[t3].8b \n\t"
"ins %[t0].d[0], %[t0].d[1] \n\t"
"ins %[t1].d[0], %[t1].d[1] \n\t"
"ins %[t2].d[0], %[t2].d[1] \n\t"
"ins %[t3].d[0], %[t3].d[1] \n\t"
"addv %b[r1], %[t0].8b \n\t"
"addv %b[r3], %[t1].8b \n\t"
"addv %b[r5], %[t2].8b \n\t"
"addv %b[r7], %[t3].8b \n\t"
:[r0]"=w"(r[0]), [r1]"=w"(r[1]), [r2]"=w"(r[2]), [r3]"=w"(r[3]), [r4]"=w"(r[4]), [r5]"=w"(r[5]), [r6]"=w"(r[6]),
[r7]"=w"(r[7]),
[t0]"+w"(tmp.vect_u8[0]), [t1]"+w"(tmp.vect_u8[1]), [t2]"+w"(tmp.vect_u8[2]), [t3]"+w"(tmp.vect_u8[3])
);
uint64x1_t res = vreinterpret_u64_u8(vld1_u8((const uint8_t *)r));
return vget_lane_u64(res, 0);
}
FORCE_INLINE __mmask16 _mm512_test_epi32_mask(__m512i a, __m512i b)
{
uint32x4_t mask_and = vld1q_u32(g_mask_epi32);
__m512i tmp;
tmp.vect_u32[0] = vandq_u32(vtstq_u32(a.vect_u32[0], b.vect_u32[0]), mask_and);
tmp.vect_u32[1] = vandq_u32(vtstq_u32(a.vect_u32[1], b.vect_u32[1]), mask_and);
tmp.vect_u32[2] = vandq_u32(vtstq_u32(a.vect_u32[2], b.vect_u32[2]), mask_and);
tmp.vect_u32[3] = vandq_u32(vtstq_u32(a.vect_u32[3], b.vect_u32[3]), mask_and);
uint32_t r0 = vaddvq_u32(tmp.vect_u32[0]);
uint32_t r1 = vaddvq_u32(tmp.vect_u32[1]);
uint32_t r2 = vaddvq_u32(tmp.vect_u32[2]);
uint32_t r3 = vaddvq_u32(tmp.vect_u32[3]);
__mmask16 res = r0 | (r1 << 4) | (r2 << 8) | (r3 << 12);
return res;
}
FORCE_INLINE __mmask8 _mm512_test_epi64_mask(__m512i a, __m512i b)
{
uint64x2_t mask_and = vld1q_u64(g_mask_epi64);
__m512i tmp;
tmp.vect_u64[0] = vandq_u64(vtstq_u64(a.vect_u64[0], b.vect_u64[0]), mask_and);
tmp.vect_u64[1] = vandq_u64(vtstq_u64(a.vect_u64[1], b.vect_u64[1]), mask_and);
tmp.vect_u64[2] = vandq_u64(vtstq_u64(a.vect_u64[2], b.vect_u64[2]), mask_and);
tmp.vect_u64[3] = vandq_u64(vtstq_u64(a.vect_u64[3], b.vect_u64[3]), mask_and);
uint32_t r0 = vaddvq_u32(tmp.vect_u32[0]);
uint32_t r1 = vaddvq_u32(tmp.vect_u32[1]);
uint32_t r2 = vaddvq_u32(tmp.vect_u32[2]);
uint32_t r3 = vaddvq_u32(tmp.vect_u32[3]);
__mmask8 res = r0 | (r1 << 2) | (r2 << 4) | (r3 << 6);
return res;
}
FORCE_INLINE __m512i _mm512_mul_epi32(__m512i a, __m512i b)
{
__asm__ __volatile__ (
"ins %[a0].s[1], %[a0].s[2] \n\t"
"ins %[a1].s[1], %[a1].s[2] \n\t"
"ins %[a2].s[1], %[a2].s[2] \n\t"
"ins %[a3].s[1], %[a3].s[2] \n\t"
"ins %[b0].s[1], %[b0].s[2] \n\t"
"ins %[b1].s[1], %[b1].s[2] \n\t"
"ins %[b2].s[1], %[b2].s[2] \n\t"
"ins %[b3].s[1], %[b3].s[2] \n\t"
"smull %[a0].2d, %[a0].2s, %[b0].2s \n\t"
"smull %[a1].2d, %[a1].2s, %[b1].2s \n\t"
"smull %[a2].2d, %[a2].2s, %[b2].2s \n\t"
"smull %[a3].2d, %[a3].2s, %[b3].2s \n\t"
:[a0]"+w"(a.vect_s32[0]), [a1]"+w"(a.vect_s32[1]), [a2]"+w"(a.vect_s32[2]), [a3]"+w"(a.vect_s32[3]),
[b0]"+w"(b.vect_s32[0]), [b1]"+w"(b.vect_s32[1]), [b2]"+w"(b.vect_s32[2]), [b3]"+w"(b.vect_s32[3])
:
:
);
return a;
}
FORCE_INLINE __m512i _mm512_mul_epu32(__m512i a, __m512i b)
{
__asm__ __volatile__ (
"ins %[a0].s[1], %[a0].s[2] \n\t"
"ins %[a1].s[1], %[a1].s[2] \n\t"
"ins %[a2].s[1], %[a2].s[2] \n\t"
"ins %[a3].s[1], %[a3].s[2] \n\t"
"ins %[b0].s[1], %[b0].s[2] \n\t"
"ins %[b1].s[1], %[b1].s[2] \n\t"
"ins %[b2].s[1], %[b2].s[2] \n\t"
"ins %[b3].s[1], %[b3].s[2] \n\t"
"umull %[a0].2d, %[a0].2s, %[b0].2s \n\t"
"umull %[a1].2d, %[a1].2s, %[b1].2s \n\t"
"umull %[a2].2d, %[a2].2s, %[b2].2s \n\t"
"umull %[a3].2d, %[a3].2s, %[b3].2s \n\t"
:[a0]"+w"(a.vect_u32[0]), [a1]"+w"(a.vect_u32[1]), [a2]"+w"(a.vect_u32[2]), [a3]"+w"(a.vect_u32[3]),
[b0]"+w"(b.vect_u32[0]), [b1]"+w"(b.vect_u32[1]), [b2]"+w"(b.vect_u32[2]), [b3]"+w"(b.vect_u32[3])
:
:
);
return a;
}
FORCE_INLINE __m512d _mm512_mul_pd(__m512d a, __m512d b)
{
__m512d res_m512d;
res_m512d.vect_f64[0] = vmulq_f64(a.vect_f64[0], b.vect_f64[0]);
res_m512d.vect_f64[1] = vmulq_f64(a.vect_f64[1], b.vect_f64[1]);
res_m512d.vect_f64[2] = vmulq_f64(a.vect_f64[2], b.vect_f64[2]);
res_m512d.vect_f64[3] = vmulq_f64(a.vect_f64[3], b.vect_f64[3]);
return res_m512d;
}
FORCE_INLINE __m512 _mm512_mul_ps(__m512 a, __m512 b)
{
__m512 res_m512;
res_m512.vect_f32[0] = vmulq_f32(a.vect_f32[0], b.vect_f32[0]);
res_m512.vect_f32[1] = vmulq_f32(a.vect_f32[1], b.vect_f32[1]);
res_m512.vect_f32[2] = vmulq_f32(a.vect_f32[2], b.vect_f32[2]);
res_m512.vect_f32[3] = vmulq_f32(a.vect_f32[3], b.vect_f32[3]);
return res_m512;
}
FORCE_INLINE __m512i _mm512_mulhi_epi16(__m512i a, __m512i b)
{
__m512i res;
res.vect_i256[0] = _mm256_mulhi_epi16(a.vect_i256[0], b.vect_i256[0]);
res.vect_i256[1] = _mm256_mulhi_epi16(a.vect_i256[1], b.vect_i256[1]);
return res;
}
FORCE_INLINE __m512i _mm512_mulhi_epu16(__m512i a, __m512i b)
{
__m512i res;
res.vect_i256[0] = _mm256_mulhi_epu16(a.vect_i256[0], b.vect_i256[0]);
res.vect_i256[1] = _mm256_mulhi_epu16(a.vect_i256[1], b.vect_i256[1]);
return res;
}
FORCE_INLINE __m512i _mm512_mulhi_epi32 (__m512i a, __m512i b)
{
__m512i res;
res.vect_i256[0] = _mm256_mulhi_epi32(a.vect_i256[0], b.vect_i256[0]);
res.vect_i256[1] = _mm256_mulhi_epi32(a.vect_i256[1], b.vect_i256[1]);
return res;
}
FORCE_INLINE __m512i _mm512_mulhi_epu32 (__m512i a, __m512i b)
{
__m512i res;
res.vect_i256[0] = _mm256_mulhi_epu32(a.vect_i256[0], b.vect_i256[0]);
res.vect_i256[1] = _mm256_mulhi_epu32(a.vect_i256[1], b.vect_i256[1]);
return res;
}
FORCE_INLINE __m512i _mm512_mullo_epi16(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_s16[0] = vmulq_s16(a.vect_s16[0], b.vect_s16[0]);
res_m512i.vect_s16[1] = vmulq_s16(a.vect_s16[1], b.vect_s16[1]);
res_m512i.vect_s16[2] = vmulq_s16(a.vect_s16[2], b.vect_s16[2]);
res_m512i.vect_s16[3] = vmulq_s16(a.vect_s16[3], b.vect_s16[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_mullo_epi32(__m512i a, __m512i b)
{
__m512i res_m512i;
res_m512i.vect_s32[0] = vmulq_s32(a.vect_s32[0], b.vect_s32[0]);
res_m512i.vect_s32[1] = vmulq_s32(a.vect_s32[1], b.vect_s32[1]);
res_m512i.vect_s32[2] = vmulq_s32(a.vect_s32[2], b.vect_s32[2]);
res_m512i.vect_s32[3] = vmulq_s32(a.vect_s32[3], b.vect_s32[3]);
return res_m512i;
}
FORCE_INLINE __m512i _mm512_mullo_epi64(__m512i a, __m512i b)
{
__m512i res;
res.vect_i256[0] = _mm256_mullo_epi64(a.vect_i256[0], b.vect_i256[0]);
res.vect_i256[1] = _mm256_mullo_epi64(a.vect_i256[1], b.vect_i256[1]);
return res;
}
FORCE_INLINE __m512i _mm512_mullox_epi64(__m512i a, __m512i b)
{
__m512i res;
res.vect_i256[0] = _mm256_mullo_epi64(a.vect_i256[0], b.vect_i256[0]);
res.vect_i256[1] = _mm256_mullo_epi64(a.vect_i256[1], b.vect_i256[1]);
return res;
}
FORCE_INLINE __m512i _mm512_mulhrs_epi16(__m512i a, __m512i b)
{
__m512i res;
res.vect_i256[0] = _mm256_mulhrs_epi16(a.vect_i256[0], b.vect_i256[0]);
res.vect_i256[1] = _mm256_mulhrs_epi16(a.vect_i256[1], b.vect_i256[1]);
return res;
}
FORCE_INLINE __m512d _mm512_mul_round_pd(__m512d a, __m512d b, int rounding)
{
assert((rounding == (_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC)) ||
(rounding == _MM_FROUND_CUR_DIRECTION));
(void)rounding;
__m512d res_m512d;
res_m512d.vect_f64[0] = vmulq_f64(a.vect_f64[0], b.vect_f64[0]);
res_m512d.vect_f64[1] = vmulq_f64(a.vect_f64[1], b.vect_f64[1]);
res_m512d.vect_f64[2] = vmulq_f64(a.vect_f64[2], b.vect_f64[2]);
res_m512d.vect_f64[3] = vmulq_f64(a.vect_f64[3], b.vect_f64[3]);
return res_m512d;
}
FORCE_INLINE __m512 _mm512_mul_round_ps(__m512 a, __m512 b, int rounding)
{
assert((rounding == (_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC)) || \
(rounding == (_MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC)) ||
(rounding == _MM_FROUND_CUR_DIRECTION));
(void)rounding;
__m512 res_m512;
res_m512.vect_f32[0] = vmulq_f32(a.vect_f32[0], b.vect_f32[0]);
res_m512.vect_f32[1] = vmulq_f32(a.vect_f32[1], b.vect_f32[1]);
res_m512.vect_f32[2] = vmulq_f32(a.vect_f32[2], b.vect_f32[2]);
res_m512.vect_f32[3] = vmulq_f32(a.vect_f32[3], b.vect_f32[3]);
return res_m512;
}
FORCE_INLINE __m512i _mm512_sll_epi64(__m512i a, __m128i count)
{
int c = count.vect_s64[0];
__m512i result_m512i;
if (likely(c >= 0 && c < 64)) {
result_m512i.vect_s64[0] = vshlq_n_s64(a.vect_s64[0], c);
result_m512i.vect_s64[1] = vshlq_n_s64(a.vect_s64[1], c);
result_m512i.vect_s64[2] = vshlq_n_s64(a.vect_s64[2], c);
result_m512i.vect_s64[3] = vshlq_n_s64(a.vect_s64[3], c);
} else {
result_m512i.vect_s64[0] = vdupq_n_s64(0);
result_m512i.vect_s64[1] = vdupq_n_s64(0);
result_m512i.vect_s64[2] = vdupq_n_s64(0);
result_m512i.vect_s64[3] = vdupq_n_s64(0);
}
return result_m512i;
}
FORCE_INLINE __m512i _mm512_slli_epi64(__m512i a, unsigned int imm8)
{
__m512i result_m512i;
if (likely(imm8 < 64)) {
result_m512i.vect_s64[0] = vshlq_n_s64(a.vect_s64[0], imm8);
result_m512i.vect_s64[1] = vshlq_n_s64(a.vect_s64[1], imm8);
result_m512i.vect_s64[2] = vshlq_n_s64(a.vect_s64[2], imm8);
result_m512i.vect_s64[3] = vshlq_n_s64(a.vect_s64[3], imm8);
} else {
result_m512i.vect_s64[0] = vdupq_n_s64(0);
result_m512i.vect_s64[1] = vdupq_n_s64(0);
result_m512i.vect_s64[2] = vdupq_n_s64(0);
result_m512i.vect_s64[3] = vdupq_n_s64(0);
}
return result_m512i;
}
FORCE_INLINE __m512i _mm512_srli_epi64(__m512i a, unsigned int imm8)
{
__m512i result_m512i;
if (likely(imm8 < 64)) {
int64x2_t vect_imm = vdupq_n_s64(-imm8);
result_m512i.vect_u64[0] = vshlq_u64(a.vect_u64[0], vect_imm);
result_m512i.vect_u64[1] = vshlq_u64(a.vect_u64[1], vect_imm);
result_m512i.vect_u64[2] = vshlq_u64(a.vect_u64[2], vect_imm);
result_m512i.vect_u64[3] = vshlq_u64(a.vect_u64[3], vect_imm);
} else {
result_m512i.vect_u64[0] = vdupq_n_u64(0);
result_m512i.vect_u64[1] = vdupq_n_u64(0);
result_m512i.vect_u64[2] = vdupq_n_u64(0);
result_m512i.vect_u64[3] = vdupq_n_u64(0);
}
return result_m512i;
}
FORCE_INLINE __m512i _mm512_bslli_epi128(__m512i a, const int imm8)
{
assert(imm8 >= 0 && imm8 <= 255);
__m512i res_m512i;
if (likely(imm8 > 0 && imm8 <= 15)) {
res_m512i.vect_s8[0] = vextq_s8(vdupq_n_s8(0), a.vect_s8[0], 16 - imm8);
res_m512i.vect_s8[1] = vextq_s8(vdupq_n_s8(0), a.vect_s8[1], 16 - imm8);
res_m512i.vect_s8[2] = vextq_s8(vdupq_n_s8(0), a.vect_s8[2], 16 - imm8);
res_m512i.vect_s8[3] = vextq_s8(vdupq_n_s8(0), a.vect_s8[3], 16 - imm8);
} else if (imm8 == 0) {
res_m512i = a;
} else {
res_m512i.vect_s8[0] = vdupq_n_s8(0);
res_m512i.vect_s8[1] = vdupq_n_s8(0);
res_m512i.vect_s8[2] = vdupq_n_s8(0);
res_m512i.vect_s8[3] = vdupq_n_s8(0);
}
return res_m512i;
}
FORCE_INLINE __m512i _mm512_bsrli_epi128(__m512i a, const int imm8)
{