nova-simd icon indicating copy to clipboard operation
nova-simd copied to clipboard

Some tests fail on arm64 on macOS

Open dyfer opened this issue 3 years ago • 2 comments

After commenting out tests that wouldn't compile (see #10), here are the tests that fail on arm64 on macOS (Apple M1 CPU, Clang):

./simd_binary_tests
Running 65 test cases...
/path/to/nova-simd/testsuite/test_helper.hpp:50: fatal error: in "over_comparer_vv": difference{7.00122e-07} between ref[i]{0.766212404} and test[i]{0.766211867} exceeds 2.00000002e-07
/path/to/nova-simd/testsuite/test_helper.hpp:50: fatal error: in "over_comparer_vs": difference{2.06854e-07} between ref[i]{0.576296568} and test[i]{0.576296449} exceeds 2.00000002e-07
/path/to/nova-simd/testsuite/test_helper.hpp:50: fatal error: in "over_comparer_sv": difference{4.0017e-06} between ref[i]{0.253213376} and test[i]{0.253212363} exceeds 2.00000002e-07

*** 3 failures are detected in the test module "Master Test Suite"
./simd_unary_tests
Running 9 test cases...
/path/to/nova-simd/testsuite/test_helper.hpp:50: fatal error: in "reciprocal_tester": difference{3.81471e-06} between ref[i]{1} and test[i]{0.999996185} exceeds 9.99999997e-07

*** 1 failure is detected in the test module "Master Test Suite"
./simd_math_tests
Running 14 test cases...
/path/to/nova-simd/testsuite/test_helper.hpp:50: fatal error: in "signed_sqrt_tests": difference{0.00207162} between ref[i]{-4.46289062} and test[i]{-4.47213602} exceeds 4.99999987e-06

*** 1 failure is detected in the test module "Master Test Suite"
./vec_test
Running 4 test cases...
/path/to/nova-simd/testsuite/vec_test.cpp:153: fatal error: in "reciprocal_tester": difference{3.81471e-06} between result{0.249999046} and 0.25{0.25} exceeds 1e-05%

*** 1 failure is detected in the test module "Master Test Suite"

In particular simd_math_tests seems to be catching an issue we see in SuperCollider with the behavior of sqrt. I'd be happy to try any solutions you might have, but I don't know enough to propose the fixes on my own. I'd appreciate any help with that. Thanks!

dyfer avatar Oct 28 '22 17:10 dyfer

could you try to changes this?

    static inline float32x4_t gen_sign_mask(void)
    {
        static const int sign_mask = 0x80000000;
        float * casted = (float*)(&sign_mask);
        return vdupq_n_f32(*casted);
    }

to

    static inline float32x4_t gen_sign_mask(void)
    {
        return set_bitmask(0x80000000);
    }

and similar for gen_abs_mask?

timblechmann avatar Nov 02 '22 05:11 timblechmann

Yes, after looking at the SSE implementation I tried that already. It compiles, but the error is still there - it gives the same result as the original code - difference{0.00207162} in the simd_math_tests is the same.

dyfer avatar Nov 02 '22 07:11 dyfer