Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix constraint arena construction #1151

Merged
Merged
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
23 changes: 18 additions & 5 deletions src/tbb/arena.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2005-2023 Intel Corporation
Copyright (c) 2005-2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -60,7 +60,6 @@ numa_binding_observer* construct_binding_observer( d1::task_arena* ta, int num_s
if ((core_type >= 0 && core_type_count() > 1) || (numa_id >= 0 && numa_node_count() > 1) || max_threads_per_core > 0) {
binding_observer = new(allocate_memory(sizeof(numa_binding_observer))) numa_binding_observer(ta, num_slots, numa_id, core_type, max_threads_per_core);
__TBB_ASSERT(binding_observer, "Failure during NUMA binding observer allocation and construction");
binding_observer->observe(true);
}
return binding_observer;
}
Expand Down Expand Up @@ -545,7 +544,7 @@ void task_arena_impl::initialize(d1::task_arena_base& ta) {
.set_max_threads_per_core(ta.max_threads_per_core())
.set_numa_id(ta.my_numa_id);
#endif /*__TBB_ARENA_BINDING*/

if (ta.my_max_concurrency < 1) {
#if __TBB_ARENA_BINDING
ta.my_max_concurrency = (int)default_concurrency(arena_constraints);
Expand All @@ -554,15 +553,29 @@ void task_arena_impl::initialize(d1::task_arena_base& ta) {
#endif /*!__TBB_ARENA_BINDING*/
}

#if __TBB_CPUBIND_PRESENT
numa_binding_observer* observer = construct_binding_observer(
static_cast<d1::task_arena*>(&ta), arena::num_arena_slots(ta.my_max_concurrency, ta.my_num_reserved_slots),
ta.my_numa_id, ta.core_type(), ta.max_threads_per_core());
if (observer) {
// TODO: Consider lazy initialization for internal arena so
// the direct calls to observer might be omitted until actual initialization.
observer->on_scheduler_entry(true);
}
#endif /*__TBB_CPUBIND_PRESENT*/

__TBB_ASSERT(ta.my_arena.load(std::memory_order_relaxed) == nullptr, "Arena already initialized");
unsigned priority_level = arena_priority_level(ta.my_priority);
threading_control* thr_control = threading_control::register_public_reference();
arena& a = arena::create(thr_control, unsigned(ta.my_max_concurrency), ta.my_num_reserved_slots, priority_level, arena_constraints);

ta.my_arena.store(&a, std::memory_order_release);
#if __TBB_CPUBIND_PRESENT
a.my_numa_binding_observer = construct_binding_observer(
static_cast<d1::task_arena*>(&ta), a.my_num_slots, ta.my_numa_id, ta.core_type(), ta.max_threads_per_core());
a.my_numa_binding_observer = observer;
if (observer) {
observer->on_scheduler_exit(true);
observer->observe(true);
}
#endif /*__TBB_CPUBIND_PRESENT*/
}

Expand Down
Loading