Skip to content

Commit

Permalink
[try_put_and_wait] Remove unnecessary functions (#1497)
Browse files Browse the repository at this point in the history
  • Loading branch information
kboyarinov authored Aug 28, 2024
1 parent 7dd2b9c commit d666d34
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 63 deletions.
8 changes: 0 additions & 8 deletions include/oneapi/tbb/detail/_flow_graph_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<d1::wait_context_vertex*>& 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<d1::wait_context_vertex*>&& msg_waiters)
: trackable_messages_graph_task(g, allocator, no_priority, std::move(msg_waiters)) {}

const std::forward_list<d1::wait_context_vertex*> get_msg_wait_context_vertices() const {
return my_msg_wait_context_vertices;
}
Expand Down
22 changes: 7 additions & 15 deletions include/oneapi/tbb/detail/_flow_graph_item_buffer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename Metainfo>
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>(metainfo));
return true;
}

#if __TBB_PREVIEW_FLOW_GRAPH_TRY_PUT_AND_WAIT
template <typename Metainfo>
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>(metainfo));
set_my_item(here, me);
return true;
}
#endif
Expand Down Expand Up @@ -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);
Expand Down
35 changes: 13 additions & 22 deletions include/oneapi/tbb/detail/_flow_graph_join_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -725,33 +723,26 @@
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);
}
break;
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.");
Expand Down
10 changes: 0 additions & 10 deletions include/oneapi/tbb/detail/_flow_graph_tagged_buffer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ struct metainfo_hash_buffer_element : public aligned_triple<ValueType, void*, me
void set_next(metainfo_hash_buffer_element* new_next) { this->second = reinterpret_cast<void*>(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);
Expand Down Expand Up @@ -368,12 +364,6 @@ struct metainfo_hash_buffer : public hash_buffer_impl<metainfo_hash_buffer_eleme
using base_type = hash_buffer_impl<metainfo_hash_buffer_element<Key, ValueType>,
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)
{
Expand Down
14 changes: 6 additions & 8 deletions include/oneapi/tbb/flow_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -1864,8 +1862,8 @@ class sequencer_node : public queue_node<T> {
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;
Expand Down

0 comments on commit d666d34

Please sign in to comment.