From 5d66123efde08bcdcfab6dd065b9fb56fa7dc68a Mon Sep 17 00:00:00 2001 From: Konstantin Boyarinov Date: Wed, 17 Jul 2024 05:40:23 -0700 Subject: [PATCH] Simplify code --- .../tbb/detail/_flow_graph_cache_impl.h | 6 +---- .../tbb/detail/_flow_graph_item_buffer_impl.h | 8 ++----- .../oneapi/tbb/detail/_flow_graph_node_impl.h | 11 +++------ include/oneapi/tbb/flow_graph.h | 24 +++++++------------ 4 files changed, 14 insertions(+), 35 deletions(-) diff --git a/include/oneapi/tbb/detail/_flow_graph_cache_impl.h b/include/oneapi/tbb/detail/_flow_graph_cache_impl.h index a806b5c39a..a807f694d4 100644 --- a/include/oneapi/tbb/detail/_flow_graph_cache_impl.h +++ b/include/oneapi/tbb/detail/_flow_graph_cache_impl.h @@ -472,11 +472,7 @@ class round_robin_cache : public successor_cache { public: graph_task* try_put_task(const T& t) override { -#if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT - return try_put_task_impl(t, message_metainfo{}); -#else - return try_put_task_impl(t); -#endif + return try_put_task_impl(t __TBB_FLOW_GRAPH_METAINFO_ARG(message_metainfo{})); } #if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT diff --git a/include/oneapi/tbb/detail/_flow_graph_item_buffer_impl.h b/include/oneapi/tbb/detail/_flow_graph_item_buffer_impl.h index 7f2d32457f..6fb9947941 100644 --- a/include/oneapi/tbb/detail/_flow_graph_item_buffer_impl.h +++ b/include/oneapi/tbb/detail/_flow_graph_item_buffer_impl.h @@ -142,11 +142,8 @@ class item_buffer { void move_item(size_t to, size_t from) { __TBB_ASSERT(!my_item_valid(to), "Trying to move to a non-empty slot"); __TBB_ASSERT(my_item_valid(from), "Trying to move from an empty slot"); -#if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT - set_my_item(to, get_my_item(from), get_my_metainfo(from)); -#else - set_my_item(to, get_my_item(from)); // could have std::move semantics -#endif + // could have std::move semantics + set_my_item(to, get_my_item(from) __TBB_FLOW_GRAPH_METAINFO_ARG(get_my_metainfo(from))); destroy_item(from); } @@ -162,7 +159,6 @@ class item_buffer { #if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT template bool place_item(size_t here, const item_type &me, Metainfo&& metainfo) { - #if !TBB_DEPRECATED_SEQUENCER_DUPLICATES if(my_item_valid(here)) return false; #endif diff --git a/include/oneapi/tbb/detail/_flow_graph_node_impl.h b/include/oneapi/tbb/detail/_flow_graph_node_impl.h index 3018c04a48..83160f7e9e 100644 --- a/include/oneapi/tbb/detail/_flow_graph_node_impl.h +++ b/include/oneapi/tbb/detail/_flow_graph_node_impl.h @@ -215,16 +215,11 @@ class function_input_base : public receiver, no_assign { input_type i; #if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT message_metainfo metainfo; - if(my_predecessors.get_item(i, metainfo)) { - ++my_concurrency; - new_task = create_body_task(i, std::move(metainfo)); - } -#else - if (my_predecessors.get_item(i)) { +#endif + if(my_predecessors.get_item(i __TBB_FLOW_GRAPH_METAINFO_ARG(metainfo))) { ++my_concurrency; - new_task = create_body_task(i __TBB_FLOW_GRAPH_METAINFO_ARG(message_metainfo{})); + new_task = create_body_task(i __TBB_FLOW_GRAPH_METAINFO_ARG(std::move(metainfo))); } -#endif } return new_task; } diff --git a/include/oneapi/tbb/flow_graph.h b/include/oneapi/tbb/flow_graph.h index 8792c4df71..b61e97e025 100644 --- a/include/oneapi/tbb/flow_graph.h +++ b/include/oneapi/tbb/flow_graph.h @@ -1260,15 +1260,12 @@ class buffer_node graph_task* ltask; successor_type *r; #if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT - message_metainfo* metainfo; + message_metainfo* metainfo = nullptr; #endif buffer_operation(const T& e, op_type t) : type(char(t)) , elem(const_cast(&e)) , ltask(nullptr) , r(nullptr) -#if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT - , metainfo(nullptr) -#endif {} #if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT @@ -1277,11 +1274,7 @@ class buffer_node , metainfo(const_cast(&info)) {} #endif - buffer_operation(op_type t) : type(char(t)), elem(nullptr), ltask(nullptr), r(nullptr) -#if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT - , metainfo(nullptr) -#endif - {} + buffer_operation(op_type t) : type(char(t)), elem(nullptr), ltask(nullptr), r(nullptr) {} #if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT buffer_operation(op_type t, message_metainfo& info) @@ -1440,7 +1433,9 @@ class buffer_node this->push_back(*(op->elem), (*op->metainfo)); } else #endif + { this->push_back(*(op->elem)); + } op->status.store(SUCCEEDED, std::memory_order_release); return true; } @@ -1877,12 +1872,11 @@ class priority_queue_node : public buffer_node { #if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT if (op->metainfo) { prio_push(*(op->elem), *(op->metainfo)); - } else { + } else +#endif + { prio_push(*(op->elem)); } -#else - prio_push(*(op->elem)); -#endif op->status.store(SUCCEEDED, std::memory_order_release); return true; } @@ -2028,10 +2022,8 @@ class priority_queue_node : public buffer_node { input_type to_place; #if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT message_metainfo metainfo; - this->fetch_item(mark, to_place, metainfo); -#else - this->fetch_item(mark, to_place); #endif + this->fetch_item(mark, to_place __TBB_FLOW_GRAPH_METAINFO_ARG(metainfo)); do { // push to_place up the heap size_type parent = (cur_pos-1)>>1; if (!compare(this->get_my_item(parent), to_place))