Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@ jobs:

- name: 'CMake Build Release'
run: cmake --build ${{ github.workspace }}/release --config Release --parallel 4

- name: 'Test Release'
run: ctest --test-dir ${{ github.workspace }}/release -C Release --output-on-failure
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ if(FASTSIMD_DISPATCH_CLASS)
endif()

if(FASTSIMD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()

Expand Down
3 changes: 2 additions & 1 deletion include/FastSIMD/ToolSet/x86/128/f32x4.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ namespace FS
}
else
{
return _mm_xor_ps( ifFalse.native, _mm_and_ps( mask.native, _mm_xor_ps( ifTrue.native, ifFalse.native ) ) );
// MSVC 19.51 miscompiles the equivalent xor( ifFalse, and( mask, xor( ifTrue, ifFalse ) ) ) inside FS::ATan2
return _mm_xor_ps( ifTrue.native, _mm_andnot_ps( mask.native, _mm_xor_ps( ifTrue.native, ifFalse.native ) ) );
}
}

Expand Down
59 changes: 53 additions & 6 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,60 @@

fastsimd_create_dispatch_library(simd_test SOURCES "test.inl" FEATURE_SETS SCALAR SSE2 SSE41 AVX2 AVX512 NEON AARCH64 WASM)
fastsimd_create_dispatch_library(simd_test_relaxed RELAXED SOURCES "test.inl" FEATURE_SETS SCALAR SSE2 SSE41 AVX2 AVX512 NEON AARCH64 WASM)
set(FASTSIMD_TEST_FEATURE_SETS SCALAR SSE2 SSE41 AVX2 AVX512 NEON AARCH64 WASM)

add_executable(test "test.cpp")
target_link_libraries(test PRIVATE FastSIMD simd_test simd_test_relaxed)
# Each register size is its own pair of dispatch libraries, test.inl instantiates FASTSIMD_TEST_REGISTER_BYTES
# All sizes in one translation unit needs ~4.5GB per unit in a GCC Debug build, too much for 4 parallel jobs on a CI runner
# Keep in sync with kTestRegisterBytes in test.h
set(simd_test_libraries "")
foreach(register_bytes 16 32 64 128)
fastsimd_create_dispatch_library(simd_test_${register_bytes} SOURCES "test.inl" FEATURE_SETS ${FASTSIMD_TEST_FEATURE_SETS})
fastsimd_create_dispatch_library(simd_test_relaxed_${register_bytes} RELAXED SOURCES "test.inl" FEATURE_SETS ${FASTSIMD_TEST_FEATURE_SETS})

foreach(simd_test_library simd_test_${register_bytes} simd_test_relaxed_${register_bytes})
target_compile_definitions(${simd_test_library} PRIVATE FASTSIMD_TEST_REGISTER_BYTES=${register_bytes})

# Every test is too many sections for an unoptimised COFF object file
if(MSVC)
target_compile_options(${simd_test_library} PRIVATE /bigobj)
elseif(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# GNU as (MinGW) has the same limit, clang's integrated assembler switches to big objects itself
target_compile_options(${simd_test_library} PRIVATE -Wa,-mbig-obj)
endif()

list(APPEND simd_test_libraries ${simd_test_library})
endforeach()
endforeach()

# "test" is a reserved target name when CTest is enabled
add_executable(FastSIMD_tests "test.cpp" "test_inputs.cpp")
target_link_libraries(FastSIMD_tests PRIVATE FastSIMD ${simd_test_libraries})

# Random inputs must be the same on every platform for a seed, stop arm64 compilers fusing the range maths into FMA
if(MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(FastSIMD_tests PRIVATE /clang:-ffp-contract=off)
elseif(NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(FastSIMD_tests PRIVATE -ffp-contract=off)
endif()

# Fewer random inputs keeps ctest (and CI) quick, run FastSIMD_tests directly for a full run
set(FASTSIMD_CTEST_INPUT_COUNT 65536 CACHE STRING "FastSIMD random input values per test when run through ctest")
add_test(NAME FastSIMD_tests COMMAND FastSIMD_tests --count ${FASTSIMD_CTEST_INPUT_COUNT})

if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(CMAKE_EXECUTABLE_SUFFIX ".html")
target_link_options(test PRIVATE -sALLOW_MEMORY_GROWTH=1 -sSINGLE_FILE)
# Runs under node, which the Emscripten toolchain sets as the ctest emulator
# EXIT_RUNTIME makes main's return value the exit code
# Debug info makes the single file output over 1GB, larger than node can load, so it's left out when linking
target_link_options(FastSIMD_tests PRIVATE -sALLOW_MEMORY_GROWTH=1 -sSINGLE_FILE -sEXIT_RUNTIME=1 $<$<CONFIG:Debug>:-g0>)

# The toolchain uses whichever node is first on PATH, emsdk's own node supports the relaxed SIMD the relaxed tests use
if(DEFINED ENV{EMSDK_NODE})
set_target_properties(FastSIMD_tests PROPERTIES CROSSCOMPILING_EMULATOR "$ENV{EMSDK_NODE}")
endif()

# Single page to run the tests in a browser
add_executable(FastSIMD_tests_web "test.cpp" "test_inputs.cpp")
target_link_libraries(FastSIMD_tests_web PRIVATE FastSIMD ${simd_test_libraries})
set_target_properties(FastSIMD_tests_web PROPERTIES SUFFIX ".html")
target_link_options(FastSIMD_tests_web PRIVATE -sALLOW_MEMORY_GROWTH=1 -sSINGLE_FILE $<$<CONFIG:Debug>:-g0>)
endif()

# Enable Warnings
Expand Down
Loading
Loading