Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
kboyarinov committed Jul 17, 2024
1 parent 703104a commit 5d66123
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 35 deletions.
6 changes: 1 addition & 5 deletions include/oneapi/tbb/detail/_flow_graph_cache_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,7 @@ class round_robin_cache : public successor_cache<T, M> {

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
Expand Down
8 changes: 2 additions & 6 deletions include/oneapi/tbb/detail/_flow_graph_item_buffer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -162,7 +159,6 @@ class item_buffer {
#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
Expand Down
11 changes: 3 additions & 8 deletions include/oneapi/tbb/detail/_flow_graph_node_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,11 @@ class function_input_base : public receiver<Input>, 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;
}
Expand Down
24 changes: 8 additions & 16 deletions include/oneapi/tbb/flow_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<T*>(&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
Expand All @@ -1277,11 +1274,7 @@ class buffer_node
, metainfo(const_cast<message_metainfo*>(&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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -1877,12 +1872,11 @@ class priority_queue_node : public buffer_node<T> {
#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;
}
Expand Down Expand Up @@ -2028,10 +2022,8 @@ class priority_queue_node : public buffer_node<T> {
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))
Expand Down

0 comments on commit 5d66123

Please sign in to comment.