Skip to content
Open
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
19 changes: 4 additions & 15 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,8 @@ set(gmgpolar_test_sources

include(GoogleTest)

# Build the test suite twice: once for serial (1 thread) and once for parallel (16 threads).
# GMGPOLAR_TEST_THREADS is passed to Kokkos::InitializationSettings at startup.
foreach(label_threads "Serial;1" "Parallel;16")
list(GET label_threads 0 label)
list(GET label_threads 1 num_threads)
set(test_target gmgpolar_tests_${label})
add_executable(gmgpolar_tests ${gmgpolar_test_sources})
target_compile_features(gmgpolar_tests PRIVATE cxx_std_20)
target_link_libraries(gmgpolar_tests GMGPolarLib GMGPolarInterface GTest::gtest)

add_executable(${test_target} ${gmgpolar_test_sources})
target_compile_features(${test_target} PRIVATE cxx_std_20)
target_compile_definitions(${test_target} PRIVATE GMGPOLAR_TEST_THREADS=${num_threads})
target_link_libraries(${test_target} GMGPolarLib GMGPolarInterface GTest::gtest)

gtest_discover_tests(${test_target}
TEST_PREFIX ${label}
DISCOVERY_MODE PRE_TEST)
endforeach()
gtest_discover_tests(gmgpolar_tests DISCOVERY_MODE PRE_TEST)
5 changes: 1 addition & 4 deletions tests/gmgpolar_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
// Define the main function only once
int main(int argc, char* argv[])
{
Kokkos::InitializationSettings settings;
// 8 (CPU) threads
settings.set_num_threads(GMGPOLAR_TEST_THREADS);
Kokkos::ScopeGuard kokkos_scope(settings);
Kokkos::ScopeGuard kokkos_scope(argc, argv);
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Loading