Skip to content

Commit eca91f1

Browse files
committed
Committing TBB 2020 Update 3 source code
1 parent 60b7d0a commit eca91f1

35 files changed

+499
-132
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ Thumbs.db
7777
################################
7878
CMakeCache.txt
7979
CMakeFiles/
80+
cmake/TBBConfig.cmake
81+
cmake/TBBConfigVersion.cmake
8082

8183
# Other #
8284
#########

CHANGES

+25
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22
The list of most significant changes made over time in
33
Intel(R) Threading Building Blocks (Intel(R) TBB).
44

5+
Intel TBB 2020 Update 3
6+
TBB_INTERFACE_VERSION == 11103
7+
8+
Changes (w.r.t. Intel TBB 2020 Update 2):
9+
10+
Changes affecting backward compatibility:
11+
12+
- Changed body type concept of the flow::input_node.
13+
Set TBB_DEPRECATED_INPUT_NODE_BODY to 1 to compile with the previous
14+
concept of the body type.
15+
16+
Bugs fixed:
17+
18+
- Fixed compilation errors in C++20 mode due to ambiguity of comparison
19+
operators. Inspired by Barry Revzin
20+
(https://github.com/oneapi-src/oneTBB/pull/251).
21+
22+
Open-source contributions integrated:
23+
24+
- Fixed an issue in TBBBuild.cmake that causes the build with no arguments
25+
to fail (https://github.com/oneapi-src/oneTBB/pull/233) by tttapa.
26+
- Added cmake/{TBBConfig,TBBConfigVersion}.cmake to Git ignore list
27+
(https://github.com/oneapi-src/oneTBB/pull/239) by Eisuke Kawashima.
28+
29+
------------------------------------------------------------------------
530
Intel TBB 2020 Update 2
631
TBB_INTERFACE_VERSION == 11102
732

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Threading Building Blocks 2020
2-
[![Stable release](https://img.shields.io/badge/version-2020.2-green.svg)](https://github.com/intel/tbb/releases/tag/v2020.2)
2+
[![Stable release](https://img.shields.io/badge/version-2020.3-green.svg)](https://github.com/intel/tbb/releases/tag/v2020.3)
33
[![Apache License Version 2.0](https://img.shields.io/badge/license-Apache_2.0-green.svg)](LICENSE)
44

55
Threading Building Blocks (TBB) lets you easily write parallel C++ programs that take

cmake/TBBBuild.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function(tbb_build)
5454
set(multiValueArgs USER_DEFINED_ARGS)
5555
cmake_parse_arguments(tbb_GMA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
5656

57-
set(result ${tbb_GMA_USER_DEFINED_ARGS})
57+
set(result "${tbb_GMA_USER_DEFINED_ARGS}")
5858

5959
if (NOT tbb_GMA_USER_DEFINED_ARGS MATCHES "compiler=")
6060
# TODO: add other supported compilers.

include/tbb/flow_graph.h

+18-10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "task.h"
3030
#include "cache_aligned_allocator.h"
3131
#include "tbb_exception.h"
32+
#include "pipeline.h"
3233
#include "internal/_template_helpers.h"
3334
#include "internal/_aggregator_impl.h"
3435
#include "tbb/internal/_allocator_traits.h"
@@ -920,12 +921,12 @@ class input_node : public graph_node, public sender< Output > {
920921
template< typename Body >
921922
__TBB_NOINLINE_SYM input_node( graph &g, Body body )
922923
: graph_node(g), my_active(false),
923-
my_body( new internal::source_body_leaf< output_type, Body>(body) ),
924-
my_init_body( new internal::source_body_leaf< output_type, Body>(body) ),
924+
my_body( new internal::input_body_leaf< output_type, Body>(body) ),
925+
my_init_body( new internal::input_body_leaf< output_type, Body>(body) ),
925926
my_reserved(false), my_has_cached_item(false)
926927
{
927928
my_successors.set_owner(this);
928-
tbb::internal::fgt_node_with_body( CODEPTR(), tbb::internal::FLOW_SOURCE_NODE, &this->my_graph,
929+
tbb::internal::fgt_node_with_body( CODEPTR(), tbb::internal::FLOW_SOURCE_NODE, &this->my_graph,
929930
static_cast<sender<output_type> *>(this), this->my_body );
930931
}
931932

@@ -1066,8 +1067,8 @@ class input_node : public graph_node, public sender< Output > {
10661067

10671068
template<typename Body>
10681069
Body copy_function_object() {
1069-
internal::source_body<output_type> &body_ref = *this->my_body;
1070-
return dynamic_cast< internal::source_body_leaf<output_type, Body> & >(body_ref).get_body();
1070+
internal::input_body<output_type> &body_ref = *this->my_body;
1071+
return dynamic_cast< internal::input_body_leaf<output_type, Body> & >(body_ref).get_body();
10711072
}
10721073

10731074
#if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
@@ -1081,15 +1082,15 @@ class input_node : public graph_node, public sender< Output > {
10811082

10821083
protected:
10831084

1084-
//! resets the source_node to its initial state
1085+
//! resets the input_node to its initial state
10851086
void reset_node( reset_flags f) __TBB_override {
10861087
my_active = false;
10871088
my_reserved = false;
10881089
my_has_cached_item = false;
10891090

10901091
if(f & rf_clear_edges) my_successors.clear();
10911092
if(f & rf_reset_bodies) {
1092-
internal::source_body<output_type> *tmp = my_init_body->clone();
1093+
internal::input_body<output_type> *tmp = my_init_body->clone();
10931094
delete my_body;
10941095
my_body = tmp;
10951096
}
@@ -1098,8 +1099,8 @@ class input_node : public graph_node, public sender< Output > {
10981099
private:
10991100
spin_mutex my_mutex;
11001101
bool my_active;
1101-
internal::source_body<output_type> *my_body;
1102-
internal::source_body<output_type> *my_init_body;
1102+
internal::input_body<output_type> *my_body;
1103+
internal::input_body<output_type> *my_init_body;
11031104
internal::broadcast_cache< output_type > my_successors;
11041105
bool my_reserved;
11051106
bool my_has_cached_item;
@@ -1113,11 +1114,18 @@ class input_node : public graph_node, public sender< Output > {
11131114
}
11141115
if ( !my_has_cached_item ) {
11151116
tbb::internal::fgt_begin_body( my_body );
1117+
1118+
#if TBB_DEPRECATED_INPUT_NODE_BODY
11161119
bool r = (*my_body)(my_cached_item);
1117-
tbb::internal::fgt_end_body( my_body );
11181120
if (r) {
11191121
my_has_cached_item = true;
11201122
}
1123+
#else
1124+
flow_control control;
1125+
my_cached_item = (*my_body)(control);
1126+
my_has_cached_item = !control.is_pipeline_stopped;
1127+
#endif
1128+
tbb::internal::fgt_end_body( my_body );
11211129
}
11221130
if ( my_has_cached_item ) {
11231131
v = my_cached_item;

include/tbb/internal/_flow_graph_body_impl.h

+59-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#ifndef __TBB__flow_graph_body_impl_H
1818
#define __TBB__flow_graph_body_impl_H
1919

20+
#include "tbb/internal/_template_helpers.h"
21+
2022
#ifndef __TBB_flow_graph_H
2123
#error Do not #include this internal file directly; use public TBB headers instead.
2224
#endif
@@ -90,8 +92,61 @@ namespace graph_policy_namespace {
9092
} // namespace graph_policy_namespace
9193

9294
// -------------- function_body containers ----------------------
93-
9495
//! A functor that takes no input and generates a value of type Output
96+
template< typename Output >
97+
class input_body : tbb::internal::no_assign {
98+
public:
99+
virtual ~input_body() {}
100+
101+
#if TBB_DEPRECATED_INPUT_NODE_BODY
102+
virtual bool operator()(Output &output) = 0;
103+
#else
104+
virtual Output operator()(flow_control& fc) = 0;
105+
#endif
106+
virtual input_body* clone() = 0;
107+
};
108+
109+
template <typename Body>
110+
void check_input_node_body_input_type_impl(Body) {
111+
__TBB_STATIC_ASSERT((tbb::internal::is_same_type<typename tbb::internal::body_arg_detector<Body>::arg_type, flow_control&>::value),
112+
"TBB Warning: input_node body requirements have been changed."
113+
"To temporarily enforce deprecated API specify TBB_DEPRECATED_INPUT_NODE_BODY.");
114+
}
115+
116+
template <typename Body>
117+
void check_input_node_body_input_type(Body) {
118+
check_input_node_body_input_type_impl(&Body::operator());
119+
}
120+
121+
template <typename ReturnType, typename T>
122+
void check_input_node_body_input_type(ReturnType(*)(T)) {
123+
__TBB_STATIC_ASSERT((tbb::internal::is_same_type<T, flow_control&>::value),
124+
"TBB Warning: input_node body requirements have been changed."
125+
"To temporarily enforce deprecated API specify TBB_DEPRECATED_INPUT_NODE_BODY.");
126+
}
127+
128+
//! The leaf for input_body
129+
template< typename Output, typename Body>
130+
class input_body_leaf : public input_body<Output> {
131+
public:
132+
input_body_leaf( const Body &_body ) : body(_body) { }
133+
134+
#if TBB_DEPRECATED_INPUT_NODE_BODY
135+
bool operator()(Output &output) __TBB_override { return body( output ); }
136+
#else
137+
Output operator()(flow_control& fc) __TBB_override {
138+
check_input_node_body_input_type(body);
139+
return body(fc);
140+
}
141+
#endif
142+
input_body_leaf* clone() __TBB_override {
143+
return new input_body_leaf< Output, Body >(body);
144+
}
145+
Body get_body() { return body; }
146+
private:
147+
Body body;
148+
};
149+
95150
template< typename Output >
96151
class source_body : tbb::internal::no_assign {
97152
public:
@@ -105,10 +160,13 @@ template< typename Output, typename Body>
105160
class source_body_leaf : public source_body<Output> {
106161
public:
107162
source_body_leaf( const Body &_body ) : body(_body) { }
163+
108164
bool operator()(Output &output) __TBB_override { return body( output ); }
165+
109166
source_body_leaf* clone() __TBB_override {
110167
return new source_body_leaf< Output, Body >(body);
111168
}
169+
112170
Body get_body() { return body; }
113171
private:
114172
Body body;

include/tbb/internal/_flow_graph_impl.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,11 @@ class graph : tbb::internal::no_copy, public tbb::flow::graph_proxy {
292292
void set_name(const char *name);
293293
#endif
294294

295-
void increment_wait_count() {
295+
__TBB_DEPRECATED void increment_wait_count() {
296296
reserve_wait();
297297
}
298298

299-
void decrement_wait_count() {
299+
__TBB_DEPRECATED void decrement_wait_count() {
300300
release_wait();
301301
}
302302

@@ -314,7 +314,7 @@ class graph : tbb::internal::no_copy, public tbb::flow::graph_proxy {
314314
/** The task is spawned as a child of the graph. This is useful for running tasks
315315
that need to block a wait_for_all() on the graph. For example a one-off source. */
316316
template< typename Receiver, typename Body >
317-
void run(Receiver &r, Body body) {
317+
__TBB_DEPRECATED void run(Receiver &r, Body body) {
318318
if (tbb::flow::interface11::internal::is_graph_active(*this)) {
319319
task* rtask = new (task::allocate_additional_child_of(*root_task()))
320320
run_and_put_task< Receiver, Body >(r, body);
@@ -326,7 +326,7 @@ class graph : tbb::internal::no_copy, public tbb::flow::graph_proxy {
326326
/** The task is spawned as a child of the graph. This is useful for running tasks
327327
that need to block a wait_for_all() on the graph. For example a one-off source. */
328328
template< typename Body >
329-
void run(Body body) {
329+
__TBB_DEPRECATED void run(Body body) {
330330
if (tbb::flow::interface11::internal::is_graph_active(*this)) {
331331
task* rtask = new (task::allocate_additional_child_of(*root_task())) run_task< Body >(body);
332332
my_task_arena->execute(spawn_functor(*rtask));
@@ -371,7 +371,7 @@ class graph : tbb::internal::no_copy, public tbb::flow::graph_proxy {
371371
}
372372

373373
//! Returns the root task of the graph
374-
tbb::task * root_task() {
374+
__TBB_DEPRECATED tbb::task * root_task() {
375375
return my_root_task;
376376
}
377377

include/tbb/internal/_flow_graph_nodes_deduction.h

+28
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ struct declare_body_types {
2929
using output_type = Output;
3030
};
3131

32+
struct NoInputBody {};
33+
34+
template <typename Output>
35+
struct declare_body_types<NoInputBody, Output> {
36+
using output_type = Output;
37+
};
38+
3239
template <typename T> struct body_types;
3340

3441
template <typename T, typename Input, typename Output>
@@ -49,6 +56,15 @@ struct body_types<Output (*)(Input&)> : declare_body_types<Input, Output> {};
4956
template <typename Input, typename Output>
5057
struct body_types<Output (*)(const Input&)> : declare_body_types<Input, Output> {};
5158

59+
template <typename T, typename Output>
60+
struct body_types<Output (T::*)(flow_control&) const> : declare_body_types<NoInputBody, Output> {};
61+
62+
template <typename T, typename Output>
63+
struct body_types<Output (T::*)(flow_control&)> : declare_body_types<NoInputBody, Output> {};
64+
65+
template <typename Output>
66+
struct body_types<Output (*)(flow_control&)> : declare_body_types<NoInputBody, Output> {};
67+
5268
template <typename Body>
5369
using input_t = typename body_types<Body>::input_type;
5470

@@ -81,18 +97,30 @@ decltype(decide_on_operator_overload(std::declval<Body>())) decide_on_callable_t
8197

8298
// Deduction guides for Flow Graph nodes
8399
#if TBB_USE_SOURCE_NODE_AS_ALIAS
100+
#if TBB_DEPRECATED_INPUT_NODE_BODY
84101
template <typename GraphOrSet, typename Body>
85102
source_node(GraphOrSet&&, Body)
86103
->source_node<input_t<decltype(decide_on_callable_type<Body>(0))>>;
87104
#else
88105
template <typename GraphOrSet, typename Body>
106+
source_node(GraphOrSet&&, Body)
107+
->source_node<output_t<decltype(decide_on_callable_type<Body>(0))>>;
108+
#endif // TBB_DEPRECATED_INPUT_NODE_BODY
109+
#else
110+
template <typename GraphOrSet, typename Body>
89111
source_node(GraphOrSet&&, Body, bool = true)
90112
->source_node<input_t<decltype(decide_on_callable_type<Body>(0))>>;
91113
#endif
92114

115+
#if TBB_DEPRECATED_INPUT_NODE_BODY
93116
template <typename GraphOrSet, typename Body>
94117
input_node(GraphOrSet&&, Body, bool = true)
95118
->input_node<input_t<decltype(decide_on_callable_type<Body>(0))>>;
119+
#else
120+
template <typename GraphOrSet, typename Body>
121+
input_node(GraphOrSet&&, Body)
122+
->input_node<output_t<decltype(decide_on_callable_type<Body>(0))>>;
123+
#endif
96124

97125
#if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET
98126

include/tbb/internal/_template_helpers.h

+27
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,33 @@ using is_transparent = typename std::conditional<true, Comp, K>::type::is_transp
279279

280280
#endif /* __TBB_CPP11_PRESENT */
281281

282+
template <typename F>
283+
struct body_arg_detector;
284+
285+
template <typename Callable, typename ReturnType, typename T>
286+
struct body_arg_detector<ReturnType(Callable::*)(T)> {
287+
typedef T arg_type;
288+
};
289+
290+
template <typename Callable, typename ReturnType, typename T>
291+
struct body_arg_detector<ReturnType(Callable::*)(T) const> {
292+
typedef T arg_type;
293+
};
294+
295+
#if __TBB_CPP11_PRESENT
296+
using std::conditional;
297+
#else
298+
template <bool C, typename T, typename U>
299+
struct conditional {
300+
typedef U type;
301+
};
302+
303+
template <typename T, typename U>
304+
struct conditional<true, T, U> {
305+
typedef T type;
306+
};
307+
#endif
308+
282309
} } // namespace internal, namespace tbb
283310

284311
#endif /* __TBB_template_helpers_H */

include/tbb/partitioner.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace interface9 {
7676
namespace internal { //< @cond INTERNAL
7777
size_t __TBB_EXPORTED_FUNC get_initial_auto_partitioner_divisor();
7878

79-
//! Defines entry point for affinity partitioner into tbb run-time library.
79+
//! Defines entry point for affinity partitioner into TBB run-time library.
8080
class affinity_partitioner_base_v3: no_copy {
8181
friend class tbb::affinity_partitioner;
8282
friend class tbb::interface9::internal::affinity_partition_type;

include/tbb/pipeline.h

+7
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,12 @@ class __TBB_DEPRECATED_MSG("tbb::pipeline is deprecated, use tbb::parallel_pipel
300300
// Support for lambda-friendly parallel_pipeline interface
301301
//------------------------------------------------------------------------
302302

303+
namespace flow {
304+
namespace interface11 {
305+
template<typename Output> class input_node;
306+
}
307+
}
308+
303309
namespace interface6 {
304310

305311
namespace internal {
@@ -311,6 +317,7 @@ class flow_control {
311317
bool is_pipeline_stopped;
312318
flow_control() { is_pipeline_stopped = false; }
313319
template<typename T, typename U, typename Body> friend class internal::concrete_filter;
320+
template<typename Output> friend class flow::interface11::input_node;
314321
public:
315322
void stop() { is_pipeline_stopped = true; }
316323
};

0 commit comments

Comments
 (0)