Skip to content

Commit

Permalink
Use TBB_TCM_TESTING CMake flag to hint to testing suite about TCM pre…
Browse files Browse the repository at this point in the history
…sence

Signed-off-by: Isaev, Ilya <[email protected]>
  • Loading branch information
isaevil committed Jul 19, 2024
1 parent 1f52f50 commit dcd814c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 11 deletions.
30 changes: 25 additions & 5 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ function(tbb_add_test)
$<$<CONFIG:DEBUG>:TBB_USE_DEBUG>
$<$<BOOL:${TBB_CPF}>:__TBB_CPF_BUILD=1>
$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:__TBB_DYNAMIC_LOAD_ENABLED=0>
$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:__TBB_SOURCE_DIRECTLY_INCLUDED=1>)
$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:__TBB_SOURCE_DIRECTLY_INCLUDED=1>
$<$<BOOL:${TBB_TCM_TESTING}>:__TBB_TCM_TESTING_ENABLED=1>)

target_link_libraries(${_tbb_test_TARGET_NAME} PRIVATE ${_tbb_test_DEPENDENCIES} Threads::Threads ${TBB_COMMON_LINK_LIBS})

Expand Down Expand Up @@ -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.
Expand All @@ -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)
Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions test/conformance/conformance_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/tbb/test_partitioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename Range>
void test_custom_range(int diff_mult) {
Expand Down
3 changes: 3 additions & 0 deletions test/tbb/test_task_arena.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -1977,6 +1979,7 @@ TEST_CASE("Workers oversubscription") {
);
});
}
#endif

#if TBB_USE_EXCEPTIONS
//! The test for error in scheduling empty task_handle
Expand Down
30 changes: 24 additions & 6 deletions test/tbb/test_task_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<tbb::task_group>();
a.execute([] {
RunFibonacciTests<tbb::task_group>();
});
}
}

Expand Down Expand Up @@ -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::isolated_task_group>();
tbb::task_arena a(p);
a.execute([] {
TestThreadSafety<tbb::isolated_task_group>();
});
}
}
#endif
Expand All @@ -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::isolated_task_group>();
tbb::task_arena a(p);
a.execute([] {
RunFibonacciTests<tbb::isolated_task_group>();
});
}
}

Expand All @@ -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::isolated_task_group>();
tbb::task_arena a(p);
a.execute([] {
RunCancellationAndExceptionHandlingTests<tbb::isolated_task_group>();
});
}
}

Expand All @@ -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::isolated_task_group>();
tbb::task_arena a(p);
a.execute([] {
TestConstantFunctorRequirement<tbb::isolated_task_group>();
});
}
}

Expand All @@ -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::isolated_task_group>();
tbb::task_arena a(p);
a.execute([] {
TestMoveSemantics<tbb::isolated_task_group>();
});
}
}

Expand Down

0 comments on commit dcd814c

Please sign in to comment.