simd-everywhere / simde

Implementations of SIMD instruction sets for systems which don't natively support them.
https://simd-everywhere.github.io/blog/
MIT License
2.36k stars 247 forks source link

How to run a specific test? #890

Open junaruga opened 3 years ago

junaruga commented 3 years ago

Related to the contributing document , I thought if I knew the way to run a specific test, it would be useful to debug or report. Is there a way to do it?

  1. How to run only tests for a specific family? e.g. How to run tests for only roundscale in simde_avx512_families in meson.build (top level).

  2. How to run a specific test? e.g. How to run only test_simde_mm_cvt_ps2pi in test/x86/sse.c?

Thanks.

ngzhian commented 3 years ago

For NEON, the test definition makes it such that I can do meson test -C build-cross 'arm/neon/ld1/native/c' to run a single test file (ld1.c).

Looking at the x86 test setup, it looks like you can only run per SSE extension. So I don't think you can do that.

ngzhian commented 3 years ago

Btw, you can use meson test --list to list all tests, here is a snippet:

x86/avx512/xorsign/emul/c                                                                                                                                                                                                                                     (37 results) [1036/8790]
x86/avx512/xorsign/native/c
x86/avx512/xorsign/emul/cpp
x86/avx512/xorsign/native/cpp
x86/mmx/emul/c
x86/mmx/native/c
x86/mmx/emul/cpp
x86/mmx/native/cpp
x86/sse/emul/c
x86/sse/native/c
x86/sse/emul/cpp
x86/sse/native/cpp
x86/sse2/emul/c

So for SSE/SSE2, you cannot run an individual test. But for AVX512, you an run just xorsign or roundscale tests.

nemequ commented 3 years ago

Zhi's answer is correct, but here is a little more info which may help:

Using meson to run a single test works, but the disadvantage is that it will actually compile everything. You can also use ninja to compile a single test and it will only compile that test ninja test/x86/avx512/roundscale-native-c (for the native C version, you can use ninja test/x86/avx512/roundscale-{native,emul}-{c,cpp} to test all four versions).

I often use this during development; my go-to is something like: INSN=x86/avx512/roundscale; ninja test/$INSN-{native,emul}-c && qemu-aarch64-static ./test/$INSN-native-c && qemu-aarch64-static ./test/$INSN-emul-c

If you're using Meson you have to run all the tests in a specific suite. On x86 prior to AVX-512 that can be pretty annoying since all the (for example) SSE2 tests are in a single suite, but for AVX-512 as well as most other architectures the tests are broken up by function instead of ISA extension, so for example you can use test/x86/avx512/roundscale-native-c to test the AVX-512 roundscale functions.

Honestly, the tests are really all fast enough that running a single suite shouldn't really be a problem (SVML is, IMHO, the only real possible exception), but if if you use CMake then the test suite uses µnit which is capable of running a single test (just pass the test name as an argument to run-tests). One of the many drawbacks, though, is that everything has to be compiled and linked, which is pretty much guaranteed to take longer than running the tests.

mr-c commented 3 years ago

Zhi's answer is correct, but here is a little more info which may help:

Hey Evan. Can you copy this information into the docs or a wiki page?

junaruga commented 3 years ago

Sorry for my late response, and thanks for your info. I will take a look at it!