From dcd814c4aae97d006b46bf530d166a292853295e Mon Sep 17 00:00:00 2001 From: "Isaev, Ilya" Date: Thu, 11 Jul 2024 07:35:23 -0500 Subject: [PATCH] Use TBB_TCM_TESTING CMake flag to hint to testing suite about TCM presence Signed-off-by: Isaev, Ilya --- test/CMakeLists.txt | 30 +++++++++++++++++++++----- test/conformance/conformance_graph.cpp | 3 +++ test/tbb/test_partitioner.cpp | 3 +++ test/tbb/test_task_arena.cpp | 3 +++ test/tbb/test_task_group.cpp | 30 ++++++++++++++++++++------ 5 files changed, 58 insertions(+), 11 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index cfde681bd6..fb4a78bdbb 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -79,7 +79,8 @@ function(tbb_add_test) $<$:TBB_USE_DEBUG> $<$:__TBB_CPF_BUILD=1> $<$>:__TBB_DYNAMIC_LOAD_ENABLED=0> - $<$>:__TBB_SOURCE_DIRECTLY_INCLUDED=1>) + $<$>:__TBB_SOURCE_DIRECTLY_INCLUDED=1> + $<$:__TBB_TCM_TESTING_ENABLED=1>) target_link_libraries(${_tbb_test_TARGET_NAME} PRIVATE ${_tbb_test_DEPENDENCIES} Threads::Threads ${TBB_COMMON_LINK_LIBS}) @@ -380,7 +381,9 @@ if (TARGET TBB::tbb) # Define the tests tbb_add_test(SUBDIR tbb NAME test_tick_count DEPENDENCIES TBB::tbb) tbb_add_test(SUBDIR tbb NAME test_allocators DEPENDENCIES TBB::tbb) - tbb_add_test(SUBDIR tbb NAME test_arena_priorities DEPENDENCIES TBB::tbb) + if (NOT TBB_TCM_TESTING) + tbb_add_test(SUBDIR tbb NAME test_arena_priorities DEPENDENCIES TBB::tbb) + endif() tbb_add_test(SUBDIR tbb NAME test_dynamic_link DEPENDENCIES TBB::tbb) if (LINKER_HAS_NO_AS_NEEDED) # The linker may not detect a dependency on pthread in static variable constructors. @@ -389,7 +392,7 @@ if (TARGET TBB::tbb) if (APPLE OR ANDROID_PLATFORM) target_link_libraries(test_dynamic_link PRIVATE -rdynamic) endif() - if (WIN32) + if (WIN32 AND NOT TBB_TCM_TESTING) tbb_add_test(SUBDIR tbb NAME test_numa_dist DEPENDENCIES TBB::tbb) endif() tbb_add_test(SUBDIR tbb NAME test_collaborative_call_once DEPENDENCIES TBB::tbb) @@ -451,8 +454,23 @@ if (TARGET TBB::tbb) tbb_add_test(SUBDIR tbb NAME test_environment_whitebox DEPENDENCIES TBB::tbb) tbb_add_test(SUBDIR tbb NAME test_hw_concurrency DEPENDENCIES TBB::tbb) tbb_add_test(SUBDIR tbb NAME test_eh_thread DEPENDENCIES TBB::tbb) - tbb_add_test(SUBDIR tbb NAME test_global_control DEPENDENCIES TBB::tbb) + if (NOT TBB_TCM_TESTING) + tbb_add_test(SUBDIR tbb NAME test_global_control DEPENDENCIES TBB::tbb) + endif() tbb_add_test(SUBDIR tbb NAME test_task DEPENDENCIES TBB::tbb) + if (TBB_TCM_TESTING AND NOT WINDOWS_STORE AND NOT TBB_WINDOWS_DRIVER) + add_test(NAME test_tcm_enabled COMMAND test_task --force-colors=1 WORKING_DIRECTORY ${TBB_TEST_WORKING_DIRECTORY}) + set_tests_properties(test_tcm_enabled PROPERTIES + ENVIRONMENT "TBB_VERSION=1;TCM_ENABLE=1" + PASS_REGULAR_EXPRESSION "TCM: VERSION.*" + FAIL_REGULAR_EXPRESSION "TCM: TCM *disabled" + ) + add_test(NAME test_tcm_disabled COMMAND test_task --force-colors=1 WORKING_DIRECTORY ${TBB_TEST_WORKING_DIRECTORY}) + set_tests_properties(test_tcm_disabled PROPERTIES + ENVIRONMENT "TBB_VERSION=1;TCM_ENABLE=0" + PASS_REGULAR_EXPRESSION "TCM: TCM *disabled" + ) + endif() if (TBB_FUZZ_TESTING AND NOT WIN32) if (NOT ((CMAKE_CXX_COMPILER_ID STREQUAL Clang) OR (CMAKE_CXX_COMPILER_ID STREQUAL IntelLLVM))) @@ -521,7 +539,9 @@ if (TARGET TBB::tbb) tbb_add_test(SUBDIR conformance NAME conformance_blocked_range3d DEPENDENCIES TBB::tbb) tbb_add_test(SUBDIR conformance NAME conformance_blocked_rangeNd DEPENDENCIES TBB::tbb) tbb_add_test(SUBDIR conformance NAME conformance_concurrent_vector DEPENDENCIES TBB::tbb) - tbb_add_test(SUBDIR conformance NAME conformance_global_control DEPENDENCIES TBB::tbb) + if (NOT TBB_TCM_TESTING) + tbb_add_test(SUBDIR conformance NAME conformance_global_control DEPENDENCIES TBB::tbb) + endif() tbb_add_test(SUBDIR conformance NAME conformance_concurrent_hash_map DEPENDENCIES TBB::tbb) tbb_add_test(SUBDIR conformance NAME conformance_enumerable_thread_specific DEPENDENCIES TBB::tbb) tbb_add_test(SUBDIR conformance NAME conformance_combinable DEPENDENCIES TBB::tbb) diff --git a/test/conformance/conformance_graph.cpp b/test/conformance/conformance_graph.cpp index 3492660783..ab9fad6f7e 100644 --- a/test/conformance/conformance_graph.cpp +++ b/test/conformance/conformance_graph.cpp @@ -158,6 +158,8 @@ void test_join_node_rf_reset_protocol(){ CHECK_MESSAGE((!testing_node.try_get(tmp)), "All buffers must be emptied"); } +// global_control::max_alowed_parallelism functionality is not covered by TCM +#if !__TBB_TCM_TESTING_ENABLED //! Graph reset //! \brief \ref requirement TEST_CASE("graph reset with rf_reset_protocol") { @@ -179,6 +181,7 @@ TEST_CASE("graph reset with rf_reset_protocol") { test_limiter_node_rf_reset_protocol(); test_join_node_rf_reset_protocol(); } +#endif //! Graph reset rf_clear_edges //! \brief \ref requirement diff --git a/test/tbb/test_partitioner.cpp b/test/tbb/test_partitioner.cpp index 2aca706f44..8c7403a1f6 100644 --- a/test/tbb/test_partitioner.cpp +++ b/test/tbb/test_partitioner.cpp @@ -168,12 +168,15 @@ void strict_test() { } // namespace task_affinity_retention +// global_control::max_alowed_parallelism functionality is not covered by TCM +#if !__TBB_TCM_TESTING_ENABLED //! Testing affinitized tasks are not stolen //! \brief \ref error_guessing TEST_CASE("Threads respect task affinity") { task_affinity_retention::relaxed_test(); task_affinity_retention::strict_test(); } +#endif template void test_custom_range(int diff_mult) { diff --git a/test/tbb/test_task_arena.cpp b/test/tbb/test_task_arena.cpp index fd930f1995..5f86cc0381 100644 --- a/test/tbb/test_task_arena.cpp +++ b/test/tbb/test_task_arena.cpp @@ -1941,6 +1941,8 @@ TEST_CASE("Stress test with mixing functionality") { StressTestMixFunctionality(); } +// global_control::max_alowed_parallelism functionality is not covered by TCM +#if !__TBB_TCM_TESTING_ENABLED //! \brief \ref stress TEST_CASE("Workers oversubscription") { std::size_t num_threads = utils::get_platform_max_threads(); @@ -1977,6 +1979,7 @@ TEST_CASE("Workers oversubscription") { ); }); } +#endif #if TBB_USE_EXCEPTIONS //! The test for error in scheduling empty task_handle diff --git a/test/tbb/test_task_group.cpp b/test/tbb/test_task_group.cpp index d39b4fc703..f14653ae07 100644 --- a/test/tbb/test_task_group.cpp +++ b/test/tbb/test_task_group.cpp @@ -780,8 +780,11 @@ TEST_CASE("Thread safety test for the task group") { TEST_CASE("Fibonacci test for the task group") { for (unsigned p=MinThread; p <= MaxThread; ++p) { tbb::global_control limit(tbb::global_control::max_allowed_parallelism, p); + tbb::task_arena a(p); g_MaxConcurrency = p; - RunFibonacciTests(); + a.execute([] { + RunFibonacciTests(); + }); } } @@ -838,7 +841,10 @@ TEST_CASE("Thread safety test for the isolated task group") { } tbb::global_control limit(tbb::global_control::max_allowed_parallelism, p); g_MaxConcurrency = p; - TestThreadSafety(); + tbb::task_arena a(p); + a.execute([] { + TestThreadSafety(); + }); } } #endif @@ -849,7 +855,10 @@ TEST_CASE("Fibonacci test for the isolated task group") { for (unsigned p=MinThread; p <= MaxThread; ++p) { tbb::global_control limit(tbb::global_control::max_allowed_parallelism, p); g_MaxConcurrency = p; - RunFibonacciTests(); + tbb::task_arena a(p); + a.execute([] { + RunFibonacciTests(); + }); } } @@ -859,7 +868,10 @@ TEST_CASE("Cancellation and exception test for the isolated task group") { for (unsigned p=MinThread; p <= MaxThread; ++p) { tbb::global_control limit(tbb::global_control::max_allowed_parallelism, p); g_MaxConcurrency = p; - RunCancellationAndExceptionHandlingTests(); + tbb::task_arena a(p); + a.execute([] { + RunCancellationAndExceptionHandlingTests(); + }); } } @@ -869,7 +881,10 @@ TEST_CASE("Constant functor test for the isolated task group") { for (unsigned p=MinThread; p <= MaxThread; ++p) { tbb::global_control limit(tbb::global_control::max_allowed_parallelism, p); g_MaxConcurrency = p; - TestConstantFunctorRequirement(); + tbb::task_arena a(p); + a.execute([] { + TestConstantFunctorRequirement(); + }); } } @@ -879,7 +894,10 @@ TEST_CASE("Move semantics test for the isolated task group") { for (unsigned p=MinThread; p <= MaxThread; ++p) { tbb::global_control limit(tbb::global_control::max_allowed_parallelism, p); g_MaxConcurrency = p; - TestMoveSemantics(); + tbb::task_arena a(p); + a.execute([] { + TestMoveSemantics(); + }); } }