Skip to content

tests: enable multi-threading - #694

Open
WojciechMula wants to merge 1 commit into
simdutf:masterfrom
WojciechMula:parallel-tests
Open

tests: enable multi-threading#694
WojciechMula wants to merge 1 commit into
simdutf:masterfrom
WojciechMula:parallel-tests

Conversation

@WojciechMula

@WojciechMula WojciechMula commented Feb 28, 2025

Copy link
Copy Markdown
Collaborator

single test program may run multiple tests. This change modifies test programs to handle GTests command line options required by CMake/CTest to discover tests[1]. Thanks to that we may use CTest facilites, especially parallel running.

[1] https://cmake.org/cmake/help/git-master/module/GoogleTest.html#command:gtest_discover_tests.

On my machine ctest -j on master takes 31 second, while on this branch only 22 seconds.

@lemire

lemire commented Mar 1, 2025

Copy link
Copy Markdown
Member

If threading is added, I think we need something like this in CMake:

option(SIMDUTF_ENABLE_THREADS "thread support" ON)
if(SIMDUTF_ENABLE_THREADS)
  find_package(Threads REQUIRED)
  target_add_library(something_that_requires_threads PRIVATE Threads::Threads)
  target_compile_definitions(something_that_requires_threads PRIVATE SIMDUTF_THREADS_ENABLED=1)
endif()

Right?

If we now require multithreading support for building simdutf, this requires changes to...

https://github.com/simdutf/simdutf/blob/master/cmake/simdutf-config.cmake.in

E.g., we should add...

include(CMakeFindDependencyMacro)
if("@ SIMDUTF_ENABLE_THREADS@")
  find_dependency(Threads)
endif()

Otherwise, this will break some builds.

@lemire

lemire commented Mar 1, 2025

Copy link
Copy Markdown
Member

I guess it's quite promising, especially for our CI, which runs multitude of tests on so many platforms and compilers.

We can parallelize the builds with an additional flag... cmake --build build ▶️ cmake --build build -j (we could do even more so by configuring with Ninja).

@WojciechMula

Copy link
Copy Markdown
Collaborator Author

Alternatively, we may think about running single test from executable, similarly to https://cmake.org/cmake/help/git-master/module/GoogleTest.html#command:gtest_discover_tests.

I tested this approach. We provide the same set of command line arguments as GTest and can use gtest_discover_tests. I think it's way better solution, as we can freely use all ctest facilities and do not clutter our code with threads and related stuff.

A single test program may run multiple tests. This change
modifies test programs to handle GTests command line options
required by CMake/CTest to discover tests[1]. Thanks to
that we may use CTest facilites, especially parallel running.

[1] https://cmake.org/cmake/help/git-master/module/GoogleTest.html#command:gtest_discover_tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants