From d666d342a6fbfe981becc02d87ca131924ec99f0 Mon Sep 17 00:00:00 2001 From: Konstantin Boyarinov Date: Wed, 28 Aug 2024 17:41:38 +0300 Subject: [PATCH] [try_put_and_wait] Remove unnecessary functions (#1497) --- include/oneapi/tbb/detail/_flow_graph_impl.h | 8 ----- .../tbb/detail/_flow_graph_item_buffer_impl.h | 22 ++++-------- .../oneapi/tbb/detail/_flow_graph_join_impl.h | 35 +++++++------------ .../detail/_flow_graph_tagged_buffer_impl.h | 10 ------ include/oneapi/tbb/flow_graph.h | 14 ++++---- 5 files changed, 26 insertions(+), 63 deletions(-) diff --git a/include/oneapi/tbb/detail/_flow_graph_impl.h b/include/oneapi/tbb/detail/_flow_graph_impl.h index 7b37b05196..19e00a8ef1 100644 --- a/include/oneapi/tbb/detail/_flow_graph_impl.h +++ b/include/oneapi/tbb/detail/_flow_graph_impl.h @@ -180,14 +180,6 @@ class trackable_messages_graph_task : public graph_task { { } - trackable_messages_graph_task(graph& g, d1::small_object_allocator& allocator, - const std::forward_list& msg_waiters) - : trackable_messages_graph_task(g, allocator, no_priority, msg_waiters) {} - - trackable_messages_graph_task(graph& g, d1::small_object_allocator& allocator, - std::forward_list&& msg_waiters) - : trackable_messages_graph_task(g, allocator, no_priority, std::move(msg_waiters)) {} - const std::forward_list get_msg_wait_context_vertices() const { return my_msg_wait_context_vertices; } 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 616738672f..cf7c54b852 100644 --- a/include/oneapi/tbb/detail/_flow_graph_item_buffer_impl.h +++ b/include/oneapi/tbb/detail/_flow_graph_item_buffer_impl.h @@ -151,21 +151,21 @@ class item_buffer { } // put an item in an empty slot. Return true if successful, else false - bool place_item(size_t here, const item_type &me) { +#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 - set_my_item(here, me); + set_my_item(here, me, std::forward(metainfo)); return true; } - -#if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT - template - bool place_item(size_t here, const item_type &me, Metainfo&& metainfo) { +#else + bool place_item(size_t here, const item_type &me) { #if !TBB_DEPRECATED_SEQUENCER_DUPLICATES if(my_item_valid(here)) return false; #endif - set_my_item(here, me, std::forward(metainfo)); + set_my_item(here, me); return true; } #endif @@ -327,14 +327,6 @@ class item_buffer { } #if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT - void set_my_item(size_t i, const item_type&o) { - set_my_item(i, o, message_metainfo{}); - } - - bool push_back(item_type& v) { - return push_back(v, message_metainfo{}); - } - bool pop_back(item_type& v) { message_metainfo metainfo; return pop_back(v, metainfo); diff --git a/include/oneapi/tbb/detail/_flow_graph_join_impl.h b/include/oneapi/tbb/detail/_flow_graph_join_impl.h index 4d347895f9..bb06a0d927 100644 --- a/include/oneapi/tbb/detail/_flow_graph_join_impl.h +++ b/include/oneapi/tbb/detail/_flow_graph_join_impl.h @@ -519,13 +519,11 @@ graph_task* rtask = nullptr; was_empty = this->buffer_empty(); #if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT - if (current->metainfo) { - this->push_back(current->my_val, *(current->metainfo)); - } else + __TBB_ASSERT(current->metainfo, nullptr); + this->push_back(current->my_val, *(current->metainfo)); +#else + this->push_back(current->my_val); #endif - { - this->push_back(current->my_val); - } if (was_empty) rtask = my_join->decrement_port_count(false); else rtask = SUCCESSFULLY_ENQUEUED; @@ -725,15 +723,12 @@ op_list = op_list->next; switch(current->type) { case try__put: { - bool was_inserted = false; #if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT - if (current->metainfo) { - was_inserted = this->insert_with_key(current->my_val, *(current->metainfo)); - } else + __TBB_ASSERT(current->metainfo, nullptr); + bool was_inserted = this->insert_with_key(current->my_val, *(current->metainfo)); +#else + bool was_inserted = this->insert_with_key(current->my_val); #endif - { - was_inserted = this->insert_with_key(current->my_val); - } // return failure if a duplicate insertion occurs current->status.store( was_inserted ? SUCCEEDED : FAILED, std::memory_order_release); } @@ -741,17 +736,13 @@ case get__item: { // use current_key from FE for item __TBB_ASSERT(current->my_arg, nullptr); - bool find_result = false; #if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT - if (current->metainfo) { - find_result = this->find_with_key(my_join->current_key, *(current->my_arg), - *(current->metainfo)); - - } else + __TBB_ASSERT(current->metainfo, nullptr); + bool find_result = this->find_with_key(my_join->current_key, *(current->my_arg), + *(current->metainfo)); +#else + bool find_result = this->find_with_key(my_join->current_key, *(current->my_arg)); #endif - { - find_result = this->find_with_key(my_join->current_key, *(current->my_arg)); - } #if TBB_USE_DEBUG if (!find_result) { __TBB_ASSERT(false, "Failed to find item corresponding to current_key."); diff --git a/include/oneapi/tbb/detail/_flow_graph_tagged_buffer_impl.h b/include/oneapi/tbb/detail/_flow_graph_tagged_buffer_impl.h index 9c169066f4..0f7c0d174f 100644 --- a/include/oneapi/tbb/detail/_flow_graph_tagged_buffer_impl.h +++ b/include/oneapi/tbb/detail/_flow_graph_tagged_buffer_impl.h @@ -66,10 +66,6 @@ struct metainfo_hash_buffer_element : public aligned_triplesecond = reinterpret_cast(new_next); } message_metainfo& get_metainfo() { return this->third; } - void create_element(const value_type& v) { - ::new(this->first) value_type(v); - } - void create_element(const value_type& v, const message_metainfo& metainfo) { __TBB_ASSERT(this->third.empty(), nullptr); ::new(this->first) value_type(v); @@ -368,12 +364,6 @@ struct metainfo_hash_buffer : public hash_buffer_impl, ValueToKey, HashCompare, Allocator>; public: - bool find_with_key(const typename base_type::Knoref& k, - typename base_type::value_type& v) - { - return base_type::find_with_key(k, v); - } - bool find_with_key(const typename base_type::Knoref& k, typename base_type::value_type& v, message_metainfo& metainfo) { diff --git a/include/oneapi/tbb/flow_graph.h b/include/oneapi/tbb/flow_graph.h index 0b2b0a2d47..49eae5eda0 100644 --- a/include/oneapi/tbb/flow_graph.h +++ b/include/oneapi/tbb/flow_graph.h @@ -1478,13 +1478,11 @@ class buffer_node virtual bool internal_push(buffer_operation *op) { __TBB_ASSERT(op->elem, nullptr); #if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT - if (op->metainfo) { - this->push_back(*(op->elem), (*op->metainfo)); - } else + __TBB_ASSERT(op->metainfo, nullptr); + this->push_back(*(op->elem), (*op->metainfo)); +#else + this->push_back(*(op->elem)); #endif - { - this->push_back(*(op->elem)); - } op->status.store(SUCCEEDED, std::memory_order_release); return true; } @@ -1864,8 +1862,8 @@ class sequencer_node : public queue_node { this->my_tail = new_tail; #if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT - bool place_item_result = op->metainfo ? this->place_item(tag, *(op->elem), *(op->metainfo)) - : this->place_item(tag, *(op->elem)); + __TBB_ASSERT(op->metainfo, nullptr); + bool place_item_result = this->place_item(tag, *(op->elem), *(op->metainfo)); const op_stat res = place_item_result ? SUCCEEDED : FAILED; #else const op_stat res = this->place_item(tag, *(op->elem)) ? SUCCEEDED : FAILED;