Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
  • Loading branch information
isaevil and aleksei-fedotov authored Dec 17, 2024
1 parent 4b74db4 commit 742361b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/tbb/arena.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ arena::arena(threading_control* control, unsigned num_slots, unsigned num_reserv
arena& arena::allocate_arena(threading_control* control, unsigned num_slots, unsigned num_reserved_slots,
unsigned priority_level
#if __TBB_PREVIEW_PARALLEL_PHASE
, tbb::task_arena::leave_policy wl
, tbb::task_arena::leave_policy lp
#endif
)
{
Expand Down Expand Up @@ -359,7 +359,7 @@ bool arena::has_enqueued_tasks() {

void arena::request_workers(int mandatory_delta, int workers_delta, bool wakeup_threads) {
#if __TBB_PREVIEW_PARALLEL_PHASE
my_thread_leave.restore_state_if_needed();
my_thread_leave.restore_default_policy_if_needed();
#endif
my_threading_control->adjust_demand(my_tc_client, mandatory_delta, workers_delta);

Expand Down
2 changes: 1 addition & 1 deletion src/tbb/arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class thread_leave_manager {
do {
if (prev & PARALLEL_PHASE_MASK) {
// The parallel phase is already started, thus simply add a reference to it
desired = PARALLEL_PHASE + prev;
desired = prev + PARALLEL_PHASE;
} else if (prev == ONE_TIME_FAST_LEAVE) {
// State was previously transitioned to "One-time Fast leave", thus
// with the start of new parallel phase, it should be then transitioned to "Delayed leave"
Expand Down
2 changes: 1 addition & 1 deletion src/tbb/waiters.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class outermost_worker_waiter : public waiter_base {
using base_type = waiter_base;

bool is_delayed_leave_enabled() {
#if __TBB_PREVIEW_PARALLEL_PHASE
#if __TBB_PREVIEW_PARALLEL_PHASE
return my_arena.my_thread_leave.is_retention_allowed();
#else
return !governor::hybrid_cpu();
Expand Down
5 changes: 3 additions & 2 deletions test/tbb/test_task_arena.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2095,7 +2095,8 @@ std::size_t measure_median_start_time(tbb::task_arena* ta, const F1& start = F1{
auto get_longest_start = [&] (std::chrono::steady_clock::time_point start_time) {
std::size_t longest_time = 0;
for (auto& time : start_times) {
longest_time = std::max(longest_time, (std::size_t)std::chrono::duration_cast<std::chrono::microseconds>(time - start_time).count());
auto diff = std::chrono::duration_cast<std::chrono::microseconds>(time - start_time);
longest_time = std::max(longest_time, std::size_t(diff.count()));
}
return longest_time;
};
Expand Down Expand Up @@ -2162,7 +2163,7 @@ class start_time_collection_phase_wrapped
std::size_t measure_impl() {
arena->start_parallel_phase();
auto median_start_time = measure_median_start_time(arena);
arena->end_parallel_phase(true);
arena->end_parallel_phase(/*with_fast_leave*/true);
return median_start_time;
};
};
Expand Down

0 comments on commit 742361b

Please sign in to comment.