Test build failed on Mac OS M1
Hey, I am building the test project with my Mac m1 machine, and used the following command to build the test source file:
cmake -S . -B build
cmake --build build
but it failed with a lot of incompatible pointer types assigning errors
such as:
/simde/arm/neon/ld1_x4.h:51:24: error: incompatible pointer types assigning to 'const __fp16 *' from 'const simde_float16 *' (aka 'const _Float16 *')
return vld1_f16_x4(ptr);
^~~
/simde/arm/neon/ld1q_x2.h:52:25: error: incompatible pointer types assigning to 'const __fp16 *' from 'const simde_float16 *' (aka 'const _Float16 *')
return vld1q_f16_x2(ptr);
^~~
simde/arm/neon/ld3_dup.h:250:26: error: incompatible pointer types assigning to 'const __fp16 *' from 'const simde_float16 *' (aka 'const _Float16 *')
return vld3q_dup_f16(ptr);
^~~
...
Maybe I should add some flags when run the cmake command, but I did not find any useful information in the CMakeLists.txt file.
Could anyone provide some help?
Hello @SakuragiHnmch and thank you for your issue.
For building the tests, we don't use cmake anymore.
Can you try with meson?
https://github.com/simd-everywhere/simde/blob/master/CONTRIBUTING.md#on-unix
Also, which compiler are you using?
I'm not surprised to see float16 errors. We don't have a macOS M1 in our build matrix and we have had difficulty in guessing the right implementation for systems we can't test: https://github.com/simd-everywhere/simde/blob/f132275f85ab1c1cb1e890538ee552c11ca09c38/simde/simde-f16.h#L64-L66
@mr-c thanks for your reply.
I've tried with meson and the same error still remains. And the complier I used is Clang 15.0.0.
Maybe I should spend some time to figure out what happends with m1 machine.
-
Is that apple's built-in clang (from XCode) or another source? The output from when you ran
meson setupwould be helpful here. -
Are you compiling the latest code from this repository, or a particular release of SIMDe?
-
Lets try out using
__fp16directly from the SIMDe side by adding-DSIMDE_FLOAT16_API=4to the CFLAGS & CXXFLAGS.CFLAGS="-march=native -DSIMDE_FLOAT16_API=4" CXXFLAGS="-march=native -DSIMDE_FLOAT16_API=4" meson setup ..https://github.com/simd-everywhere/simde/blob/f132275f85ab1c1cb1e890538ee552c11ca09c38/simde/simde-f16.h#L60-L62
If that works, I can use the information from meson setup to fix the configuration in SIMDe
https://github.com/simd-everywhere/simde/blob/f132275f85ab1c1cb1e890538ee552c11ca09c38/simde/simde-f16.h#L64-L82
It worked when I add -DSIMDE_FLOAT16_API=4, I can build the test source files now.
I am using built-in clang installed in Xcode to build the latest code from master branch.
When meson setup .. runs, the output is:
The Meson build system
Version: 1.2.3
Source dir: /Users/lanjunkang/Documents/grandline/simde
Build dir: /Users/lanjunkang/Documents/grandline/simde/build
Build type: native build
Project name: SIMDe
Project version: 0.7.7
C compiler for the host machine: cc (clang 15.0.0 "Apple clang version 15.0.0 (clang-1500.0.40.1)")
C linker for the host machine: cc ld64 1015.7
C++ compiler for the host machine: c++ (clang 15.0.0 "Apple clang version 15.0.0 (clang-1500.0.40.1)")
C++ linker for the host machine: c++ ld64 1015.7
Host machine cpu family: aarch64
Host machine cpu: aarch64
Library m found: YES
Compiler for C supports arguments -fopenmp-simd: YES
Compiler for C++ supports arguments -fopenmp-simd: YES
Compiler for C supports arguments -Wpsabi: YES
Compiler for C++ supports arguments -Wpsabi: YES
Library m found: YES
Build targets in project: 1838
NOTICE: Future-deprecated features used:
* 0.64.0: {'copy arg in configure_file'}
Found ninja-1.11.1.git.kitware.jobserver-1 at /Users/lanjunkang/Library/Python/3.9/bin/ninja
But when I run the test, the following failed:
719/1838 arm/neon/cvt/emul/c OK 2.98s 70 subtests passed
▶ 720/1838 cvt/vcvth_s16_f16 FAIL
▶ 720/1838 cvt/vcvtah_s16_f16 FAIL
720/1838 arm/neon/cvt/native/c ERROR 3.08s exit status 1
>>> MALLOC_PERTURB_=46 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvt-native-c
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
../test/arm/neon/cvt.c:47: assertion failed: r == test_vec[i].r (-32768 == 32767)
../test/arm/neon/cvt.c:2106: assertion failed: r == test_vec[i].r (-32768 == 32767)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
721/1838 arm/neon/cvt/emul/cpp OK 2.77s 70 subtests passed
▶ 722/1838 cvt/vcvth_s16_f16 FAIL
▶ 722/1838 cvt/vcvtah_s16_f16 FAIL
722/1838 arm/neon/cvt/native/cpp ERROR 2.75s exit status 1
>>> MALLOC_PERTURB_=158 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvt-native-cpp
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
test/arm/neon/cvt.cpp:47: assertion failed: r == test_vec[i].r (-32768 == 32767)
test/arm/neon/cvt.cpp:2106: assertion failed: r == test_vec[i].r (-32768 == 32767)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
723/1838 arm/neon/cvt_n/emul/c OK 2.78s 43 subtests passed
▶ 724/1838 cvt_n/vcvth_n_s32_f16 FAIL
▶ 724/1838 cvt_n/vcvth_n_s64_f16 FAIL
▶ 724/1838 cvt_n/vcvth_n_u32_f16 FAIL
▶ 724/1838 cvt_n/vcvth_n_u64_f16 FAIL
▶ 724/1838 cvt_n/vcvth_n_f16_s32 FAIL
▶ 724/1838 cvt_n/vcvth_n_f16_s64 FAIL
▶ 724/1838 cvt_n/vcvth_n_f16_u32 FAIL
▶ 724/1838 cvt_n/vcvth_n_f16_u64 FAIL
724/1838 arm/neon/cvt_n/native/c ERROR 2.79s exit status 1
>>> MALLOC_PERTURB_=107 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvt_n-native-c
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
../test/arm/neon/cvt_n.c:184: assertion failed: r10 == test_vec[i].r10 (32767 == 2147483647)
../test/arm/neon/cvt_n.c:287: assertion failed: r13 == test_vec[i].r13 (32767 == 9223372036854775807)
../test/arm/neon/cvt_n.c:437: assertion failed: r10 == test_vec[i].r10 (65535 == 4294967295)
../test/arm/neon/cvt_n.c:509: assertion failed: r10 == test_vec[i].r10 (65535 == 18446744073709551615)
../test/arm/neon/cvt_n.c:669: assertion failed: r3 ~= test_vec[i].r3 (-3764.000000 ~= inf)
../test/arm/neon/cvt_n.c:767: assertion failed: r3 ~= test_vec[i].r3 (3084.000000 ~= -inf)
../test/arm/neon/cvt_n.c:928: assertion failed: r3 ~= test_vec[i].r3 (7768.000000 ~= inf)
../test/arm/neon/cvt_n.c:1026: assertion failed: r3 ~= test_vec[i].r3 (3320.000000 ~= inf)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
725/1838 arm/neon/cvt_n/emul/cpp OK 2.74s 43 subtests passed
▶ 726/1838 cvt_n/vcvth_n_s32_f16 FAIL
▶ 726/1838 cvt_n/vcvth_n_s64_f16 FAIL
▶ 726/1838 cvt_n/vcvth_n_u32_f16 FAIL
▶ 726/1838 cvt_n/vcvth_n_u64_f16 FAIL
▶ 726/1838 cvt_n/vcvth_n_f16_s32 FAIL
▶ 726/1838 cvt_n/vcvth_n_f16_s64 FAIL
▶ 726/1838 cvt_n/vcvth_n_f16_u32 FAIL
▶ 726/1838 cvt_n/vcvth_n_f16_u64 FAIL
726/1838 arm/neon/cvt_n/native/cpp ERROR 2.64s exit status 1
>>> MALLOC_PERTURB_=131 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvt_n-native-cpp
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
test/arm/neon/cvt_n.cpp:184: assertion failed: r10 == test_vec[i].r10 (32767 == 2147483647)
test/arm/neon/cvt_n.cpp:287: assertion failed: r13 == test_vec[i].r13 (32767 == 9223372036854775807)
test/arm/neon/cvt_n.cpp:437: assertion failed: r10 == test_vec[i].r10 (65535 == 4294967295)
test/arm/neon/cvt_n.cpp:509: assertion failed: r10 == test_vec[i].r10 (65535 == 18446744073709551615)
test/arm/neon/cvt_n.cpp:669: assertion failed: r3 ~= test_vec[i].r3 (-3764.000000 ~= inf)
test/arm/neon/cvt_n.cpp:767: assertion failed: r3 ~= test_vec[i].r3 (3084.000000 ~= -inf)
test/arm/neon/cvt_n.cpp:928: assertion failed: r3 ~= test_vec[i].r3 (7768.000000 ~= inf)
test/arm/neon/cvt_n.cpp:1026: assertion failed: r3 ~= test_vec[i].r3 (3320.000000 ~= inf)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
727/1838 arm/neon/cvtm/emul/c OK 2.59s 22 subtests passed
▶ 728/1838 cvtm/vcvtmh_s16_f16 FAIL
728/1838 arm/neon/cvtm/native/c ERROR 2.83s exit status 1
>>> MALLOC_PERTURB_=248 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvtm-native-c
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
../test/arm/neon/cvtm.c:256: assertion failed: r == test_vec[i].r (-32768 == 32767)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
729/1838 arm/neon/cvtm/emul/cpp OK 2.71s 22 subtests passed
▶ 730/1838 cvtm/vcvtmh_s16_f16 FAIL
730/1838 arm/neon/cvtm/native/cpp ERROR 2.73s exit status 1
>>> MALLOC_PERTURB_=209 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvtm-native-cpp
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
test/arm/neon/cvtm.cpp:256: assertion failed: r == test_vec[i].r (-32768 == 32767)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
731/1838 arm/neon/cvtn/emul/c OK 2.78s 22 subtests passed
▶ 732/1838 cvtn/vcvtnh_s16_f16 FAIL
732/1838 arm/neon/cvtn/native/c ERROR 2.78s exit status 1
>>> MALLOC_PERTURB_=226 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvtn-native-c
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
../test/arm/neon/cvtn.c:213: assertion failed: r == test_vec[i].r (-32768 == 32767)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
733/1838 arm/neon/cvtn/emul/cpp OK 2.85s 22 subtests passed
▶ 734/1838 cvtn/vcvtnh_s16_f16 FAIL
734/1838 arm/neon/cvtn/native/cpp ERROR 2.88s exit status 1
>>> MALLOC_PERTURB_=246 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvtn-native-cpp
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
test/arm/neon/cvtn.cpp:213: assertion failed: r == test_vec[i].r (-32768 == 32767)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
735/1838 arm/neon/cvtp/emul/c OK 2.91s 22 subtests passed
▶ 736/1838 cvtp/vcvtph_s16_f16 FAIL
736/1838 arm/neon/cvtp/native/c ERROR 2.56s exit status 1
>>> MALLOC_PERTURB_=213 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvtp-native-c
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
../test/arm/neon/cvtp.c:256: assertion failed: r == test_vec[i].r (-32768 == 32767)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
737/1838 arm/neon/cvtp/emul/cpp OK 2.61s 22 subtests passed
▶ 738/1838 cvtp/vcvtph_s16_f16 FAIL
738/1838 arm/neon/cvtp/native/cpp ERROR 2.71s exit status 1
>>> MALLOC_PERTURB_=18 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvtp-native-cpp
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
test/arm/neon/cvtp.cpp:256: assertion failed: r == test_vec[i].r (-32768 == 32767)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
739/1838 arm/neon/combine/emul/c OK 2.96s 11 subtests passed
...
1838/1838 mips_msa_simd/subv/native/cpp OK 2.66s 4 subtests passed
Summary of Failures:
720/1838 arm/neon/cvt/native/c ERROR 3.08s exit status 1
722/1838 arm/neon/cvt/native/cpp ERROR 2.75s exit status 1
724/1838 arm/neon/cvt_n/native/c ERROR 2.79s exit status 1
726/1838 arm/neon/cvt_n/native/cpp ERROR 2.64s exit status 1
728/1838 arm/neon/cvtm/native/c ERROR 2.83s exit status 1
730/1838 arm/neon/cvtm/native/cpp ERROR 2.73s exit status 1
732/1838 arm/neon/cvtn/native/c ERROR 2.78s exit status 1
734/1838 arm/neon/cvtn/native/cpp ERROR 2.88s exit status 1
736/1838 arm/neon/cvtp/native/c ERROR 2.56s exit status 1
738/1838 arm/neon/cvtp/native/cpp ERROR 2.71s exit status 1
Ok: 1828
Expected Fail: 0
Fail: 10
Unexpected Pass: 0
Skipped: 0
Timeout: 0
Full log written to /Users/lanjunkang/Documents/grandline/simde/build/meson-logs/testlog.txt
FAILED: meson-internal__test
/Users/lanjunkang/Library/Python/3.9/bin/meson test --no-rebuild --print-errorlogs
ninja: build stopped: subcommand failed.
Great, progress!
@yyctw I think those are functions that you added; any insights to why they are failing on macOS clang compiling for the M1 processor?
/simde/arm/neon/ld1_x4.h:51:24: error: incompatible pointer types assigning to 'const __fp16 *' from 'const simde_float16 *' (aka 'const _Float16 *') return vld1_f16_x4(ptr); ^~~ /simde/arm/neon/ld1q_x2.h:52:25: error: incompatible pointer types assigning to 'const __fp16 *' from 'const simde_float16 *' (aka 'const _Float16 *') return vld1q_f16_x2(ptr); ^~~ simde/arm/neon/ld3_dup.h:250:26: error: incompatible pointer types assigning to 'const __fp16 *' from 'const simde_float16 *' (aka 'const _Float16 *') return vld3q_dup_f16(ptr); ^~~
I have sent a PR to fix this compilation error. @SakuragiHnmch, could you please try building again?
Great, progress!
@yyctw I think those are functions that you added; any insights to why they are failing on macOS clang compiling for the M1 processor?
Based on the first compilation error, I believe the macOS M1 processor supports NEON intrinsics. However, the test results differ between macOS and QEMU. Could there be some bugs in Clang or the M1 processor?
@yyctw I applied the commit patch and rebuilt the test, but the test errors still remain:
Summary of Failures:
720/1838 arm/neon/cvt/native/c ERROR 2.63s exit status 1
722/1838 arm/neon/cvt/native/cpp ERROR 2.51s exit status 1
724/1838 arm/neon/cvt_n/native/c ERROR 2.36s exit status 1
726/1838 arm/neon/cvt_n/native/cpp ERROR 2.50s exit status 1
728/1838 arm/neon/cvtm/native/c ERROR 2.79s exit status 1
730/1838 arm/neon/cvtm/native/cpp ERROR 2.82s exit status 1
732/1838 arm/neon/cvtn/native/c ERROR 2.85s exit status 1
734/1838 arm/neon/cvtn/native/cpp ERROR 2.76s exit status 1
736/1838 arm/neon/cvtp/native/c ERROR 2.45s exit status 1
738/1838 arm/neon/cvtp/native/cpp ERROR 2.57s exit status 1
Ok: 1828
Expected Fail: 0
Fail: 10
Unexpected Pass: 0
Skipped: 0
Timeout: 0
But the error log differed from the previous, may be it can help:
718/1838 arm/neon/cnt/native/cpp OK 0.03s 4 subtests passed
▶ 719/1838 cvt/vcvth_s16_f16 FAIL
▶ 719/1838 cvt/vcvtah_s16_f16 FAIL
720/1838 arm/neon/cvt/emul/c OK 0.03s 70 subtests passed
▶ 721/1838 cvt/vcvth_s16_f16 FAIL
▶ 721/1838 cvt/vcvtah_s16_f16 FAIL
▶ 722/1838 cvt_n/vcvth_n_s32_f16 FAIL
▶ 722/1838 cvt_n/vcvth_n_s64_f16 FAIL
▶ 722/1838 cvt_n/vcvth_n_u32_f16 FAIL
▶ 722/1838 cvt_n/vcvth_n_u64_f16 FAIL
▶ 722/1838 cvt_n/vcvth_n_f16_s32 FAIL
▶ 722/1838 cvt_n/vcvth_n_f16_s64 FAIL
▶ 722/1838 cvt_n/vcvth_n_f16_u32 FAIL
▶ 722/1838 cvt_n/vcvth_n_f16_u64 FAIL
719/1838 arm/neon/cvt/native/c ERROR 0.03s exit status 1
>>> MALLOC_PERTURB_=89 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvt-native-c
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
../test/arm/neon/cvt.c:47: assertion failed: r == test_vec[i].r (-32768 == 32767)
../test/arm/neon/cvt.c:2106: assertion failed: r == test_vec[i].r (-32768 == 32767)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
▶ 723/1838 cvt_n/vcvth_n_s32_f16 FAIL
▶ 723/1838 cvt_n/vcvth_n_s64_f16 FAIL
▶ 723/1838 cvt_n/vcvth_n_u32_f16 FAIL
▶ 723/1838 cvt_n/vcvth_n_u64_f16 FAIL
▶ 723/1838 cvt_n/vcvth_n_f16_s32 FAIL
▶ 723/1838 cvt_n/vcvth_n_f16_s64 FAIL
▶ 723/1838 cvt_n/vcvth_n_f16_u32 FAIL
▶ 723/1838 cvt_n/vcvth_n_f16_u64 FAIL
724/1838 arm/neon/cvt/emul/cpp OK 0.03s 70 subtests passed
725/1838 arm/neon/cvt_n/emul/c OK 0.03s 43 subtests passed
721/1838 arm/neon/cvt/native/cpp ERROR 0.04s exit status 1
>>> MALLOC_PERTURB_=216 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvt-native-cpp
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
test/arm/neon/cvt.cpp:47: assertion failed: r == test_vec[i].r (-32768 == 32767)
test/arm/neon/cvt.cpp:2106: assertion failed: r == test_vec[i].r (-32768 == 32767)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
722/1838 arm/neon/cvt_n/native/c ERROR 0.03s exit status 1
>>> MALLOC_PERTURB_=115 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvt_n-native-c
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
../test/arm/neon/cvt_n.c:184: assertion failed: r10 == test_vec[i].r10 (32767 == 2147483647)
../test/arm/neon/cvt_n.c:287: assertion failed: r13 == test_vec[i].r13 (32767 == 9223372036854775807)
../test/arm/neon/cvt_n.c:437: assertion failed: r10 == test_vec[i].r10 (65535 == 4294967295)
../test/arm/neon/cvt_n.c:509: assertion failed: r10 == test_vec[i].r10 (65535 == 18446744073709551615)
../test/arm/neon/cvt_n.c:669: assertion failed: r3 ~= test_vec[i].r3 (-3764.000000 ~= inf)
../test/arm/neon/cvt_n.c:767: assertion failed: r3 ~= test_vec[i].r3 (3084.000000 ~= -inf)
../test/arm/neon/cvt_n.c:928: assertion failed: r3 ~= test_vec[i].r3 (7768.000000 ~= inf)
../test/arm/neon/cvt_n.c:1026: assertion failed: r3 ~= test_vec[i].r3 (3320.000000 ~= inf)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
726/1838 arm/neon/cvt_n/emul/cpp OK 0.03s 43 subtests passed
723/1838 arm/neon/cvt_n/native/cpp ERROR 0.04s exit status 1
>>> MALLOC_PERTURB_=152 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvt_n-native-cpp
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
test/arm/neon/cvt_n.cpp:184: assertion failed: r10 == test_vec[i].r10 (32767 == 2147483647)
test/arm/neon/cvt_n.cpp:287: assertion failed: r13 == test_vec[i].r13 (32767 == 9223372036854775807)
test/arm/neon/cvt_n.cpp:437: assertion failed: r10 == test_vec[i].r10 (65535 == 4294967295)
test/arm/neon/cvt_n.cpp:509: assertion failed: r10 == test_vec[i].r10 (65535 == 18446744073709551615)
test/arm/neon/cvt_n.cpp:669: assertion failed: r3 ~= test_vec[i].r3 (-3764.000000 ~= inf)
test/arm/neon/cvt_n.cpp:767: assertion failed: r3 ~= test_vec[i].r3 (3084.000000 ~= -inf)
test/arm/neon/cvt_n.cpp:928: assertion failed: r3 ~= test_vec[i].r3 (7768.000000 ~= inf)
test/arm/neon/cvt_n.cpp:1026: assertion failed: r3 ~= test_vec[i].r3 (3320.000000 ~= inf)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
▶ 727/1838 cvtm/vcvtmh_s16_f16 FAIL
728/1838 arm/neon/cvtm/emul/c OK 0.08s 22 subtests passed
▶ 729/1838 cvtm/vcvtmh_s16_f16 FAIL
▶ 730/1838 cvtn/vcvtnh_s16_f16 FAIL
727/1838 arm/neon/cvtm/native/c ERROR 0.09s exit status 1
>>> MALLOC_PERTURB_=16 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvtm-native-c
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
../test/arm/neon/cvtm.c:256: assertion failed: r == test_vec[i].r (-32768 == 32767)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
731/1838 arm/neon/cvtm/emul/cpp OK 0.08s 22 subtests passed
▶ 732/1838 cvtn/vcvtnh_s16_f16 FAIL
729/1838 arm/neon/cvtm/native/cpp ERROR 0.08s exit status 1
>>> MALLOC_PERTURB_=246 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvtm-native-cpp
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
test/arm/neon/cvtm.cpp:256: assertion failed: r == test_vec[i].r (-32768 == 32767)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
733/1838 arm/neon/cvtn/emul/c OK 0.08s 22 subtests passed
734/1838 arm/neon/cvtn/emul/cpp OK 0.07s 22 subtests passed
730/1838 arm/neon/cvtn/native/c ERROR 0.09s exit status 1
>>> MALLOC_PERTURB_=159 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvtn-native-c
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
../test/arm/neon/cvtn.c:213: assertion failed: r == test_vec[i].r (-32768 == 32767)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
732/1838 arm/neon/cvtn/native/cpp ERROR 0.08s exit status 1
>>> MALLOC_PERTURB_=61 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvtn-native-cpp
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
test/arm/neon/cvtn.cpp:213: assertion failed: r == test_vec[i].r (-32768 == 32767)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
735/1838 arm/neon/cvtp/emul/c OK 0.03s 22 subtests passed
▶ 736/1838 cvtp/vcvtph_s16_f16 FAIL
▶ 737/1838 cvtp/vcvtph_s16_f16 FAIL
738/1838 arm/neon/cvtp/emul/cpp OK 0.03s 22 subtests passed
736/1838 arm/neon/cvtp/native/c ERROR 0.03s exit status 1
>>> MALLOC_PERTURB_=70 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvtp-native-c
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
../test/arm/neon/cvtp.c:256: assertion failed: r == test_vec[i].r (-32768 == 32767)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
739/1838 arm/neon/combine/emul/c OK 0.02s 11 subtests passed
740/1838 arm/neon/combine/native/c OK 0.02s 11 subtests passed
737/1838 arm/neon/cvtp/native/cpp ERROR 0.04s exit status 1
>>> MALLOC_PERTURB_=54 /Users/lanjunkang/Documents/grandline/simde/build/test/arm/neon/cvtp-native-cpp
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀ ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
test/arm/neon/cvtp.cpp:256: assertion failed: r == test_vec[i].r (-32768 == 32767)
(test program exited with status code 1)
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
741/1838 arm/neon/combine/emul/cpp OK 0.03s 11 subtests passed
I'm not sure whether there are some bugs in Compiler or Apple chips.
@yyctw Have you been generating your test matrices using a real ARM chip, or Qemu?
@yyctw Have you been generating your test matrices using a real ARM chip, or Qemu?
@mr-c I generated the test matrices only using QEMU.
I found that:
- All failed functions are defined in
arm_fp16.h. - The return type of macOS M1 seems not be the same as Clang.
For example, the function
vcvth_n_s32_f16reports the error message../test/arm/neon/cvt_n.c:184: assertion failed: r10 == test_vec[i].r10 (32767 == 2147483647). However, I saw the function definition inarm_fp16.h:
#define vcvth_n_s32_f16(__p0, __p1) __extension__ ({ \
int32_t __ret; \
float16_t __s0 = __p0; \
__ret = (int32_t) __builtin_neon_vcvth_n_s32_f16(__s0, __p1); \
__ret; \
})
The return type of the function is int32_t, but the result on macOS is 32767, which is INT16_MAX. So, @SakuragiHnmch could you please check whether the function definition in the file arm_fp16.h (possibly located at /usr/lib/llvm-15/lib/clang/15.0.7/include/) is the same as the one above?
@yyctw The definition of vcvth_n_s32_f16 is the same as you showed above:
And the clang is a built-in compiler of Xcode:
➜ ~ clang -v
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
@SakuragiHnmch Based on the discussions in both ARM Intrinsics don't build on clang and Why does march=native not work on Apple M1?, could you please try adding -march=native or -mcpu=apple-m1 to c_args and cxx_args in lines 6 and 7 of the file simde/test/meson.build? I'm not sure if it will resolve the issue.
@yyctw It did't work to add the flag -march=native or -mcpu=apple-m1.
I used following command to set up meson
CFLAGS="-march=native -DSIMDE_FLOAT16_API=4" CXXFLAGS="-march=native -DSIMDE_FLOAT16_API=4" meson setup ..
and then run:
ninja test
Before running the above command, I also add -mcpu=apple-m1 in the file simde/test/meson.build.(I am not sure if the flag -march=native in meson.build file takes the same effect as it in the commad above)
simde_c_args = ['-mcpu=apple-m1']
simde_cxx_args = ['-mcpu=apple-m1']
But the test failed again.
Summary of Failures:
720/1838 arm/neon/cvt/native/c ERROR 2.41s exit status 1
722/1838 arm/neon/cvt/native/cpp ERROR 2.50s exit status 1
724/1838 arm/neon/cvt_n/native/c ERROR 2.51s exit status 1
726/1838 arm/neon/cvt_n/native/cpp ERROR 2.49s exit status 1
728/1838 arm/neon/cvtm/native/c ERROR 2.47s exit status 1
730/1838 arm/neon/cvtm/native/cpp ERROR 2.64s exit status 1
732/1838 arm/neon/cvtn/native/c ERROR 2.76s exit status 1
734/1838 arm/neon/cvtn/native/cpp ERROR 3.10s exit status 1
736/1838 arm/neon/cvtp/native/c ERROR 3.28s exit status 1
738/1838 arm/neon/cvtp/native/cpp ERROR 3.33s exit status 1
Ok: 1828
Expected Fail: 0
Fail: 10
Unexpected Pass: 0
Skipped: 0
Timeout: 0
@SakuragiHnmch I don't know why there are inconsistent results between QEMU and the macOS M1 processor.
In branch issue_1099, I added a bug macro to skip those functions on macOS. And I also added new conditions to detect the type of __fp16 in macOS. This should be run directly without any other c_args added.
Any recommendations, @mr-c ?
We should try testing with the latest qemu. It isn't impossible that Apple Silicon / apple clang are wrong, but it seems more likely that qemu is in error.
@yyctw can you
- Build and test the
masterbranch of SIMDe using the latest qemu with a CPU profile and compilation options that matches the capability of a M1 chip? - Review the test results reported here, comparing the plain SIMDe implementations and the Arm intrinsics documentation. If qemu is in error, then the plain implementations will need changing.
I'm also seeing test failures on my Pixel 4a 5g (aarch64 arm8.2-a)
I think the implementation for these intrinsics is wrong
ok 1 cvt_n/vcvth_n_s16_f16
../test/arm/neon/cvt_n.c:184: assertion failed: r10 == test_vec[i].r10 (457472 == 2147483647)
not ok 2 cvt_n/vcvth_n_s32_f16
../test/arm/neon/cvt_n.c:287: assertion failed: r13 == test_vec[i].r13 (223360 == 9223372036854775807)
not ok 3 cvt_n/vcvth_n_s64_f16
ok 4 cvt_n/vcvth_n_u16_f16
../test/arm/neon/cvt_n.c:437: assertion failed: r10 == test_vec[i].r10 (150016 == 4294967295)
not ok 5 cvt_n/vcvth_n_u32_f16
../test/arm/neon/cvt_n.c:509: assertion failed: r10 == test_vec[i].r10 (221056 == 18446744073709551615)
not ok 6 cvt_n/vcvth_n_u64_f16
../test/arm/neon/cvtm.c:316: assertion failed: r == test_vec[i].r (-2147483648 == 2147483647)
not ok 1 cvtm/vcvtms_s32_f32
../test/arm/neon/cvtm.c:622: assertion failed: r == test_vec[i].r (-9223372036854775808 == 9223372036854775807)
not ok 2 cvtm/vcvtmd_s64_f64
../test/arm/neon/cvtp.c:316: assertion failed: r == test_vec[i].r (-2147483648 == 2147483647)
not ok 1 cvtp/vcvtps_s32_f32
../test/arm/neon/cvtp.c:625: assertion failed: r == test_vec[i].r (-9223372036854775808 == 9223372036854775807)
not ok 2 cvtp/vcvtpd_s64_f64
I think this issue has some weird points:
- For
cvt_n.c, I tested it on the Mac server and encountered the same error as @SakuragiHnmch. However, @mr-c didn't get assertions in the last four functions (vcvth_n_f16_{s/u}{32/64}) and also received different assertions in the first four functions. This implies that the behavior ofaarch64 arm8.2-aandarm64might differ.
My clang version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin22.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Assertions of arm64
stderr:
../test/arm/neon/cvt_n.c:184: assertion failed: r10 == test_vec[i].r10 (32767 == 2147483647)
../test/arm/neon/cvt_n.c:287: assertion failed: r13 == test_vec[i].r13 (32767 == 9223372036854775807)
../test/arm/neon/cvt_n.c:437: assertion failed: r10 == test_vec[i].r10 (65535 == 4294967295)
../test/arm/neon/cvt_n.c:509: assertion failed: r10 == test_vec[i].r10 (65535 == 18446744073709551615)
../test/arm/neon/cvt_n.c:669: assertion failed: r3 ~= test_vec[i].r3 (-3764.000000 ~= inf)
../test/arm/neon/cvt_n.c:767: assertion failed: r3 ~= test_vec[i].r3 (3084.000000 ~= -inf)
../test/arm/neon/cvt_n.c:928: assertion failed: r3 ~= test_vec[i].r3 (7768.000000 ~= inf)
../test/arm/neon/cvt_n.c:1026: assertion failed: r3 ~= test_vec[i].r3 (3320.000000 ~= inf)
Assertions of aarch64 arm8.2-a
ok 1 cvt_n/vcvth_n_s16_f16
../test/arm/neon/cvt_n.c:184: assertion failed: r10 == test_vec[i].r10 (457472 == 2147483647)
not ok 2 cvt_n/vcvth_n_s32_f16
../test/arm/neon/cvt_n.c:287: assertion failed: r13 == test_vec[i].r13 (223360 == 9223372036854775807)
not ok 3 cvt_n/vcvth_n_s64_f16
ok 4 cvt_n/vcvth_n_u16_f16
../test/arm/neon/cvt_n.c:437: assertion failed: r10 == test_vec[i].r10 (150016 == 4294967295)
not ok 5 cvt_n/vcvth_n_u32_f16
../test/arm/neon/cvt_n.c:509: assertion failed: r10 == test_vec[i].r10 (221056 == 18446744073709551615)
not ok 6 cvt_n/vcvth_n_u64_f16
- According to ARM documentation, all of these functions actually perform the same operation, FPToFixed, which calls SatQ functions after rounding. The SatQ function saturates the result if it exceeds the range of the return type. The difference between those functions is rounding mode (
cvtp: +infinity,cvtm: -infinity) and the number of shift bits (cvt_n). However, when I testedvcvtah_s16_f16with test case A, I encountered the assertion31776 == -32768. It seems that the results are not saturated toINT16_MINbut rather the integer overflow occurs.
test case A of vcvtah_s16_f16
{ simde_float16_from_float32(HEDLEY_STATIC_CAST(simde_float32_t, INT16_MIN-1000)),
INT16_MIN },
Assertion
../test/arm/neon/cvt.c:2198: assertion failed: r == test_vec[i].r (31776 == -32768)
not ok 44 cvt/vcvtah_s16_f16
The process of integer overflow
simde_float16_from_float32(-33767) = -33760
overflow = 33760 - 32768 = 992
result = INT16_MIN - overflow = INT16_MAX - overflow + 1 = 32767 - 991 = 31776
- Looking at another perspective, if the NEON intrinsics didn't require saturating the result after rounding, the assertion should also appear in other functions (like
vcvtah_u16_f16), not just in bothvcvth_s16_f16andvcvtah_s16_f16.
Considering the mentioned points, I believe there's a higher likelihood of bugs existing in ARM chips rather than bugs in the documentation or QEMU.
Thanks for reading and any recommendations are welcome!
I think the difference between the tests I ran on my Pixel 4a 5g (Snapdragon 765G arm8.2-a) and on the M1 is that the Snapdragon doesn't support 16-bit floating points and related intrinsics. I'm going to comment out all of the affected functions while we debug this further
@yyctw Running with a newer qemu version, I am able to reproduce errors:
$ /opt/qemu/bin/qemu-aarch64 --version
qemu-aarch64 version 8.2.90 (v9.0.0-rc0)
$ meson test -C aarch64-clang-18-fp16 --print-errorlogs arm/neon/cvt{_n,m,n,p,,}/native/c | grep failed
../../../usr/local/src/simde/test/arm/neon/cvt.c:47: assertion failed: r == test_vec[i].r (-32768 == 32767)
../../../usr/local/src/simde/test/arm/neon/cvt.c:2198: assertion failed: r == test_vec[i].r (-32768 == 32767)
../../../usr/local/src/simde/test/arm/neon/cvt_n.c:184: assertion failed: r10 == test_vec[i].r10 (32767 == 2147483647)
../../../usr/local/src/simde/test/arm/neon/cvt_n.c:287: assertion failed: r13 == test_vec[i].r13 (32767 == 9223372036854775807)
../../../usr/local/src/simde/test/arm/neon/cvt_n.c:437: assertion failed: r10 == test_vec[i].r10 (65535 == 4294967295)
../../../usr/local/src/simde/test/arm/neon/cvt_n.c:509: assertion failed: r10 == test_vec[i].r10 (65535 == 18446744073709551615)
../../../usr/local/src/simde/test/arm/neon/cvt_n.c:669: assertion failed: r3 ~= test_vec[i].r3 (-3764.000000 ~= inf)
../../../usr/local/src/simde/test/arm/neon/cvt_n.c:767: assertion failed: r3 ~= test_vec[i].r3 (3084.000000 ~= -inf)
../../../usr/local/src/simde/test/arm/neon/cvt_n.c:928: assertion failed: r3 ~= test_vec[i].r3 (7768.000000 ~= inf)
../../../usr/local/src/simde/test/arm/neon/cvt_n.c:1026: assertion failed: r3 ~= test_vec[i].r3 (3320.000000 ~= inf)
../../../usr/local/src/simde/test/arm/neon/cvtm.c:256: assertion failed: r == test_vec[i].r (-32768 == 32767)
../../../usr/local/src/simde/test/arm/neon/cvtn.c:213: assertion failed: r == test_vec[i].r (-32768 == 32767)
../../../usr/local/src/simde/test/arm/neon/cvtp.c:256: assertion failed: r == test_vec[i].r (-32768 == 32767)
Build failures were fixed in https://github.com/simd-everywhere/simde/pull/1148 ; I'll make a new issue to re-implement the FCVTZS/FCVTMS/FCVTPS/FCVTNS family intrinsics that I had to disable
I think there should be no more test failures on Mac OS M1s, which we now test in our CI.
Please let us know if you have other issues. Thanks again for your report!