File: ci.yml

package info (click to toggle)
simde 0.8.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie, trixie-backports
  • size: 58,264 kB
  • sloc: ansic: 817,393; sh: 315; makefile: 45; python: 26
file content (889 lines) | stat: -rw-r--r-- 34,547 bytes parent folder | download | duplicates (3)
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
name: CI

on:
  push:
    branches-ignore:
      - 'ci/**'
      - '!ci/gha**'
      - 'dependabot/**'
  pull_request:
    branches:
      - 'master'

concurrency:
  group: build-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  checkinstall:
    runs-on: ubuntu-22.04
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 2
    - name: Install APT Dependencies
      run: |
        sudo apt-get install -y ninja-build ninja-build pipx
        pipx install meson==0.55.0
    - run: |
        meson setup build --prefix $PWD/install -Dtests=false
        meson install -C build --quiet
        diff <(find simde/ -type f -name "*.h")  <(cd install/include/; find simde -type f -name "*.h" )

  formatting:
    runs-on: ubuntu-22.04
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 2
    - name: Install pcre2grep
      run: sudo apt-get update && sudo apt-get install -y pcre2-utils
    # Check for trailing whitespace
    - name: Trailing whitespace
      run: find simde/ \( -name '*.c' -o -name '*.h' \) -exec grep -nP '\s+$' {} + && exit 1 || exit 0
    # We use spaces, not tabs.  I don't want to start a holy war here;
    # I don't actually have a strong preference between the two, but I
    # do have a strong preference for consistency, so don't @ me.
    - name: Tabs
      run: find simde/ \( -name '*.c' -o -name '*.h' \) -exec grep -nP '\t' {} + && exit 1 || exit 0
    # s/8/16/ will result in this if the input is x86.
    - name: Bad substitutions
      run: git grep -i 'x''1''6''6' && exit 1 || exit 0
    - name: Incorrect assertions in test/
      run: grep -PR '(?<=[^a-zA-Z0-9_])simde_assert_u?int(8|16|32|64)(?>[^a-zA-Z0-9_])' test/ && exit 1 || exit 0
    # Check to make sure no source files have the executable bit set
    - name: Executable sources
      run: find \( -name '*.c' -o -name '*.h' \) -executable | grep -q '.' && exit 1 || exit 0
    # Make sure neon.h includes all the NEON headers.
    - name: Missing NEON includes
      run: for f in simde/arm/neon/*.h; do grep -q "include \"neon/$(basename "$f")\"" simde/arm/neon.h || (echo "Missing $f" && exit 1); done
    # Make sure sve.h includes all the SVE headers.
    - name: Missing SVE includes
      run: for f in simde/arm/sve/*.h; do grep -q "include \"sve/$(basename "$f")\"" simde/arm/sve.h || (echo "Missing $f" && exit 1); done
    # Make sure msa.h includes all the MSA headers.
    - name: Missing MSA includes
      run: for f in simde/mips/msa/*.h; do grep -q "include \"msa/$(basename "$f")\"" simde/mips/msa.h || (echo "Missing $f" && exit 1); done
    # Make sure we can find the expected header guards.  It's easy to miss this when doing C&P
    - name: Header guards
      run: for file in $(find simde/*/ -name '*.h'); do grep -q "$(echo "$file" | tr '[:lower:]' '[:upper:]' | tr '[:punct:]' '_')" "$file" || (echo "Missing or incorrect header guard in $file" && exit 1); done
    # There should be an empty line at the end of every file
    - name: Newline at EOF
      run: for file in $(find simde -name '*.h'); do if [ -n "$(tail -c 1 "$file")" ]; then echo "No newline at end of $file" && exit 1; fi; done
    # Don't #ifndef ; use !defined(...) instead.  ifndef leads to annoying inconsistencies
    - name: ifndef
      run: for file in $(find simde -name '*.h'); do grep -qP '^ *# *ifndef ' "${file}" && exit 1 || exit 0; done
    # List of headers we want Meson to install
    - name: Meson install headers
      run: for file in $(find simde -name '*.h'); do grep -qF "$(basename "${file}" .h)" meson.build || (echo "${file} missing from top-level meson.build" && exit 1); done
    # Make sure we don't accidentally use `vector ...` instead of SIMDE_POWER_ALTIVEC_VECTOR(...)
    - name: AltiVec raw vector keyword
      run: find simde/ \( -name '*.c' -o -name '*.h' \) -exec grep -nP 'vector( +)((bool|signed|unsigned) +)?(double|float|long long|long|int|short|char)' {} + && exit 1 || exit 0
    # Check indentation of preprocessor directives.
    - name: Preprocessor directive indentation
      run: find simde/*/ -name 'avx*.h' -exec pcre2grep -M '{\n#' {} + && exit 1 || exit 0
    - name: Stray `&& 0`
      run: git grep ' && 0' simde/ test/ && exit 1 || exit 0

  x86:
    runs-on: ubuntu-22.04
    strategy:
      fail-fast: false
      matrix:
        isax:
        - -DSIMDE_NATURAL_VECTOR_SIZE=256 -march=x86-64-v3 -mavx512bw -mavx512vl
        # https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels
        - -march=x86-64 -maes -mpclmul  # the x86-64 baseline is CMOV, CX8, FPU, FXSR, MMX, OSFXSR, SCE, SSE, SSE2
        - -march=x86-64-v2  # CMPXCHG16B, LAHF-SAHF, POPCNT, SSE3, SSE4_1, SSE4_2, SSSE3
        - -march=x86-64-v3  # AVX, AVX2, BMI1, BMI2, F16C, FMA, LZCNT, MOVBE, OSXSAVE
        - -march=x86-64-v4  # AVX512F, AVX512BW, AVX512CD, AVX512DQ, AVX512VL a.k.a. skylake+ (including zen4)
        include:
          - target: tgl
          - isax: -march=x86-64-v4 -mcx16 -mxsave -mpclmul -mfsgsbase -mrdrnd -mhle -mrdseed -maes -mclflushopt -mxsavec -mxsaves -msgx -mpku -msha -mrdpid -mavx512vpopcntdq -mavx512ifma -mavx512vbmi -mavx512vnni -mavx512vbmi2 -mavx512bitalg -mvpclmulqdq -mgfni -mvaes  # icelake
            target: icl
          - isax: -march=x86-64-v4 -mcx16 -mxsave -mpclmul -mfsgsbase -mrdrnd -mhle -mrdseed -maes -mclflushopt -mxsavec -mxsaves -msgx -mpku -msha -mrdpid -mavx512vpopcntdq -mavx512ifma -mavx512vbmi -mavx512vnni -mavx512vbmi2 -mavx512bitalg -mvpclmulqdq -mgfni -mvaes -mpconfig -mwbnoinvd -mclwb -mmovdiri -mmovdir64b -menqcmd -mcldemote -mptwrite -mwaitpkg -mserialize -mtsxldtrk -muintr -mavxvnni -mavx512fp16  # sapphire rapids without bf16
            # See https://github.com/simd-everywhere/simde/issues/1095
            target: spr
    env:
      CFLAGS: -Wall -Wextra -Werror ${{ matrix.isax }}
      CXXFLAGS: -Wall -Wextra -Werror ${{ matrix.isax }}
      INTEL_TARGET: ${{ matrix.target }}
    steps:
    - uses: actions/checkout@v4
      with:
        submodules: recursive
    - name: CPU Information
      run: cat /proc/cpuinfo
    - run: sudo apt-get update
    - name: ccache
      uses: hendrikmuhs/ccache-action@v1.2
      with:
        key: ${{ github.job }}-${{ matrix.isax }}
    - name: Install APT Dependencies
      run: |
        sudo apt-get install -y ninja-build ninja-build python3-pip parallel gcovr g++-12 gcc-12
        sudo apt-get purge -y gcc g++
        sudo ln -s /usr/bin/gcc-12 /usr/bin/gcc
        sudo ln -s /usr/bin/g++-12 /usr/bin/g++
        sudo python3 -m pip install meson==0.55.0
    - name: add ccache to the build path
      run: |
        export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
    - name: Configure
      run: meson setup build -Db_coverage=true || (cat build/meson-logs/meson-log.txt ; false)
    - name: Test run native?
      run: |
        test/check-flags.sh query && echo Tests with $CFLAGS will be run natively
        test/check-flags.sh query || echo Tests with $CFLAGS will be run using SDE
    - name: Build
      run: ninja -C build -v
    - name: Test
      run: meson test -C build --print-errorlogs --wrapper "${GITHUB_WORKSPACE}/test/check-flags.sh sde" $(meson test -C build --list | grep -v emul)
    - name: Coverage Report
      run: ninja -C build -v coverage-xml
    - name: CodeCov.io
      uses: codecov/codecov-action@v4
      with:
        file: ./build/meson-logs/coverage.xml
      env:
        CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

  x86-xop:
    runs-on: ubuntu-22.04
    strategy:
      fail-fast: false
    env:
      CFLAGS: -Wall -Wextra -Werror -march=bdver2
      CXXFLAGS: -Wall -Wextra -Werror -march=bdver2
    steps:
    - uses: actions/checkout@v4
      with:
        submodules: recursive
    - name: CPU Information
      run: cat /proc/cpuinfo
    - name: ccache
      uses: hendrikmuhs/ccache-action@v1.2
      with:
        key: ${{ github.job }}-
    - name: Install APT Dependencies
      run: |
        #sudo add-apt-repository ppa:aschultz/backports
        sudo apt-get update
        sudo apt-get install -y ninja-build ninja-build python3-pip parallel gcovr g++-12 gcc-12 qemu-user-static
        sudo apt-get purge -y gcc g++
        sudo ln -s /usr/bin/gcc-12 /usr/bin/gcc
        sudo ln -s /usr/bin/g++-12 /usr/bin/g++
        sudo python3 -m pip install meson==0.55.0
    - name: add ccache to the build path
      run: |
        export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
    - name: Configure
      run: meson setup build -Db_coverage=true || (cat build/meson-logs/meson-log.txt ; false)
    - name: Build
      run: ninja -C build -v
    # can't test until we find a combination of `gcc -march=` and `qemu -cpu` that both enable XOP and allows qemu to test it
    # - name: Test
    #   run: meson test -C build --print-errorlogs --wrapper "qemu-amd64-static -cpu Opteron_G5-v1"
    # - name: Coverage Report
    #   run: ninja -C build -v coverage-xml
    # - name: CodeCov.io
    #   uses: codecov/codecov-action@v4
    #   with:
    #     file: ./build/meson-logs/coverage.xml
    #   env:
    #     CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

  emscripten:
    runs-on: ubuntu-22.04
    strategy:
      matrix:
        variant:
          - "32"
          - "64"
          - "32-relaxed"
          - "64-relaxed"
    steps:
    - uses: actions/checkout@v4
      with:
        submodules: recursive
    - name: CPU Information
      run: cat /proc/cpuinfo
    - name: Install APT Dependencies
      run: |
        sudo apt-get update && \
        sudo apt-get install -y ninja-build ninja-build python3-pip parallel gcovr &&\
        sudo python3 -m pip install meson==0.55.0
    - name: Install emscripten
      run: |
        git clone https://github.com/emscripten-core/emsdk.git /opt/emsdk
        cd /opt/emsdk
        ./emsdk install tot
        ./emsdk activate tot
        source emsdk_env.sh
    - name: Install v8
      run: |
        sudo npm install jsvu -g
        jsvu --os=linux64 --engines=v8
        sudo ln -s "$HOME/.jsvu/bin/v8" /usr/bin/v8
        ls -l /usr/bin/v8
        ls -l ~/.jsvu || true
        /usr/bin/v8 --help
    - name: Configure
      run: meson setup build --optimization 2 --cross-file docker/cross-files/emscripten${{ matrix.variant }}.cross
    - name: Build
      run: meson compile -C build --verbose
    - name: Test
      run: meson test -C build --print-errorlogs

  native-aliases:
    runs-on: ubuntu-22.04
    env:
      CFLAGS: -DSIMDE_ENABLE_NATIVE_ALIASES -DSIMDE_NATIVE_ALIASES_TESTING -Wall -Wextra -Werror
      CXXFLAGS: -DSIMDE_ENABLE_NATIVE_ALIASES -DSIMDE_NATIVE_ALIASES_TESTING -Wall -Wextra -Werror
    steps:
    - uses: actions/checkout@v4
      with:
        submodules: recursive
    - name: CPU Information
      run: cat /proc/cpuinfo
    - name: Install APT Dependencies
      run: |
        sudo apt-get update && \
        sudo apt-get -yq install libxml2-utils ninja-build parallel gcovr && \
        sudo python3 -m pip install meson==0.55.0
    - name: Convert
      run: ./test/native-aliases.sh
    - name: Configure
      run: meson setup build -Db_coverage=true
    - name: Build
      run: ninja -C build -v
    - name: Test
      run: ninja -C build -v test
    - name: Coverage Report
      run: ninja -C build -v coverage-xml
    - name: CodeCov.io
      uses: codecov/codecov-action@v4
      with:
        file: ./build/meson-logs/coverage.xml
      env:
        CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

  sleef:
    runs-on: ubuntu-22.04
    env:
      CFLAGS: -march=native -Wall -Wextra -Werror
      CXXFLAGS: -march=native -Wall -Wextra -Werror
    steps:
    - uses: actions/checkout@v4
      with:
        submodules: recursive
    - run: sudo apt-get update
    - name: CPU Information
      run: cat /proc/cpuinfo
    - name: Install APT Dependencies
      run: |
        sudo apt-get install -y ninja-build ninja-build parallel gcovr libsleef-dev
        sudo python3 -m pip install meson==0.55.0
    - name: Configure
      run: meson setup build -Dsleef=enabled -Db_coverage=true
    - name: Build
      run: ninja -C build -v
    - name: Test
      run: meson test -C build --print-errorlogs $(meson test -C build --list | grep -v emul)
    - name: Coverage Report
      run: ninja -C build -v coverage-xml
    - name: CodeCov.io
      uses: codecov/codecov-action@v4
      with:
        file: ./build/meson-logs/coverage.xml
      env:
        CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

  gcc:
    strategy:
      fail-fast: false
      matrix:
        include:
        - version: 9
          distro: ubuntu-20.04
          arch_flags: -march=native
        - version: 10
          distro: ubuntu-20.04
          arch_flags: -march=native
        - version: 10
          distro: ubuntu-20.04
          arch_flags: -ffast-math
          ccache: 'true'
        - version: 11
          distro: ubuntu-22.04
          arch_flags: -march=native
        - version: 11
          distro: ubuntu-22.04
          arch_flags: -ffast-math
          ccache: 'true'
        - version: 12
          distro: ubuntu-22.04
          arch_flags: -march=native
        - version: 12
          distro: ubuntu-22.04
          arch_flags: -ffast-math
          ccache: 'true'
        - version: 13
          distro: ubuntu-22.04
          arch_flags: -march=native
        - version: 13
          distro: ubuntu-22.04
          arch_flags: -ffast-math
          ccache: 'true'
    runs-on: ${{ matrix.distro }}
    env:
      CFLAGS: ${{ matrix.arch_flags }} -Wall -Wextra -Werror
      CXXFLAGS: ${{ matrix.arch_flags }} -Wall -Wextra -Werror
    steps:
    - uses: actions/checkout@v4
      with:
        submodules: recursive
    - name: CPU Information
      run: cat /proc/cpuinfo
    - name: Install APT Dependencies
      run: |
        sudo add-apt-repository ppa:ubuntu-toolchain-r/test
        sudo apt-get update
        sudo apt-get -yq install gcovr python3-pip ninja-build parallel gcc-${{ matrix.version }} g++-${{ matrix.version }}
        sudo apt-get -y purge g++ gcc
        sudo python3 -m pip install meson==0.55.0
    - name: ccache
      uses: hendrikmuhs/ccache-action@v1.2
      if: ${{ matrix.ccache == 'true' }}
      with:
        key: ${{ github.job }}-${{ matrix.version }}-${{ matrix.distro }}-${{ matrix.arch_flags }}
    - name: add ccache to the build path
      run: |
        export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
        sudo ln -s /usr/bin/gcc-${{ matrix.version }} /usr/bin/gcc
        sudo ln -s /usr/bin/g++-${{ matrix.version }} /usr/bin/g++
    - name: Configure
      run: meson setup build
    - name: Build
      run: meson compile -C build --verbose
    - name: Test
      run: meson test -C build --print-errorlogs $(meson test -C build --list | grep -v emul)

  gcc-qemu:
    strategy:
      fail-fast: false
      matrix:
        include:
        - version: 12
          cross: armel
          arch_gnu_abi: eabi
          arch_deb: armel
          arch_gnu: arm
          distro: ubuntu-22.04
        - version: 12
          cross: armv7
          arch_gnu: arm
          arch_gnu_abi: eabihf
          arch_deb: armhf
          distro: ubuntu-22.04
        - version: 12
          cross: aarch64
          arch_gnu: aarch64
          arch_deb: arm64
          distro: ubuntu-22.04
        - extra: -32bit
          version: 12
          cross: armv8
          arch_gnu: arm
          arch_gnu_abi: eabihf
          arch_deb: armhf
          distro: ubuntu-22.04
        - version: 12
          cross: riscv64
          arch_gnu: riscv64
          arch_deb: riscv64
          distro: ubuntu-22.04
        - extra: -O3
          version: 12
          cross: riscv64
          arch_gnu: riscv64
          arch_deb: riscv64
          distro: ubuntu-22.04
        - version: 12
          cross: s390x
          arch_gnu: s390x
          arch_deb: s390x
          distro: ubuntu-22.04
        - version: 12
          cross: power9
          arch_gnu: powerpc64le
          arch_deb: ppc64el
          distro: ubuntu-22.04
       # - version: 12  # needs newer Ubuntu version (23.04+)
       #   cross: mips64el
       #   arch_gnu: mips64el
       #   arch_gnu_abi: abi64
       #   arch_deb: mips64el
       #   distro: ubuntu-22.04
    runs-on: ${{ matrix.distro }}
    steps:
    - uses: actions/checkout@v4
      with:
        submodules: recursive
    - run: sudo apt-get update
    - name: CPU Information
      run: cat /proc/cpuinfo
    - name: Install APT Dependencies
      run: |
        sudo add-apt-repository ppa:savoury1/virtualisation
        sudo apt-get update -y
        sudo apt-get -yq install ninja-build parallel \
          gcc-${{ matrix.version }}-${{ matrix.arch_gnu }}-linux-gnu${{ matrix.arch_gnu_abi }} \
          g++-${{ matrix.version }}-${{ matrix.arch_gnu }}-linux-gnu${{ matrix.arch_gnu_abi }} binfmt-support \
          qemu-user-static python3-pip libc6-${{ matrix.arch_deb }}-cross libstdc++-${{ matrix.version }}-dev-${{ matrix.arch_deb }}-cross
        sudo python3 -m pip install meson==0.55.0
    - name: ccache
      uses: hendrikmuhs/ccache-action@v1.2
      with:
        key: ${{ github.job }}-${{ matrix.distro }}-${{ matrix.cross }}
    - name: add ccache to the build path
      run: |
        export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
    - name: Configure
      run: meson setup --cross-file=docker/cross-files/${{ matrix.cross }}-gcc-${{ matrix.version }}${{ matrix.extra}}-ccache.cross build
    - name: Build
      run: ninja -C build -v
    - name: Test
      run: meson test -C build --print-errorlogs --print-errorlogs $(meson test -C build --list | grep -v emul)

  clang-qemu-rvv:
    strategy:
      fail-fast: false
      matrix:
        include:
        - version: 17
          cross: riscv64+rvv_vlen128_elen64
          arch_gnu: riscv64
          arch_deb: riscv64
          distro: ubuntu-22.04
        - version: 17
          cross: riscv64+rvv_vlen256_elen64
          arch_gnu: riscv64
          arch_deb: riscv64
          distro: ubuntu-22.04
        - version: 17
          cross: riscv64+rvv_vlen512_elen64
          arch_gnu: riscv64
          arch_deb: riscv64
          distro: ubuntu-22.04
        - version: 17
          cross: riscv64+rvv_vlen128_elen64_zvfh
          arch_gnu: riscv64
          arch_deb: riscv64
          distro: ubuntu-22.04
        - version: 17
          cross: riscv64+rvv_vlen256_elen64_zvfh
          arch_gnu: riscv64
          arch_deb: riscv64
          distro: ubuntu-22.04
        - version: 17
          cross: riscv64+rvv_vlen512_elen64_zvfh
          arch_gnu: riscv64
          arch_deb: riscv64
          distro: ubuntu-22.04
    runs-on: ${{ matrix.distro }}
    container:
      image: amd64/ubuntu:23.10
    steps:
    - run: apt-get update
    - name: Install git
      run: |
        apt-get install -y git
    - uses: actions/checkout@v4
      with:
        submodules: recursive
    - name: CPU Information
      run: cat /proc/cpuinfo
    - name: Install APT Dependencies
      run: |
        apt-get install -y python3 python3-pip git ninja-build pkg-config libglib2.0-dev \
          lsb-release wget software-properties-common gnupg qemu-user pipx
        apt-get install -y clang-${{ matrix.version }} lldb-${{ matrix.version }} lld-${{ matrix.version }}
        #add-apt-repository ppa:savoury1/virtualisation
        #add-apt-repository ppa:savoury1/display
        apt-get update -y
        apt-get -yq install ninja-build parallel \
          binfmt-support libc6-${{ matrix.arch_deb }}-cross \
          libstdc++-12-dev-${{ matrix.arch_deb }}-cross binutils-${{ matrix.arch_gnu }}-linux-gnu
        apt install meson
    - name: ccache
      uses: hendrikmuhs/ccache-action@v1.2
      with:
        key: ${{ github.job }}-${{ matrix.distro }}-${{ matrix.cross }}
    - name: add ccache to the build path
      run: |
        export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
    - name: Configure
      run: |
        meson setup --cross-file=docker/cross-files/${{ matrix.cross }}-clang-${{ matrix.version }}-ccache.cross build \
          || (cat build/meson-logs/meson-log.txt ; false)
    - name: Build
      run: ninja -C build -v
    - name: Test
      run: meson test -C build --print-errorlogs --print-errorlogs $(meson test -C build --list | grep -v emul)

  clang-qemu:
    strategy:
      fail-fast: false
      matrix:
        include:
        - version: 17
          cross: armv7
          arch_deb: armhf
          arch_gnu_abi: eabihf
          arch_gnu: arm
          distro: ubuntu-22.04
        - version: 17
          cross: aarch64
          arch_gnu: aarch64
          arch_deb: arm64
          distro: ubuntu-22.04
        - version: 17
          cross: armel
          arch_gnu_abi: eabi
          arch_deb: armel
          arch_gnu: arm
          distro: ubuntu-22.04
        - version: 17
          cross: riscv64
          arch_gnu: riscv64
          arch_deb: riscv64
          distro: ubuntu-22.04
        # - version: 17
        #   cross: s390x
        #   arch_gnu: s390x
        #   arch_deb: s390x
        #   distro: ubuntu-22.04
        - version: 17
          cross: ppc64el
          arch_deb: ppc64el
          arch_gnu: powerpc64le
          distro: ubuntu-22.04
        # - version: 17
        #   cross: mips64el  # needs newer Ubuntu (23.04+)
        #   arch_deb: mips64el
        #   arch_gnu: mips64el
        #   arch_gnu_abi: abi64
        #   distro: ubuntu-22.04
    runs-on: ${{ matrix.distro }}
    steps:
    - uses: actions/checkout@v4
      with:
        submodules: recursive
    - run: sudo apt-get update
    - name: CPU Information
      run: cat /proc/cpuinfo
    - name: Install APT Dependencies
      run: |
        sudo add-apt-repository ppa:savoury1/virtualisation
        sudo add-apt-repository ppa:savoury1/build-tools
        sudo add-apt-repository ppa:savoury1/display
        sudo apt-get update -y
        sudo apt-get -yq install ninja-build parallel \
          binfmt-support clang-${{ matrix.version }} clang++-${{ matrix.version }} \
          qemu-user-static python3-pip libc6-${{ matrix.arch_deb }}-cross libstdc++-12-dev-${{ matrix.arch_deb }}-cross \
          binutils-${{ matrix.arch_gnu }}-linux-gnu${{ matrix.arch_gnu_abi }}
        sudo python3 -m pip install meson==0.55.0
    - name: ccache
      uses: hendrikmuhs/ccache-action@v1.2
      with:
        key: ${{ github.job }}-${{ matrix.distro }}-${{ matrix.cross }}
    - name: add ccache to the build path
      run: |
        export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
    - name: Configure
      run: |
        meson setup --cross-file=docker/cross-files/${{ matrix.cross }}-clang-${{ matrix.version }}-ccache.cross build \
          || (cat build/meson-logs/meson-log.txt ; false)
    - name: Build
      run: ninja -C build -v
    - name: Test
      run: meson test -C build --print-errorlogs --print-errorlogs $(meson test -C build --list | grep -v emul)

  clang:
    strategy:
      fail-fast: false
      matrix:
        include:
        - version: "7"
          distro: ubuntu-20.04
          arch_flags: -march=native
        # clang-8 is tested on Semaphore-CI https://nemequ.semaphoreci.com/projects/simde
        - version: "9"
          distro: ubuntu-20.04
          arch_flags: -march=native
        # clang-10 is tested on Semaphore-CI https://nemequ.semaphoreci.com/projects/simde
        - version: "11"
          distro: ubuntu-22.04
          arch_flags: -march=native
        - version: "12"
          distro: ubuntu-20.04
          arch_flags: -march=native
        - version: "12"
          distro: ubuntu-20.04
          arch_flags: -ffast-math
          ccache: 'true'
        - version: "13"
          distro: ubuntu-22.04
          arch_flags: -march=native
        - version: "13"
          distro: ubuntu-22.04
          arch_flags: -ffast-math
          ccache: 'true'
        - version: "14"
          distro: ubuntu-22.04
          arch_flags: -march=native
        - version: "14"
          distro: ubuntu-22.04
          arch_flags: -ffast-math
          ccache: 'true'
        - version: "15"
          distro: ubuntu-22.04
          arch_flags: -march=native
        - version: "15"
          distro: ubuntu-22.04
          arch_flags: -ffast-math
          ccache: 'true'
        - version: "16"
          distro: ubuntu-22.04
          arch_flags: -march=native -Wno-unsafe-buffer-usage
        - version: "16"
          distro: ubuntu-22.04
          arch_flags: -ffast-math -Wno-unsafe-buffer-usage
          ccache: 'true'
        - version: "17"
          distro: ubuntu-22.04
          arch_flags: -march=native -Wno-unsafe-buffer-usage
        - version: "17"
          distro: ubuntu-22.04
          arch_flags: -ffast-math -Wno-unsafe-buffer-usage
          ccache: 'true'
        - version: "17"
          distro: ubuntu-22.04
          arch_flags: -march=native -Wno-unsafe-buffer-usage -O2
    runs-on: ${{ matrix.distro }}
    env:
      CFLAGS: ${{ matrix.arch_flags }} -Wall -Weverything -Werror -fno-lax-vector-conversions
      CXXFLAGS: ${{ matrix.arch_flags }} -Wall -Weverything -Werror -fno-lax-vector-conversions
    steps:
    - uses: actions/checkout@v4
      with:
        submodules: recursive
    - name: CPU Information
      run: cat /proc/cpuinfo
    - name: Install APT Dependencies
      run: |
        sudo add-apt-repository ppa:ubuntu-toolchain-r/test
        sudo add-apt-repository ppa:savoury1/build-tools
        sudo add-apt-repository ppa:savoury1/display
        sudo add-apt-repository ppa:savoury1/llvm-defaults-16
        sudo apt-get update
        sudo apt-get -yq install gcovr ninja-build python3-pip clang-${{ matrix.version }}
        sudo python3 -m pip install meson==0.55.0
        sudo rm /usr/bin/gcc /usr/bin/g++ /usr/bin/cc /usr/bin/c++
        sudo ln -s $(command -v clang-${{ matrix.version }}) /usr/bin/cc
        sudo ln -s $(command -v clang-${{ matrix.version }}) /usr/bin/c++
    - name: ccache
      uses: hendrikmuhs/ccache-action@v1.2
      if: ${{ matrix.ccache == 'true' }}
      with:
        key: ${{ github.job }}-${{ matrix.version }}-${{ matrix.distro }}-${{ matrix.arch_flags }}
    - name: add ccache to the build path
      if: ${{ matrix.ccache == 'true' }}
      run: |
        export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
    - name: Configure
      run: meson setup build
    - name: Build
      run: meson compile -C build --verbose
    - name: Test
      run: meson test -C build --print-errorlogs $(meson test -C build --list | grep -v emul)

  macos:
    strategy:
      fail-fast: false
      matrix:
        # https://www.jessesquires.com/blog/2020/01/06/selecting-an-xcode-version-on-github-ci/
        # https://github.com/actions/runner-images/blob/main/images/macos/macos-11-Readme.md#xcode
        # https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md#xcode
        # https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode
        # https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md
        # https://trac.macports.org/wiki/XcodeVersionInfo
        include:
          - xcode: "11.7"
            os: macos-11
            arch_flags: -Wno-complex-component-init
          - xcode: "12.4"
            os: macos-11
            arch_flags: -Wno-poison-system-directories  # due to meson test
          - xcode: "12.5.1"
            os: macos-11
            arch_flags: -Wno-poison-system-directories  # due to meson test
          - xcode: "13.1"
            os: macos-12
            arch_flags: -Wno-poison-system-directories  # due to meson test
          - xcode: "13.3.1"
            os: macos-12
            arch_flags: -Wno-poison-system-directories  # due to meson test
          - xcode: "13.4.1"
            os: macos-12
            arch_flags: -Wno-poison-system-directories  # due to meson test
          - xcode: "14.2"
            os: macos-13
            arch_flags: -Wno-poison-system-directories  # due to meson test
          - xcode: "14.3.1"
            os: macos-14  # arm64
            arch_flags: -march=native -Wno-poison-system-directories
              # "-Wno-poison-system-directories": due to meson test
              # "-march=native": without, or with -mcpu=apple-m1 then unavailable __ARM_FEATURE_s get enabled
          - xcode: "15.2"
            os: macos-14  # arm64
            arch_flags: -march=native -Wno-poison-system-directories
              # "-Wno-poison-system-directories": due to meson test
              # "-march=native": without, or with -mcpu=apple-m1 then unavailable __ARM_FEATURE_s get enabled
    runs-on: ${{ matrix.os }}
    env:
      DEVELOPER_DIR:  /Applications/Xcode_${{ matrix.xcode }}.app
      CFLAGS: ${{ matrix.arch_flags }} -Wall -Weverything -Werror -Wno-complex-component-init
      CXXFLAGS: ${{ matrix.arch_flags }} -Wall -Weverything -Werror -Wno-complex-component-init
    steps:
    - uses: actions/checkout@v4
      with:
        submodules: recursive
    # - name: System Information
    #   run: system_profiler
    - name: Compiler version
      run: cc --version
    - name: ccache
      uses: hendrikmuhs/ccache-action@v1.2
      with:
        key: ${{ github.job }}-${{ matrix.xcode }}
    - name: Python install bug workaround # https://github.com/actions/setup-python/issues/577
      run: |
          find /usr/local/bin -type l -exec sh -c 'readlink -f "$1" \
          | grep -q ^/Library/Frameworks/Python.framework/Versions/' _ {} \; -exec rm -v {} \;
    - name: Install Homebrew Dependencies
      run: brew install meson ninja # gcovr
    - name: Configure
      run: meson setup build || (cat build/meson-logs/meson-log.txt ; false) # -Db_coverage=true
    - name: Build
      run: ninja -C build -v
    - name: Test
      run: meson test -C build --print-errorlogs $(meson test -C build --list | grep -v emul)
    # - name: Coverage Report
    #   run: ninja -C build -v coverage-xml
    # - name: CodeCov.io
    #   uses: codecov/codecov-action@v4
    #   with:
    #     file: ./build/meson-logs/coverage.xml
    #   env:
    #     CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

  icc:
    runs-on: ubuntu-22.04
    env:
      CC: /home/runner/.local/bin/icx
      CXX: /home/runner/.local/bin/icpx
      CFLAGS: -Wall -Werror -march=native -fp-model precise
      CXXFLAGS: -Wall -Werror -march=native -fp-model precise
    steps:
    - uses: actions/checkout@v4
    - name: CPU Information
      run: cat /proc/cpuinfo
    - name: Install APT Dependencies
      run: sudo apt-get install -y ninja-build python3-pip && sudo pip install meson==0.64
    - name: Install ICC
      run: |
        # download the key to system keyring
        wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
        | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
        # add signed entry to apt sources and configure the APT client to use Intel repository:
        echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
        sudo apt-get update
        sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp
        mkdir -p ~/.local/bin/ || true
        for exe in icx icpx; do
          printf '#!/bin/bash\nARGS="$@"\nsource /opt/intel/oneapi/compiler/latest/env/vars.sh >/dev/null\n%s ${ARGS}\n' "${exe}" > ~/.local/bin/"${exe}"
          chmod 0755 ~/.local/bin/"${exe}";
        done
    - name: Configure
      run: meson setup build
    - name: Build
      run: ninja -C build -v
    - name: Test
      run: meson test -C build --print-errorlogs $(meson test -C build --list | grep -v emul)

  msvc-arm64:
    name: Windows MSVC-AArch64
    runs-on: [windows-latest]
    env:
      CFLAGS: /WX /Z7
      CXXFLAGS: /WX /Z7
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          submodules: recursive
      - name: Install Meson, Ninja and coverage
        run: |
          python3 -m pip install --upgrade ninja meson
          choco install opencppcoverage codecov
      - name: Use ARM64 Developer Command Prompt
        uses: ilammy/msvc-dev-cmd@v1
        with:
          arch: amd64_arm64
      - name: Configure and Build
        run: |
          meson --backend=ninja build --cross-file test/arm64cl.txt
          ninja -C build test

  linux-gcc-loongarch64:
    runs-on: ubuntu-22.04
    steps:
    - uses: actions/checkout@v4
    - name: CPU Information
      run: cat /proc/cpuinfo
    - name: Install APT Dependencies
      run: |
        sudo add-apt-repository ppa:savoury1/virtualisation
        sudo apt-get install -y ninja-build ninja-build meson qemu-user-static
    - name: Download and install loongarch64-toolchain
      run: |
        wget https://github.com/loongson/build-tools/releases/download/2022.09.06/loongarch64-clfs-7.3-cross-tools-gcc-glibc.tar.xz
        tar -xf loongarch64-clfs-7.3-cross-tools-gcc-glibc.tar.xz -C /opt
    - name: ccache
      uses: hendrikmuhs/ccache-action@v1.2
      with:
        key: ${{ github.job }}-loongarch64-gcc-13
    - name: set env
      run: |
        echo "LD_LIBRARY_PATH=/opt/cross-tools/target/usr/lib64:/opt/cross-tools/loongarch64-unknown-linux-gnu/lib64:$LD_LIBRARY_PATH" >> $GITHUB_ENV
        echo "PATH=$GITHUB_WORKSPACE:/opt/cross-tools/bin:$PATH" >> $GITHUB_ENV
    - name: Disable SVML tests
      run: |
        sed -i "/svml/d" test/x86/meson.build
        rm test/x86/svml.c
        echo "Due to the qemu versions 7.2 through 8.0 causing timeouts in four sets of test cases,"
        echo "the SVML tests have been temporarily disabled."
    - name: Disable RND*X tests
      run: |
        sed -i "/rndx/d" meson.build
        sed -i "/rnd..x/d" meson.build
        rm test/arm/neon/rndx.c test/arm/neon/rnd32x.c test/arm/neon/rnd64x.c
        echo "Due to the qemu versions 7.2 through 8.0 causing timeouts in four sets of test cases,"
        echo "the RNDX, RND32X, and RND64X tests have been temporarily disabled."
    - name: Configure
      run: meson setup build --cross-file=docker/cross-files/loongarch64-gcc-13-ccache.cross
    - name: Build
      run: meson compile -C build -v
    - name: Test
      run: meson test -C build --print-errorlogs