Skip to content

Commit 6f84587

Browse files
committed
Add a CORRADE_BUILD_TESTS_FORCE_CPU_POINTER_DISPATCH option.
The tests will be implicitly configured to use function pointers for CPU dispatch, but since it adds significant overhead on Emscripten, there also needs to be a way to disable this.
1 parent ab543ab commit 6f84587

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ cmake_dependent_option(CORRADE_CPU_USE_IFUNC "Allow using GNU IFUNC for runtime
256256
# negative perf consequences, enable it by default only on platforms that have
257257
# IFUNC, and thus can avoid the function pointer indirection.
258258
option(CORRADE_BUILD_CPU_RUNTIME_DISPATCH "Build with runtime dispatch for CPU-dependent functionality" ${_CORRADE_CPU_CAN_USE_IFUNC})
259+
# Enabled by default and independent of CORRADE_BUILD_CPU_RUNTIME_DISPATCH as
260+
# correctness is important. It can however negatively affect performance
261+
# compared to IFUNC or compile-time dispatch, so make it possible to disable
262+
# this for benchmarks.
263+
cmake_dependent_option(CORRADE_BUILD_TESTS_FORCE_CPU_POINTER_DISPATCH "Force pointer-based dispatch for unit tests to verify all variants of CPU-dependent functionality" ON "CORRADE_BUILD_TESTS" OFF)
259264

260265
# Backwards compatibility for unprefixed CMake options. If the user isn't
261266
# explicitly using prefixed options in the first run already, accept the

doc/building-corrade.dox

+15-5
Original file line numberDiff line numberDiff line change
@@ -641,11 +641,21 @@ compatibility if `CORRADE_BUILD_DEPRECATED` isn't disabled.
641641

642642
@subsection building-corrade-tests Building and running tests
643643

644-
If you want to build also the tests (which are not built by default), enable
645-
`CORRADE_BUILD_TESTS` in CMake. The tests use Corrade's own
646-
@ref Corrade::TestSuite "TestSuite" framework and can be run either manually
647-
(the binaries are located in `Test/` subdirectories in the build directory) or
648-
using
644+
Building of tests is controlled by the following options:
645+
646+
- `CORRADE_BUILD_TESTS` --- Builds unit tests. Disabled by default.
647+
- `CORRADE_BUILD_TESTS_FORCE_CPU_POINTER_DISPATCH` --- Force unit tests to be
648+
built with function-pointer-based dispatch for CPU-dependent functionality,
649+
independently of the `CORRADE_BUILD_CPU_RUNTIME_DISPATCH` and
650+
`CORRADE_CPU_USE_IFUNC` options. This makes it possible for the tests to
651+
verify all variants instead of just one, and is enabled by default. The
652+
overhead from function pointers may however be significant on certain
653+
platforms, skewing benchmark results. Disable it to make the tests use the
654+
same dispatch method as the rest of the library.
655+
656+
The tests use Corrade's own @relativeref{Corrade,TestSuite} framework and can
657+
be run either manually (the binaries are located in `Test/` subdirectories in
658+
the build directory) or using
649659

650660
@code{.sh}
651661
ctest --output-on-failure

0 commit comments

Comments
 (0)