Skip to content

Commit 104db7f

Browse files
authored
Add parallel phase feature test macro and simplify leave policy initialization logic (#2002)
1 parent d38d12c commit 104db7f

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

include/oneapi/tbb/detail/_config.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,14 @@
562562
#endif
563563

564564
// Feature-test macros
565+
#if __TBB_PREVIEW_FLOW_GRAPH_RESOURCE_LIMITING
566+
#define TBB_HAS_FLOW_GRAPH_RESOURCE_LIMITING 202603
567+
#endif
568+
569+
#if __TBB_PREVIEW_PARALLEL_PHASE
570+
#define TBB_HAS_PARALLEL_PHASE 202603
571+
#endif
572+
565573
#if __TBB_PREVIEW_TASK_ARENA_CORE_TYPE_SELECTOR
566574
#define TBB_HAS_TASK_ARENA_CORE_TYPE_SELECTOR 202603
567575
#endif
@@ -570,8 +578,4 @@
570578
#define TBB_HAS_TASK_GROUP_WAIT_FOR_SINGLE_TASK 202603
571579
#endif
572580

573-
#if __TBB_PREVIEW_FLOW_GRAPH_RESOURCE_LIMITING
574-
#define TBB_HAS_FLOW_GRAPH_RESOURCE_LIMITING 202603
575-
#endif
576-
577581
#endif // __TBB_detail__config_H

src/tbb/arena.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ class thread_leave_manager {
196196
std::uintptr_t policy = FAST_LEAVE;
197197
if (lp == tbb::task_arena::leave_policy::automatic) {
198198
auto glp = tbb::task_arena::leave_policy(global_control::active_value(global_control::leave_policy));
199-
if (glp == tbb::task_arena::leave_policy::automatic) {
200-
policy = governor::hybrid_cpu() ? FAST_LEAVE : DELAYED_LEAVE;
199+
if (glp == tbb::task_arena::leave_policy::automatic && !governor::hybrid_cpu()) {
200+
policy = DELAYED_LEAVE;
201201
}
202202
}
203203
my_state.store(policy, std::memory_order_relaxed);

test/tbb/test_parallel_phase.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,3 +427,8 @@ TEST_CASE("Test parallel phase with this_task_arena") {
427427
WARN_MESSAGE(median1 < median2,
428428
"Expected one-time fast leave setting to slow workers to start new work");
429429
}
430+
431+
//! \brief \ref interface
432+
TEST_CASE("Feature test macro") {
433+
CHECK_MESSAGE(TBB_HAS_PARALLEL_PHASE == 202603, "Incorrect feature test macro");
434+
}

0 commit comments

Comments
 (0)