Skip to content

Commit

Permalink
Committing TBB 2020 Update 3 source code
Browse files Browse the repository at this point in the history
  • Loading branch information
tbbdev committed Jul 10, 2020
1 parent 60b7d0a commit eca91f1
Show file tree
Hide file tree
Showing 35 changed files with 499 additions and 132 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ Thumbs.db
################################
CMakeCache.txt
CMakeFiles/
cmake/TBBConfig.cmake
cmake/TBBConfigVersion.cmake

# Other #
#########
Expand Down
25 changes: 25 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@
The list of most significant changes made over time in
Intel(R) Threading Building Blocks (Intel(R) TBB).

Intel TBB 2020 Update 3
TBB_INTERFACE_VERSION == 11103

Changes (w.r.t. Intel TBB 2020 Update 2):

Changes affecting backward compatibility:

- Changed body type concept of the flow::input_node.
Set TBB_DEPRECATED_INPUT_NODE_BODY to 1 to compile with the previous
concept of the body type.

Bugs fixed:

- Fixed compilation errors in C++20 mode due to ambiguity of comparison
operators. Inspired by Barry Revzin
(https://github.com/oneapi-src/oneTBB/pull/251).

Open-source contributions integrated:

- Fixed an issue in TBBBuild.cmake that causes the build with no arguments
to fail (https://github.com/oneapi-src/oneTBB/pull/233) by tttapa.
- Added cmake/{TBBConfig,TBBConfigVersion}.cmake to Git ignore list
(https://github.com/oneapi-src/oneTBB/pull/239) by Eisuke Kawashima.

------------------------------------------------------------------------
Intel TBB 2020 Update 2
TBB_INTERFACE_VERSION == 11102

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Threading Building Blocks 2020
[![Stable release](https://img.shields.io/badge/version-2020.2-green.svg)](https://github.com/intel/tbb/releases/tag/v2020.2)
[![Stable release](https://img.shields.io/badge/version-2020.3-green.svg)](https://github.com/intel/tbb/releases/tag/v2020.3)
[![Apache License Version 2.0](https://img.shields.io/badge/license-Apache_2.0-green.svg)](LICENSE)

Threading Building Blocks (TBB) lets you easily write parallel C++ programs that take
Expand Down
2 changes: 1 addition & 1 deletion cmake/TBBBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function(tbb_build)
set(multiValueArgs USER_DEFINED_ARGS)
cmake_parse_arguments(tbb_GMA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

set(result ${tbb_GMA_USER_DEFINED_ARGS})
set(result "${tbb_GMA_USER_DEFINED_ARGS}")

if (NOT tbb_GMA_USER_DEFINED_ARGS MATCHES "compiler=")
# TODO: add other supported compilers.
Expand Down
28 changes: 18 additions & 10 deletions include/tbb/flow_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "task.h"
#include "cache_aligned_allocator.h"
#include "tbb_exception.h"
#include "pipeline.h"
#include "internal/_template_helpers.h"
#include "internal/_aggregator_impl.h"
#include "tbb/internal/_allocator_traits.h"
Expand Down Expand Up @@ -920,12 +921,12 @@ class input_node : public graph_node, public sender< Output > {
template< typename Body >
__TBB_NOINLINE_SYM input_node( graph &g, Body body )
: graph_node(g), my_active(false),
my_body( new internal::source_body_leaf< output_type, Body>(body) ),
my_init_body( new internal::source_body_leaf< output_type, Body>(body) ),
my_body( new internal::input_body_leaf< output_type, Body>(body) ),
my_init_body( new internal::input_body_leaf< output_type, Body>(body) ),
my_reserved(false), my_has_cached_item(false)
{
my_successors.set_owner(this);
tbb::internal::fgt_node_with_body( CODEPTR(), tbb::internal::FLOW_SOURCE_NODE, &this->my_graph,
tbb::internal::fgt_node_with_body( CODEPTR(), tbb::internal::FLOW_SOURCE_NODE, &this->my_graph,
static_cast<sender<output_type> *>(this), this->my_body );
}

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

template<typename Body>
Body copy_function_object() {
internal::source_body<output_type> &body_ref = *this->my_body;
return dynamic_cast< internal::source_body_leaf<output_type, Body> & >(body_ref).get_body();
internal::input_body<output_type> &body_ref = *this->my_body;
return dynamic_cast< internal::input_body_leaf<output_type, Body> & >(body_ref).get_body();
}

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

protected:

//! resets the source_node to its initial state
//! resets the input_node to its initial state
void reset_node( reset_flags f) __TBB_override {
my_active = false;
my_reserved = false;
my_has_cached_item = false;

if(f & rf_clear_edges) my_successors.clear();
if(f & rf_reset_bodies) {
internal::source_body<output_type> *tmp = my_init_body->clone();
internal::input_body<output_type> *tmp = my_init_body->clone();
delete my_body;
my_body = tmp;
}
Expand All @@ -1098,8 +1099,8 @@ class input_node : public graph_node, public sender< Output > {
private:
spin_mutex my_mutex;
bool my_active;
internal::source_body<output_type> *my_body;
internal::source_body<output_type> *my_init_body;
internal::input_body<output_type> *my_body;
internal::input_body<output_type> *my_init_body;
internal::broadcast_cache< output_type > my_successors;
bool my_reserved;
bool my_has_cached_item;
Expand All @@ -1113,11 +1114,18 @@ class input_node : public graph_node, public sender< Output > {
}
if ( !my_has_cached_item ) {
tbb::internal::fgt_begin_body( my_body );

#if TBB_DEPRECATED_INPUT_NODE_BODY
bool r = (*my_body)(my_cached_item);
tbb::internal::fgt_end_body( my_body );
if (r) {
my_has_cached_item = true;
}
#else
flow_control control;
my_cached_item = (*my_body)(control);
my_has_cached_item = !control.is_pipeline_stopped;
#endif
tbb::internal::fgt_end_body( my_body );
}
if ( my_has_cached_item ) {
v = my_cached_item;
Expand Down
60 changes: 59 additions & 1 deletion include/tbb/internal/_flow_graph_body_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#ifndef __TBB__flow_graph_body_impl_H
#define __TBB__flow_graph_body_impl_H

#include "tbb/internal/_template_helpers.h"

#ifndef __TBB_flow_graph_H
#error Do not #include this internal file directly; use public TBB headers instead.
#endif
Expand Down Expand Up @@ -90,8 +92,61 @@ namespace graph_policy_namespace {
} // namespace graph_policy_namespace

// -------------- function_body containers ----------------------

//! A functor that takes no input and generates a value of type Output
template< typename Output >
class input_body : tbb::internal::no_assign {
public:
virtual ~input_body() {}

#if TBB_DEPRECATED_INPUT_NODE_BODY
virtual bool operator()(Output &output) = 0;
#else
virtual Output operator()(flow_control& fc) = 0;
#endif
virtual input_body* clone() = 0;
};

template <typename Body>
void check_input_node_body_input_type_impl(Body) {
__TBB_STATIC_ASSERT((tbb::internal::is_same_type<typename tbb::internal::body_arg_detector<Body>::arg_type, flow_control&>::value),
"TBB Warning: input_node body requirements have been changed."
"To temporarily enforce deprecated API specify TBB_DEPRECATED_INPUT_NODE_BODY.");
}

template <typename Body>
void check_input_node_body_input_type(Body) {
check_input_node_body_input_type_impl(&Body::operator());
}

template <typename ReturnType, typename T>
void check_input_node_body_input_type(ReturnType(*)(T)) {
__TBB_STATIC_ASSERT((tbb::internal::is_same_type<T, flow_control&>::value),
"TBB Warning: input_node body requirements have been changed."
"To temporarily enforce deprecated API specify TBB_DEPRECATED_INPUT_NODE_BODY.");
}

//! The leaf for input_body
template< typename Output, typename Body>
class input_body_leaf : public input_body<Output> {
public:
input_body_leaf( const Body &_body ) : body(_body) { }

#if TBB_DEPRECATED_INPUT_NODE_BODY
bool operator()(Output &output) __TBB_override { return body( output ); }
#else
Output operator()(flow_control& fc) __TBB_override {
check_input_node_body_input_type(body);
return body(fc);
}
#endif
input_body_leaf* clone() __TBB_override {
return new input_body_leaf< Output, Body >(body);
}
Body get_body() { return body; }
private:
Body body;
};

template< typename Output >
class source_body : tbb::internal::no_assign {
public:
Expand All @@ -105,10 +160,13 @@ template< typename Output, typename Body>
class source_body_leaf : public source_body<Output> {
public:
source_body_leaf( const Body &_body ) : body(_body) { }

bool operator()(Output &output) __TBB_override { return body( output ); }

source_body_leaf* clone() __TBB_override {
return new source_body_leaf< Output, Body >(body);
}

Body get_body() { return body; }
private:
Body body;
Expand Down
10 changes: 5 additions & 5 deletions include/tbb/internal/_flow_graph_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ class graph : tbb::internal::no_copy, public tbb::flow::graph_proxy {
void set_name(const char *name);
#endif

void increment_wait_count() {
__TBB_DEPRECATED void increment_wait_count() {
reserve_wait();
}

void decrement_wait_count() {
__TBB_DEPRECATED void decrement_wait_count() {
release_wait();
}

Expand All @@ -314,7 +314,7 @@ class graph : tbb::internal::no_copy, public tbb::flow::graph_proxy {
/** The task is spawned as a child of the graph. This is useful for running tasks
that need to block a wait_for_all() on the graph. For example a one-off source. */
template< typename Receiver, typename Body >
void run(Receiver &r, Body body) {
__TBB_DEPRECATED void run(Receiver &r, Body body) {
if (tbb::flow::interface11::internal::is_graph_active(*this)) {
task* rtask = new (task::allocate_additional_child_of(*root_task()))
run_and_put_task< Receiver, Body >(r, body);
Expand All @@ -326,7 +326,7 @@ class graph : tbb::internal::no_copy, public tbb::flow::graph_proxy {
/** The task is spawned as a child of the graph. This is useful for running tasks
that need to block a wait_for_all() on the graph. For example a one-off source. */
template< typename Body >
void run(Body body) {
__TBB_DEPRECATED void run(Body body) {
if (tbb::flow::interface11::internal::is_graph_active(*this)) {
task* rtask = new (task::allocate_additional_child_of(*root_task())) run_task< Body >(body);
my_task_arena->execute(spawn_functor(*rtask));
Expand Down Expand Up @@ -371,7 +371,7 @@ class graph : tbb::internal::no_copy, public tbb::flow::graph_proxy {
}

//! Returns the root task of the graph
tbb::task * root_task() {
__TBB_DEPRECATED tbb::task * root_task() {
return my_root_task;
}

Expand Down
28 changes: 28 additions & 0 deletions include/tbb/internal/_flow_graph_nodes_deduction.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ struct declare_body_types {
using output_type = Output;
};

struct NoInputBody {};

template <typename Output>
struct declare_body_types<NoInputBody, Output> {
using output_type = Output;
};

template <typename T> struct body_types;

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

template <typename T, typename Output>
struct body_types<Output (T::*)(flow_control&) const> : declare_body_types<NoInputBody, Output> {};

template <typename T, typename Output>
struct body_types<Output (T::*)(flow_control&)> : declare_body_types<NoInputBody, Output> {};

template <typename Output>
struct body_types<Output (*)(flow_control&)> : declare_body_types<NoInputBody, Output> {};

template <typename Body>
using input_t = typename body_types<Body>::input_type;

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

// Deduction guides for Flow Graph nodes
#if TBB_USE_SOURCE_NODE_AS_ALIAS
#if TBB_DEPRECATED_INPUT_NODE_BODY
template <typename GraphOrSet, typename Body>
source_node(GraphOrSet&&, Body)
->source_node<input_t<decltype(decide_on_callable_type<Body>(0))>>;
#else
template <typename GraphOrSet, typename Body>
source_node(GraphOrSet&&, Body)
->source_node<output_t<decltype(decide_on_callable_type<Body>(0))>>;
#endif // TBB_DEPRECATED_INPUT_NODE_BODY
#else
template <typename GraphOrSet, typename Body>
source_node(GraphOrSet&&, Body, bool = true)
->source_node<input_t<decltype(decide_on_callable_type<Body>(0))>>;
#endif

#if TBB_DEPRECATED_INPUT_NODE_BODY
template <typename GraphOrSet, typename Body>
input_node(GraphOrSet&&, Body, bool = true)
->input_node<input_t<decltype(decide_on_callable_type<Body>(0))>>;
#else
template <typename GraphOrSet, typename Body>
input_node(GraphOrSet&&, Body)
->input_node<output_t<decltype(decide_on_callable_type<Body>(0))>>;
#endif

#if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET

Expand Down
27 changes: 27 additions & 0 deletions include/tbb/internal/_template_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,33 @@ using is_transparent = typename std::conditional<true, Comp, K>::type::is_transp

#endif /* __TBB_CPP11_PRESENT */

template <typename F>
struct body_arg_detector;

template <typename Callable, typename ReturnType, typename T>
struct body_arg_detector<ReturnType(Callable::*)(T)> {
typedef T arg_type;
};

template <typename Callable, typename ReturnType, typename T>
struct body_arg_detector<ReturnType(Callable::*)(T) const> {
typedef T arg_type;
};

#if __TBB_CPP11_PRESENT
using std::conditional;
#else
template <bool C, typename T, typename U>
struct conditional {
typedef U type;
};

template <typename T, typename U>
struct conditional<true, T, U> {
typedef T type;
};
#endif

} } // namespace internal, namespace tbb

#endif /* __TBB_template_helpers_H */
2 changes: 1 addition & 1 deletion include/tbb/partitioner.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace interface9 {
namespace internal { //< @cond INTERNAL
size_t __TBB_EXPORTED_FUNC get_initial_auto_partitioner_divisor();

//! Defines entry point for affinity partitioner into tbb run-time library.
//! Defines entry point for affinity partitioner into TBB run-time library.
class affinity_partitioner_base_v3: no_copy {
friend class tbb::affinity_partitioner;
friend class tbb::interface9::internal::affinity_partition_type;
Expand Down
7 changes: 7 additions & 0 deletions include/tbb/pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ class __TBB_DEPRECATED_MSG("tbb::pipeline is deprecated, use tbb::parallel_pipel
// Support for lambda-friendly parallel_pipeline interface
//------------------------------------------------------------------------

namespace flow {
namespace interface11 {
template<typename Output> class input_node;
}
}

namespace interface6 {

namespace internal {
Expand All @@ -311,6 +317,7 @@ class flow_control {
bool is_pipeline_stopped;
flow_control() { is_pipeline_stopped = false; }
template<typename T, typename U, typename Body> friend class internal::concrete_filter;
template<typename Output> friend class flow::interface11::input_node;
public:
void stop() { is_pipeline_stopped = true; }
};
Expand Down
Loading

0 comments on commit eca91f1

Please sign in to comment.