From c5f15747e4ee03c29f7f8fbecfff6f2136f9a769 Mon Sep 17 00:00:00 2001 From: John-Paul Smith Date: Mon, 9 May 2022 17:09:57 +0100 Subject: [PATCH 1/7] Updated to TBB 2020 Update 3 --- .gitignore | 2 + CHANGES | 25 ++++ README.md | 2 +- include/tbb/flow_graph.h | 28 +++-- include/tbb/internal/_flow_graph_body_impl.h | 60 ++++++++- include/tbb/internal/_flow_graph_impl.h | 10 +- .../internal/_flow_graph_nodes_deduction.h | 28 +++++ include/tbb/internal/_template_helpers.h | 27 ++++ include/tbb/partitioner.h | 2 +- include/tbb/pipeline.h | 7 ++ include/tbb/task.h | 2 +- include/tbb/task_scheduler_init.h | 4 +- include/tbb/tbb_stddef.h | 4 +- python/tbb/__init__.py | 2 +- src/rml/include/rml_omp.h | 4 +- src/rml/include/rml_tbb.h | 6 +- src/rml/server/rml_server.cpp | 22 ++-- src/tbb/intrusive_list.h | 117 +++++++++--------- src/tbb/tools_api/ittnotify.h | 2 +- src/test/harness_eh.h | 2 +- src/test/harness_graph.h | 2 +- src/test/test_composite_node.cpp | 18 ++- src/test/test_eh_flow_graph.cpp | 46 ++++++- src/test/test_flow_graph.cpp | 14 +++ src/test/test_flow_graph_priorities.cpp | 12 ++ src/test/test_flow_graph_whitebox.cpp | 12 ++ src/test/test_indexer_node.cpp | 15 +++ src/test/test_input_node.cpp | 59 ++++++--- src/test/test_join_node.h | 25 ++++ src/test/test_runtime_loader.cpp | 2 +- src/test/test_source_node.cpp | 46 ++++++- src/test/test_split_node.cpp | 14 +++ src/test/test_task_scheduler_init.cpp | 4 +- src/test/test_tbb_version.cpp | 4 +- 34 files changed, 498 insertions(+), 131 deletions(-) diff --git a/.gitignore b/.gitignore index 50fffbf0..71e5c885 100644 --- a/.gitignore +++ b/.gitignore @@ -76,6 +76,8 @@ Thumbs.db ################################ CMakeCache.txt CMakeFiles/ +cmake/TBBConfig.cmake +cmake/TBBConfigVersion.cmake *.cmake libtbb.dylib diff --git a/CHANGES b/CHANGES index de502b68..e96a9699 100644 --- a/CHANGES +++ b/CHANGES @@ -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 diff --git a/README.md b/README.md index 6a18884b..adeb1f88 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ### Intel(R) Threading Building Blocks -[![Stable release](https://img.shields.io/badge/version-2020.2-green.svg)](https://github.com/01org/tbb/releases/tag/v2020.2) +[![Stable release](https://img.shields.io/badge/version-2020.3-green.svg)](https://github.com/01org/tbb/releases/tag/v2020.3) [![Apache License Version 2.0](https://img.shields.io/badge/license-Apache_2.0-green.svg)](LICENSE) [![Build Status](https://travis-ci.org/wjakob/tbb.svg?branch=master)](https://travis-ci.org/wjakob/tbb) [![Build status](https://ci.appveyor.com/api/projects/status/fvepmk5nxekq27r8?svg=true)](https://ci.appveyor.com/project/wjakob/tbb/branch/master) diff --git a/include/tbb/flow_graph.h b/include/tbb/flow_graph.h index 8c9702e1..03020f79 100644 --- a/include/tbb/flow_graph.h +++ b/include/tbb/flow_graph.h @@ -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" @@ -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 *>(this), this->my_body ); } @@ -1066,8 +1067,8 @@ class input_node : public graph_node, public sender< Output > { template Body copy_function_object() { - internal::source_body &body_ref = *this->my_body; - return dynamic_cast< internal::source_body_leaf & >(body_ref).get_body(); + internal::input_body &body_ref = *this->my_body; + return dynamic_cast< internal::input_body_leaf & >(body_ref).get_body(); } #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION @@ -1081,7 +1082,7 @@ 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; @@ -1089,7 +1090,7 @@ class input_node : public graph_node, public sender< Output > { if(f & rf_clear_edges) my_successors.clear(); if(f & rf_reset_bodies) { - internal::source_body *tmp = my_init_body->clone(); + internal::input_body *tmp = my_init_body->clone(); delete my_body; my_body = tmp; } @@ -1098,8 +1099,8 @@ class input_node : public graph_node, public sender< Output > { private: spin_mutex my_mutex; bool my_active; - internal::source_body *my_body; - internal::source_body *my_init_body; + internal::input_body *my_body; + internal::input_body *my_init_body; internal::broadcast_cache< output_type > my_successors; bool my_reserved; bool my_has_cached_item; @@ -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; diff --git a/include/tbb/internal/_flow_graph_body_impl.h b/include/tbb/internal/_flow_graph_body_impl.h index 5d3ad6a0..e75f50da 100644 --- a/include/tbb/internal/_flow_graph_body_impl.h +++ b/include/tbb/internal/_flow_graph_body_impl.h @@ -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 @@ -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 +void check_input_node_body_input_type_impl(Body) { + __TBB_STATIC_ASSERT((tbb::internal::is_same_type::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 +void check_input_node_body_input_type(Body) { + check_input_node_body_input_type_impl(&Body::operator()); +} + +template +void check_input_node_body_input_type(ReturnType(*)(T)) { + __TBB_STATIC_ASSERT((tbb::internal::is_same_type::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 { +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: @@ -105,10 +160,13 @@ template< typename Output, typename Body> class source_body_leaf : public source_body { 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; diff --git a/include/tbb/internal/_flow_graph_impl.h b/include/tbb/internal/_flow_graph_impl.h index 2f18676e..7859e944 100644 --- a/include/tbb/internal/_flow_graph_impl.h +++ b/include/tbb/internal/_flow_graph_impl.h @@ -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(); } @@ -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); @@ -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)); @@ -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; } diff --git a/include/tbb/internal/_flow_graph_nodes_deduction.h b/include/tbb/internal/_flow_graph_nodes_deduction.h index ffdfae2e..caf2f689 100644 --- a/include/tbb/internal/_flow_graph_nodes_deduction.h +++ b/include/tbb/internal/_flow_graph_nodes_deduction.h @@ -29,6 +29,13 @@ struct declare_body_types { using output_type = Output; }; +struct NoInputBody {}; + +template +struct declare_body_types { + using output_type = Output; +}; + template struct body_types; template @@ -49,6 +56,15 @@ struct body_types : declare_body_types {}; template struct body_types : declare_body_types {}; +template +struct body_types : declare_body_types {}; + +template +struct body_types : declare_body_types {}; + +template +struct body_types : declare_body_types {}; + template using input_t = typename body_types::input_type; @@ -81,18 +97,30 @@ decltype(decide_on_operator_overload(std::declval())) decide_on_callable_t // Deduction guides for Flow Graph nodes #if TBB_USE_SOURCE_NODE_AS_ALIAS +#if TBB_DEPRECATED_INPUT_NODE_BODY template source_node(GraphOrSet&&, Body) ->source_node(0))>>; #else template +source_node(GraphOrSet&&, Body) +->source_node(0))>>; +#endif // TBB_DEPRECATED_INPUT_NODE_BODY +#else +template source_node(GraphOrSet&&, Body, bool = true) ->source_node(0))>>; #endif +#if TBB_DEPRECATED_INPUT_NODE_BODY template input_node(GraphOrSet&&, Body, bool = true) ->input_node(0))>>; +#else +template +input_node(GraphOrSet&&, Body) +->input_node(0))>>; +#endif #if __TBB_PREVIEW_FLOW_GRAPH_NODE_SET diff --git a/include/tbb/internal/_template_helpers.h b/include/tbb/internal/_template_helpers.h index 197f77a1..08470430 100644 --- a/include/tbb/internal/_template_helpers.h +++ b/include/tbb/internal/_template_helpers.h @@ -279,6 +279,33 @@ using is_transparent = typename std::conditional::type::is_transp #endif /* __TBB_CPP11_PRESENT */ +template +struct body_arg_detector; + +template +struct body_arg_detector { + typedef T arg_type; +}; + +template +struct body_arg_detector { + typedef T arg_type; +}; + +#if __TBB_CPP11_PRESENT +using std::conditional; +#else +template +struct conditional { + typedef U type; +}; + +template +struct conditional { + typedef T type; +}; +#endif + } } // namespace internal, namespace tbb #endif /* __TBB_template_helpers_H */ diff --git a/include/tbb/partitioner.h b/include/tbb/partitioner.h index 23990868..c130d349 100644 --- a/include/tbb/partitioner.h +++ b/include/tbb/partitioner.h @@ -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; diff --git a/include/tbb/pipeline.h b/include/tbb/pipeline.h index 13bf4e33..b8212ddb 100644 --- a/include/tbb/pipeline.h +++ b/include/tbb/pipeline.h @@ -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 class input_node; +} +} + namespace interface6 { namespace internal { @@ -311,6 +317,7 @@ class flow_control { bool is_pipeline_stopped; flow_control() { is_pipeline_stopped = false; } template friend class internal::concrete_filter; + template friend class flow::interface11::input_node; public: void stop() { is_pipeline_stopped = true; } }; diff --git a/include/tbb/task.h b/include/tbb/task.h index d58fb361..5e137c69 100644 --- a/include/tbb/task.h +++ b/include/tbb/task.h @@ -510,7 +510,7 @@ class task_group_context : internal::no_copy { init(); } - // Custom constructor for instrumentation of tbb algorithm + // Custom constructor for instrumentation of TBB algorithm task_group_context ( internal::string_index name ) : my_kind(bound) , my_version_and_traits(3 | default_traits) diff --git a/include/tbb/task_scheduler_init.h b/include/tbb/task_scheduler_init.h index c025454b..687bba1d 100644 --- a/include/tbb/task_scheduler_init.h +++ b/include/tbb/task_scheduler_init.h @@ -146,8 +146,8 @@ class __TBB_DEPRECATED_IN_VERBOSE_MODE task_scheduler_init: internal::no_copy { /** Result returned by this method does not depend on whether the scheduler has already been initialized. - Because tbb 2.0 does not support blocking tasks yet, you may use this method - to boost the number of threads in the tbb's internal pool, if your tasks are + Because TBB 2.0 does not support blocking tasks yet, you may use this method + to boost the number of threads in the TBB's internal pool, if your tasks are doing I/O operations. The optimal number of additional threads depends on how much time your tasks spend in the blocked state. diff --git a/include/tbb/tbb_stddef.h b/include/tbb/tbb_stddef.h index aed4d1c4..96743024 100644 --- a/include/tbb/tbb_stddef.h +++ b/include/tbb/tbb_stddef.h @@ -19,10 +19,10 @@ // Marketing-driven product version #define TBB_VERSION_MAJOR 2020 -#define TBB_VERSION_MINOR 2 +#define TBB_VERSION_MINOR 3 // Engineering-focused interface version -#define TBB_INTERFACE_VERSION 11102 +#define TBB_INTERFACE_VERSION 11103 #define TBB_INTERFACE_VERSION_MAJOR TBB_INTERFACE_VERSION/1000 // The oldest major interface version still supported diff --git a/python/tbb/__init__.py b/python/tbb/__init__.py index 2446c2a9..508ad1ef 100644 --- a/python/tbb/__init__.py +++ b/python/tbb/__init__.py @@ -31,7 +31,7 @@ __all__ = ["Monkey", "is_active"] + api__all + pool__all __doc__ = """ -Python API for Intel(R) Threading Building Blocks library (Intel(R) TBB) +Python API for Intel(R) Threading Building Blocks (Intel(R) TBB) extended with standard Python's pools implementation and monkey-patching. Command-line interface example: diff --git a/src/rml/include/rml_omp.h b/src/rml/include/rml_omp.h index 2c203141..6838d48c 100644 --- a/src/rml/include/rml_omp.h +++ b/src/rml/include/rml_omp.h @@ -60,10 +60,10 @@ class omp_server: public ::rml::server { Note: conversion between a coin and a thread does not affect the accounting. */ #if _WIN32||_WIN64 - //! Inform server of a tbb master thread. + //! Inform server of a TBB master thread. virtual void register_master( execution_resource_t& /*v*/ ) = 0; - //! Inform server that the tbb master thread is done with its work. + //! Inform server that the TBB master thread is done with its work. virtual void unregister_master( execution_resource_t /*v*/ ) = 0; //! deactivate diff --git a/src/rml/include/rml_tbb.h b/src/rml/include/rml_tbb.h index a7d85929..452a8967 100644 --- a/src/rml/include/rml_tbb.h +++ b/src/rml/include/rml_tbb.h @@ -32,17 +32,17 @@ class tbb_client; // Classes instantiated by the server //------------------------------------------------------------------------ -//! Represents a set of tbb worker threads provided by the server. +//! Represents a set of TBB worker threads provided by the server. class tbb_server: public ::rml::server { public: //! Inform server of adjustments in the number of workers that the client can profitably use. virtual void adjust_job_count_estimate( int delta ) = 0; #if _WIN32||_WIN64 - //! Inform server of a tbb master thread. + //! Inform server of a TBB master thread. virtual void register_master( execution_resource_t& v ) = 0; - //! Inform server that the tbb master thread is done with its work. + //! Inform server that the TBB master thread is done with its work. virtual void unregister_master( execution_resource_t v ) = 0; #endif /* _WIN32||_WIN64 */ }; diff --git a/src/rml/server/rml_server.cpp b/src/rml/server/rml_server.cpp index 75dd828c..d73c6e66 100644 --- a/src/rml/server/rml_server.cpp +++ b/src/rml/server/rml_server.cpp @@ -147,7 +147,7 @@ enum thread_state_t { ts_omp_busy, //! Thread is busy doing TBB work. ts_tbb_busy, - //! For tbb threads only + //! For TBB threads only ts_done, ts_created, ts_started, @@ -1005,7 +1005,7 @@ connection_scavenger_thread connection_scavenger; template struct connection_traits {}; -// head of the active tbb connections +// head of the active TBB connections static tbb::atomic active_tbb_connections; static tbb::atomic current_tbb_conn_readers; static size_t current_tbb_conn_reader_epoch; @@ -1381,7 +1381,7 @@ template void generic_connection::request_close_connection( bool ) { #endif /* RML_USE_WCRM */ if( connection_traits::is_tbb ) { - // acquire the head of active tbb connections + // acquire the head of active TBB connections uintptr_t conn; do { for( ; (conn=active_tbb_connections)&1; ) @@ -1402,7 +1402,7 @@ void generic_connection::request_close_connection( bool ) { } else active_tbb_connections = (uintptr_t) curr_conn->next_conn; // update & release it curr_conn->next_conn = NULL; - // Increment the tbb connection close event count + // Increment the TBB connection close event count my_ec = ++close_tbb_connection_event_count; // Wait happens in tbb_connection_v2::~tbb_connection_v2() } @@ -1672,12 +1672,12 @@ void omp_connection_v2::reactivate( rml::job* j ) #endif /* RML_USE_WCRM */ -//! Wake up some available tbb threads +//! Wake up some available TBB threads void wakeup_some_tbb_threads() { /* First, atomically grab the connection, then increase the server ref count to keep it from being released prematurely. Second, check if the balance is available for TBB - and the tbb connection has slack to exploit. If the answer is true, go ahead and + and the TBB connection has slack to exploit. If the answer is true, go ahead and try to wake some up. */ if( generic_connection::get_addr(active_tbb_connections)==0 ) // the next connection will see the change; return. @@ -1687,7 +1687,7 @@ void wakeup_some_tbb_threads() int n_curr_readers = ++current_tbb_conn_readers; if( n_curr_readers>1 ) // I lost return; - // if n_curr_readers==1, i am the first one, so I will take responsibility for waking tbb threads up. + // if n_curr_readers==1, i am the first one, so I will take responsibility for waking TBB threads up. // update the current epoch current_tbb_conn_reader_epoch = close_tbb_connection_event_count; @@ -1702,7 +1702,7 @@ void wakeup_some_tbb_threads() generic_connection* next_conn_wake_up = generic_connection::get_addr( active_tbb_connections ); for( ; next_conn_wake_up; ) { - /* some threads are creating tbb server threads; they may not see my changes made to the_balance */ + /* some threads are creating TBB server threads; they may not see my changes made to the_balance */ /* When a thread is in adjust_job_count_estimate() to increase the slack RML tries to activate worker threads on behalf of the requesting thread by repeatedly drawing a coin from the bank optimistically and grabbing a @@ -2076,7 +2076,7 @@ void server_thread::loop() { if( s==ts_omp_busy ) { // Enslaved by OpenMP team. omp_dispatch.consume(); - /* here wake tbb threads up if feasible */ + /* here wake TBB threads up if feasible */ if( ++the_balance>0 ) wakeup_some_tbb_threads(); state = ts_idle; @@ -2109,7 +2109,7 @@ void server_thread::loop() { } } // else the new request will see my changes to state & the_balance. } - /* here wake tbb threads up if feasible */ + /* here wake TBB threads up if feasible */ if( the_balance>0 ) wakeup_some_tbb_threads(); } @@ -2229,7 +2229,7 @@ void tbb_server_thread::Dispatch( DispatchState* ) { make_job( *tbb_conn, *this ); for( ;; ) { - // Try to wake some tbb threads if the balance is positive. + // Try to wake some TBB threads if the balance is positive. // When a thread is added by ConcRT and enter here for the first time, // the thread may wake itself up (i.e., atomically change its state to ts_busy. if( the_balance>0 ) diff --git a/src/tbb/intrusive_list.h b/src/tbb/intrusive_list.h index 1bdc3cf7..add58e72 100644 --- a/src/tbb/intrusive_list.h +++ b/src/tbb/intrusive_list.h @@ -18,6 +18,7 @@ #define _TBB_intrusive_list_H #include "tbb/tbb_stddef.h" +#include "tbb/internal/_template_helpers.h" namespace tbb { namespace internal { @@ -49,63 +50,75 @@ class intrusive_list_base { static T& item ( intrusive_list_node* node ) { return List::item(node); } - template - class iterator_impl { - Iterator& self () { return *static_cast(this); } + static const T& item( const intrusive_list_node* node ) { return List::item(node); } - //! Node the iterator points to at the moment - intrusive_list_node *my_pos; + template + class iterator_impl { + __TBB_STATIC_ASSERT((tbb::internal::is_same_type::value || + tbb::internal::is_same_type::value), + "Incorrect DereferenceType in iterator_impl"); + typedef typename tbb::internal::conditional::value, + intrusive_list_node*, + const intrusive_list_node*>::type pointer_type; + public: + iterator_impl() : my_pos(NULL) {} - protected: - iterator_impl (intrusive_list_node* pos ) - : my_pos(pos) - {} + iterator_impl( pointer_type pos ) : my_pos(pos) {} - T& item () const { - return intrusive_list_base::item(my_pos); + iterator_impl& operator=( const iterator_impl& other ) { + if (this != &other) { + my_pos = other.my_pos; + } + return *this; } - public: - iterator_impl () : my_pos(NULL) {} + iterator_impl& operator=( const T& val ) { + my_pos = &node(val); + return *this; + } - Iterator& operator = ( const Iterator& it ) { - return my_pos = it.my_pos; + iterator_impl& operator++() { + my_pos = my_pos->my_next_node; + return *this; } - Iterator& operator = ( const T& val ) { - return my_pos = &node(val); + iterator_impl operator++( int ) { + iterator_impl it(*this); + ++*this; + return it; } - bool operator == ( const Iterator& it ) const { - return my_pos == it.my_pos; + iterator_impl& operator--() { + my_pos = my_pos->my_prev_node; + return *this; } - bool operator != ( const Iterator& it ) const { - return my_pos != it.my_pos; + iterator_impl operator--( int ) { + iterator_impl it(*this); + --*this; + return it; } - Iterator& operator++ () { - my_pos = my_pos->my_next_node; - return self(); + bool operator==( const iterator_impl& rhs ) const { + return my_pos == rhs.my_pos; } - Iterator& operator-- () { - my_pos = my_pos->my_prev_node; - return self(); + bool operator!=( const iterator_impl& rhs ) const { + return my_pos != rhs.my_pos; } - Iterator operator++ ( int ) { - Iterator result = self(); - ++(*this); - return result; + DereferenceType& operator*() const { + return intrusive_list_base::item(my_pos); } - Iterator operator-- ( int ) { - Iterator result = self(); - --(*this); - return result; + DereferenceType* operator->() const { + return &intrusive_list_base::item(my_pos); } - }; // intrusive_list_base::iterator_impl + + private: + // Node the iterator points to at the moment + pointer_type my_pos; + }; // class iterator_impl void assert_ok () const { __TBB_ASSERT( (my_head.my_prev_node == &my_head && !my_size) || @@ -119,31 +132,8 @@ class intrusive_list_base { } public: - class iterator : public iterator_impl { - template friend class intrusive_list_base; - public: - iterator (intrusive_list_node* pos ) - : iterator_impl(pos ) - {} - iterator () {} - - T* operator-> () const { return &this->item(); } - - T& operator* () const { return this->item(); } - }; // class iterator - - class const_iterator : public iterator_impl { - template friend class intrusive_list_base; - public: - const_iterator (const intrusive_list_node* pos ) - : iterator_impl(const_cast(pos) ) - {} - const_iterator () {} - - const T* operator-> () const { return &this->item(); } - - const T& operator* () const { return this->item(); } - }; // class iterator + typedef iterator_impl iterator; + typedef iterator_impl const_iterator; intrusive_list_base () : my_size(0) { my_head.my_prev_node = &my_head; @@ -219,6 +209,10 @@ class memptr_intrusive_list : public intrusive_list_base((char*)node - ((ptrdiff_t)&(reinterpret_cast(0x1000)->*NodePtr) - 0x1000)); } + + static const T& item( const intrusive_list_node* node ) { + return item(const_cast(node)); + } }; // intrusive_list //! Double linked list of items of type T that is derived from intrusive_list_node class. @@ -234,6 +228,7 @@ class intrusive_list : public intrusive_list_base, T> static intrusive_list_node& node ( T& val ) { return val; } static T& item ( intrusive_list_node* node ) { return *static_cast(node); } + static const T& item( const intrusive_list_node* node ) { return *static_cast(node); } }; // intrusive_list } // namespace internal diff --git a/src/tbb/tools_api/ittnotify.h b/src/tbb/tools_api/ittnotify.h index 27f3b88b..95ca8e60 100644 --- a/src/tbb/tools_api/ittnotify.h +++ b/src/tbb/tools_api/ittnotify.h @@ -22,7 +22,7 @@ @brief Public User API functions and types @mainpage -The ITT API is used to annotate a user's program with additional information +The Instrumentation and Tracing Technology API (ITT API) is used to annotate a user's program with additional information that can be used by correctness and performance tools. The user inserts calls in their program. Those calls generate information that is collected at runtime, and used by Intel(R) Threading Tools. diff --git a/src/test/harness_eh.h b/src/test/harness_eh.h index 8d039ef4..721c5d40 100644 --- a/src/test/harness_eh.h +++ b/src/test/harness_eh.h @@ -45,7 +45,7 @@ tbb::atomic g_ActualCurrentThreads; volatile bool g_ThrowException = true, // g_Flog is true for nested construct tests with catches (exceptions are not allowed to - // propagate to the tbb construct itself.) + // propagate to the TBB construct itself.) g_Flog = false, g_MasterExecuted = false, g_NonMasterExecuted = false; diff --git a/src/test/harness_graph.h b/src/test/harness_graph.h index ae5e8e53..06176711 100644 --- a/src/test/harness_graph.h +++ b/src/test/harness_graph.h @@ -1204,7 +1204,7 @@ void test_limited_lightweight_execution(unsigned N, unsigned concurrency) { tbb::flow::graph g; NodeType node(g, concurrency, limited_lightweight_checker_body()); // Execute first body as lightweight, then wait for all other threads to fill internal buffer. - // Then unblock the lightweightd thread and check if other body executions are inside tbb task. + // Then unblock the lightweightd thread and check if other body executions are inside TBB task. Harness::SpinBarrier barrier(N - concurrency); NativeParallelFor(N, native_loop_limited_body(node, barrier)); g.wait_for_all(); diff --git a/src/test/test_composite_node.cpp b/src/test/test_composite_node.cpp index e2d80f60..d2205db9 100644 --- a/src/test/test_composite_node.cpp +++ b/src/test/test_composite_node.cpp @@ -16,6 +16,7 @@ #include "harness.h" #if __TBB_FLOW_GRAPH_CPP11_FEATURES +#define TBB_DEPRECATED_INPUT_NODE_BODY __TBB_CPF_BUILD #include "tbb/flow_graph.h" #include "harness_graph.h" @@ -35,6 +36,7 @@ class src_body{ int step; public: src_body(int f, int s) : start(1), finish(f), step(s) {} +#if TBB_DEPRECATED_INPUT_NODE_BODY bool operator()(int &a) { a = start; if (start <= finish) { @@ -45,7 +47,21 @@ class src_body{ else { return false; }; - } + } +#else + int operator()(tbb::flow_control& fc) { + int a = start; + if (start <= finish) { + a = start; + start+=step; + return a; + } + else { + fc.stop(); + return int(); + }; + } +#endif }; struct m_fxn_body{ diff --git a/src/test/test_eh_flow_graph.cpp b/src/test/test_eh_flow_graph.cpp index 58195706..9cc92a03 100644 --- a/src/test/test_eh_flow_graph.cpp +++ b/src/test/test_eh_flow_graph.cpp @@ -40,6 +40,8 @@ #define TBB_RUN_BUFFERING_TEST 1 #endif +#define TBB_DEPRECATED_INPUT_NODE_BODY __TBB_CPF_BUILD + #if TBB_USE_EXCEPTIONS #if USE_TASK_SCHEDULER_OBSERVER #include "tbb/task_scheduler_observer.h" @@ -177,6 +179,7 @@ class test_source_body : WaitThrow { REMARK("- --------- - - - constructed %lx\n", (size_t)(my_current_val)); } +#if TBB_DEPRECATED_INPUT_NODE_BODY bool operator()(OutputType & out) { UPDATE_COUNTS(); out = OutputType(my_mult * ++(*my_current_val)); @@ -189,6 +192,19 @@ class test_source_body : WaitThrow { WaitAndThrow((int)out,"test_source_body"); return true; } +#else + OutputType operator()(tbb::flow_control& fc) { + UPDATE_COUNTS(); + OutputType ret = OutputType(my_mult * ++(*my_current_val)); + if(*my_current_val > g_NumItems) { + *my_current_val = g_NumItems; + fc.stop(); + return OutputType(); + } + WaitAndThrow((int)ret,"test_input_body"); + return ret; + } +#endif int count_value() { return (int)*my_current_val; } }; @@ -199,7 +215,7 @@ class test_source_body : WaitThrow *my_current_val; public: test_source_body(tbb::atomic &my_cnt) : my_current_val(&my_cnt) { } - +#if TBB_DEPRECATED_INPUT_NODE_BODY bool operator()(tbb::flow::continue_msg & out) { UPDATE_COUNTS(); int outint = ++(*my_current_val); @@ -211,6 +227,19 @@ class test_source_body : WaitThrow g_NumItems) { + *my_current_val = g_NumItems; + fc.stop(); + return tbb::flow::continue_msg(); + } + WaitAndThrow(outint,"test_input_body"); + return tbb::flow::continue_msg(); + } +#endif int count_value() { return (int)*my_current_val; } }; @@ -320,7 +349,7 @@ class tuple_test_source_body : WaitThrow { tbb::atomic *my_current_val; public: tuple_test_source_body(tbb::atomic &my_cnt) : my_current_val(&my_cnt) { } - +#if TBB_DEPRECATED_INPUT_NODE_BODY bool operator()(OutputTuple & out) { UPDATE_COUNTS(); int ival = ++(*my_current_val); @@ -332,6 +361,19 @@ class tuple_test_source_body : WaitThrow { WaitAndThrow(ival,"tuple_test_source_body"); return true; } +#else + OutputTuple operator()(tbb::flow_control& fc) { + UPDATE_COUNTS(); + int ival = ++(*my_current_val); + if(*my_current_val > g_NumItems) { + *my_current_val = g_NumItems; // jam the final value; we assert on it later. + fc.stop(); + return OutputTuple(); + } + WaitAndThrow(ival,"tuple_test_input_body"); + return OutputTuple(ItemType0(ival),ItemType1(ival)); + } +#endif int count_value() { return (int)*my_current_val; } }; diff --git a/src/test/test_flow_graph.cpp b/src/test/test_flow_graph.cpp index 99516aab..08c7390d 100644 --- a/src/test/test_flow_graph.cpp +++ b/src/test/test_flow_graph.cpp @@ -14,11 +14,14 @@ limitations under the License. */ +#define TBB_DEPRECATED_INPUT_NODE_BODY __TBB_CPF_BUILD + #include "harness_graph.h" #include "harness_barrier.h" #include "tbb/flow_graph.h" #include "tbb/task_scheduler_init.h" + const int T = 4; const int W = 4; @@ -246,6 +249,8 @@ struct source_body { tbb::task_arena* my_a; int counter; source_body(tbb::task_arena* a) : my_a(a), counter(0) {} + +#if TBB_DEPRECATED_INPUT_NODE_BODY bool operator()(const int& /*i*/) { check_arena(my_a); if (counter < 1) { @@ -254,6 +259,15 @@ struct source_body { } return false; } +#else + int operator()(tbb::flow_control &fc) { + check_arena(my_a); + if (counter++ >= 1) { + fc.stop(); + } + return int(); + } +#endif }; struct run_test_functor : tbb::internal::no_assign { diff --git a/src/test/test_flow_graph_priorities.cpp b/src/test/test_flow_graph_priorities.cpp index c5f5e962..9c0c8735 100644 --- a/src/test/test_flow_graph_priorities.cpp +++ b/src/test/test_flow_graph_priorities.cpp @@ -17,6 +17,7 @@ #include "harness_defs.h" #if __TBB_PREVIEW_FLOW_GRAPH_PRIORITIES +#define TBB_DEPRECATED_INPUT_NODE_BODY __TBB_CPF_BUILD #include "harness_graph.h" #include "harness_barrier.h" @@ -233,6 +234,7 @@ struct AsyncActivity { struct StartBody { bool has_run; +#if TBB_DEPRECATED_INPUT_NODE_BODY bool operator()(data_type& input) { if (has_run) return false; else { @@ -241,6 +243,16 @@ struct StartBody { return true; } } +#else + data_type operator()(tbb::flow_control& fc) { + if (has_run){ + fc.stop(); + return data_type(); + } + has_run = true; + return 1; + } +#endif StartBody() : has_run(false) {} }; diff --git a/src/test/test_flow_graph_whitebox.cpp b/src/test/test_flow_graph_whitebox.cpp index 5e991be8..e63916dc 100644 --- a/src/test/test_flow_graph_whitebox.cpp +++ b/src/test/test_flow_graph_whitebox.cpp @@ -25,6 +25,8 @@ #endif #endif +#define TBB_DEPRECATED_INPUT_NODE_BODY __TBB_CPF_BUILD + #include "harness.h" #include // merely prevents LNK2001 error to happen (on ICL+VC9 configurations) @@ -633,11 +635,21 @@ struct snode_body { int max_cnt; int my_cnt; snode_body( const int &in) : max_cnt(in) { my_cnt = 0; } +#if TBB_DEPRECATED_INPUT_NODE_BODY bool operator()(int &out) { if(max_cnt <= my_cnt++) return false; out = my_cnt; return true; } +#else + int operator()(tbb::flow_control &fc) { + if(max_cnt <= my_cnt++) { + fc.stop(); + return int(); + } + return my_cnt; + } +#endif }; void diff --git a/src/test/test_indexer_node.cpp b/src/test/test_indexer_node.cpp index c9c4317b..27839365 100644 --- a/src/test/test_indexer_node.cpp +++ b/src/test/test_indexer_node.cpp @@ -17,6 +17,7 @@ #if __TBB_CPF_BUILD #define TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1 #endif +#define TBB_DEPRECATED_INPUT_NODE_BODY __TBB_CPF_BUILD #include "harness.h" #include "harness_graph.h" @@ -414,12 +415,26 @@ class source_body { int addend; public: source_body(TT multiplier, int init_val, int addto) : my_mult(multiplier), my_count(init_val), addend(addto) { } +#if TBB_DEPRECATED_INPUT_NODE_BODY bool operator()( TT &v) { int lc = my_count; v = my_mult * (TT)my_count; my_count += addend; return lc < Count; } +#else + TT operator()( tbb::flow_control& fc) { + int lc = my_count; + TT ret = my_mult * (TT)my_count; + my_count += addend; + if ( lc < Count){ + return ret; + }else{ + fc.stop(); + return TT(); + } + } +#endif }; // allocator for indexer_node. diff --git a/src/test/test_input_node.cpp b/src/test/test_input_node.cpp index 25ea789d..0a7d4d59 100644 --- a/src/test/test_input_node.cpp +++ b/src/test/test_input_node.cpp @@ -17,6 +17,7 @@ // have to expose the reset_node method to be able to reset a function_body #include "harness.h" +#define TBB_DEPRECATED_INPUT_NODE_BODY __TBB_CPF_BUILD #include "harness_graph.h" #include "tbb/flow_graph.h" @@ -80,15 +81,27 @@ class source_body { source_body() : ninvocations(NULL) { my_count = 0; } source_body(int &_inv) : ninvocations(&_inv) { my_count = 0; } - bool operator()( T &v ) { - v = (T)my_count++; - if(ninvocations) ++(*ninvocations); - if ( (int)v < N ) - return true; - else - return false; - } - +#if TBB_DEPRECATED_INPUT_NODE_BODY + bool operator()( T &v ) { + v = (T)my_count++; + if(ninvocations) ++(*ninvocations); + if ( (int)v < N ) + return true; + else + return false; + } +#else + T operator()( tbb::flow_control& fc ) { + T v = (T)my_count++; + if(ninvocations) ++(*ninvocations); + if ( (int)v < N ){ + return v; + }else{ + fc.stop(); + return T(); + } + } +#endif }; template< typename T > @@ -256,15 +269,22 @@ void test_reset() { } #if __TBB_CPP17_DEDUCTION_GUIDES_PRESENT -bool source_body_f(int& i) { return i > 5; } - +#if TBB_DEPRECATED_INPUT_NODE_BODY + bool source_body_f(int& i) { return i > 5; } +#else + int source_body_f(tbb::flow_control&) { return 42; } +#endif void test_deduction_guides() { using namespace tbb::flow; graph g; +#if TBB_DEPRECATED_INPUT_NODE_BODY auto lambda = [](int& i) { return i > 5; }; auto non_const_lambda = [](int& i) mutable { return i > 5; }; - +#else + auto lambda = [](tbb::flow_control&) { return 42; }; + auto non_const_lambda = [](tbb::flow_control&) mutable { return 42; }; +#endif // Tests for source_node(graph&, Body) input_node s1(g, lambda); static_assert(std::is_same_v>); @@ -310,7 +330,9 @@ void test_follows_and_precedes_api() { }}; bool do_try_put = true; - input_node src(precedes(successors[0], successors[1], successors[2]), [&](bool& v) -> bool { + input_node src(precedes(successors[0], successors[1], successors[2]), + #if TBB_DEPRECATED_INPUT_NODE_BODY + [&](bool& v) -> bool { if(do_try_put) { v = do_try_put; do_try_put = false; @@ -319,7 +341,16 @@ void test_follows_and_precedes_api() { else { return false; } - }); + } + #else + [&](tbb::flow_control& fc) -> bool { + if(!do_try_put) + fc.stop(); + do_try_put = !do_try_put; + return true; + } + #endif + ); src.activate(); g.wait_for_all(); diff --git a/src/test/test_join_node.h b/src/test/test_join_node.h index 88f99893..3c53bd13 100644 --- a/src/test/test_join_node.h +++ b/src/test/test_join_node.h @@ -26,6 +26,8 @@ #endif #endif +#define TBB_DEPRECATED_INPUT_NODE_BODY __TBB_CPF_BUILD + #include "harness.h" #include "harness_graph.h" #include "harness_checktype.h" @@ -835,11 +837,20 @@ static int input_count; // source_nodes are serial // emit input_count continue_msg class recirc_source_node_body { public: +#if TBB_DEPRECATED_INPUT_NODE_BODY bool operator()(tbb::flow::continue_msg &v) { --input_count; v = tbb::flow::continue_msg(); return 0<=input_count; } +#else + tbb::flow::continue_msg operator()(tbb::flow_control &fc) { + if( --input_count < 0 ){ + fc.stop(); + } + return tbb::flow::continue_msg(); + } +#endif }; // T must be arithmetic, and shouldn't wrap around for reasonable sizes of Count (which is now 150, and maxPorts is 10, @@ -854,12 +865,26 @@ class source_body { int addend; public: source_body(int init_val, int addto): my_count(init_val), addend(addto) { } +#if TBB_DEPRECATED_INPUT_NODE_BODY bool operator()(TT &v) { int lc = my_count; v = make_thingie()(my_count); my_count += addend; return lc < Count; } +#else + TT operator()(tbb::flow_control& fc) { + int lc = my_count; + TT ret = make_thingie()(my_count); + my_count += addend; + if ( lc < Count){ + return ret; + }else{ + fc.stop(); + return TT(); + } + } +#endif }; template diff --git a/src/test/test_runtime_loader.cpp b/src/test/test_runtime_loader.cpp index 1e69a543..b0eba537 100644 --- a/src/test/test_runtime_loader.cpp +++ b/src/test/test_runtime_loader.cpp @@ -42,7 +42,7 @@ int TestMain () { #include #ifdef HARNESS_USE_RUNTIME_LOADER - #undef HARNESS_USE_RUNTIME_LOADER // We do not want harness to preload tbb. + #undef HARNESS_USE_RUNTIME_LOADER // We do not want harness to preload TBB. #endif #include "harness.h" diff --git a/src/test/test_source_node.cpp b/src/test/test_source_node.cpp index b2594e7d..cfe0359d 100644 --- a/src/test/test_source_node.cpp +++ b/src/test/test_source_node.cpp @@ -17,6 +17,7 @@ // have to expose the reset_node method to be able to reset a function_body #define TBB_USE_SOURCE_NODE_AS_ALIAS __TBB_CPF_BUILD +#define TBB_DEPRECATED_INPUT_NODE_BODY !__TBB_CPF_BUILD #include "harness.h" @@ -24,6 +25,8 @@ #define TBB_DEPRECATED_FLOW_NODE_EXTRACTION 1 #endif + + #include "harness_graph.h" #include "tbb/flow_graph.h" #include "tbb/task.h" @@ -78,7 +81,7 @@ class test_push_receiver : public tbb::flow::receiver, NoAssign { template< typename T > class source_body { - tbb::atomic my_count; + unsigned my_count; int *ninvocations; public: @@ -86,14 +89,27 @@ class source_body { source_body() : ninvocations(NULL) { my_count = 0; } source_body(int &_inv) : ninvocations(&_inv) { my_count = 0; } +#if TBB_DEPRECATED_INPUT_NODE_BODY bool operator()( T &v ) { - v = (T)my_count.fetch_and_increment(); + v = (T)my_count++; if(ninvocations) ++(*ninvocations); if ( (int)v < N ) return true; else return false; } +#else + T operator()( tbb::flow_control& fc ) { + T v = (T)my_count++; + if(ninvocations) ++(*ninvocations); + if ( (int)v < N ){ + return v; + }else{ + fc.stop(); + return T(); + } + } +#endif }; @@ -434,14 +450,23 @@ void test_extract() { #endif /* TBB_DEPRECATED_FLOW_NODE_EXTRACTION */ #if __TBB_CPP17_DEDUCTION_GUIDES_PRESENT -bool source_body_f(int& i) { return i > 5; } +#if TBB_DEPRECATED_INPUT_NODE_BODY + bool source_body_f(int& i) { return i > 5; } +#else + int source_body_f(tbb::flow_control&) { return 42; } +#endif void test_deduction_guides() { using namespace tbb::flow; graph g; +#if TBB_DEPRECATED_INPUT_NODE_BODY auto lambda = [](int& i) { return i > 5; }; auto non_const_lambda = [](int& i) mutable { return i > 5; }; +#else + auto lambda = [](tbb::flow_control&) { return 42; }; + auto non_const_lambda = [](tbb::flow_control&) mutable { return 42; }; +#endif // Tests for source_node(graph&, Body) source_node s1(g, lambda); @@ -489,7 +514,9 @@ void test_follows_and_precedes_api() { bool do_try_put = true; - source_node src(precedes(successors[0], successors[1], successors[2]), [&](bool& v) -> bool { + source_node src(precedes(successors[0], successors[1], successors[2]), + #if TBB_DEPRECATED_INPUT_NODE_BODY + [&](bool& v) -> bool { if(do_try_put) { v = do_try_put; do_try_put = false; @@ -498,7 +525,16 @@ void test_follows_and_precedes_api() { else { return false; } - }); + } + #else + [&](tbb::flow_control& fc) -> bool { + if(!do_try_put) + fc.stop(); + do_try_put = !do_try_put; + return true; + } + #endif + ); src.activate(); g.wait_for_all(); diff --git a/src/test/test_split_node.cpp b/src/test/test_split_node.cpp index 59e74625..5879b977 100644 --- a/src/test/test_split_node.cpp +++ b/src/test/test_split_node.cpp @@ -15,6 +15,7 @@ */ #define TBB_DEPRECATED_FLOW_NODE_ALLOCATOR __TBB_CPF_BUILD +#define TBB_DEPRECATED_INPUT_NODE_BODY __TBB_CPF_BUILD #include "harness.h" #include "harness_graph.h" @@ -100,12 +101,25 @@ class source_body { int addend; public: source_body(int init_val, int addto) : my_count(init_val), addend(addto) { } +#if TBB_DEPRECATED_INPUT_NODE_BODY bool operator()( TT &v) { if(my_count >= Count) return false; tuple_helper::set_element(v, my_count); my_count += addend; return true; } +#else + TT operator()( tbb::flow_control &fc) { + if(my_count >= Count){ + fc.stop(); + return TT(); + } + TT v; + tuple_helper::set_element(v, my_count); + my_count += addend; + return v; + } +#endif }; // allocator for split_node. diff --git a/src/test/test_task_scheduler_init.cpp b/src/test/test_task_scheduler_init.cpp index 396150d1..6479ea1f 100644 --- a/src/test/test_task_scheduler_init.cpp +++ b/src/test/test_task_scheduler_init.cpp @@ -324,10 +324,10 @@ int TestMain () { #if _MSC_VER && !__TBB_NO_IMPLICIT_LINKAGE && !defined(__TBB_LIB_NAME) #ifdef _DEBUG ASSERT(!GetModuleHandle(_T("tbb.dll")) && GetModuleHandle(_T("tbb_debug.dll")), - "test linked with wrong (non-debug) tbb library"); + "test linked with wrong (non-debug) TBB library"); #else ASSERT(!GetModuleHandle(_T("tbb_debug.dll")) && GetModuleHandle(_T("tbb.dll")), - "test linked with wrong (debug) tbb library"); + "test linked with wrong (debug) TBB library"); #endif #endif /* _MSC_VER && !__TBB_NO_IMPLICIT_LINKAGE && !__TBB_LIB_NAME */ std::srand(2); diff --git a/src/test/test_tbb_version.cpp b/src/test/test_tbb_version.cpp index 8248995d..9032fc5e 100644 --- a/src/test/test_tbb_version.cpp +++ b/src/test/test_tbb_version.cpp @@ -224,8 +224,8 @@ int main(int argc, char *argv[] ) { // Fill dictionary with version strings for platforms void initialize_strings_vector(std::vector * vector) { - vector->push_back(string_pair("TBB: VERSION\t\t2020.2", required)); // check TBB_VERSION - vector->push_back(string_pair("TBB: INTERFACE VERSION\t11102", required)); // check TBB_INTERFACE_VERSION + vector->push_back(string_pair("TBB: VERSION\t\t2020.3", required)); // check TBB_VERSION + vector->push_back(string_pair("TBB: INTERFACE VERSION\t11103", required)); // check TBB_INTERFACE_VERSION vector->push_back(string_pair("TBB: BUILD_DATE", required)); vector->push_back(string_pair("TBB: BUILD_HOST", required)); vector->push_back(string_pair("TBB: BUILD_OS", required)); From c736d5f31eddc0028a2f3a2833da91850b3fb9a7 Mon Sep 17 00:00:00 2001 From: John-Paul Smith Date: Wed, 11 May 2022 14:58:34 +0100 Subject: [PATCH 2/7] Disable std_thread_test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit std_thread_test doesn’t compile with the macOS 12 SDK due to conflicts with the native std::thread implementation. As this functionality is deprecated anyway, just disable the test. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 616934be..d81d89b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -615,7 +615,7 @@ if (TBB_BUILD_TESTS) tbb_add_test (source_node) tbb_add_test (split_node) tbb_add_test (static_assert) - tbb_add_test (std_thread) + # tbb_add_test (std_thread) # Fails to compile on macOS - deprecated anyway tbb_add_test (tagged_msg) # tbb_add_test (task_arena) # LINK : fatal error LNK1104: cannot open file '__TBB_LIB_NAME.lib' [C:\projects\tbb\test_task_arena.vcxproj] # tbb_add_test (task_assertions) From e206d20e53635ed58718dfed42ca7ea79be238a6 Mon Sep 17 00:00:00 2001 From: mikw Date: Tue, 7 Jun 2022 20:38:54 +0100 Subject: [PATCH 3/7] On Windows, removed the concurrent_vector "copy constructor for vector with different allocator type" The function is deprecated, so removal should not pose a problem. This fixes a compiler error in Visual Studio 2017 --- include/tbb/concurrent_vector.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/tbb/concurrent_vector.h b/include/tbb/concurrent_vector.h index a4988aaa..647ea941 100644 --- a/include/tbb/concurrent_vector.h +++ b/include/tbb/concurrent_vector.h @@ -675,6 +675,7 @@ class concurrent_vector: protected internal::allocator_base, #endif +#if !defined(_MSC_VER) // This deprecated function declaration causes a compiler error in Visual Studio 2017 //! Copying constructor for vector with different allocator type template __TBB_DEPRECATED concurrent_vector( const concurrent_vector& vector, const allocator_type& a = allocator_type() ) @@ -689,7 +690,7 @@ class concurrent_vector: protected internal::allocator_base, __TBB_RETHROW(); } } - +#endif //! Construction with initial size specified by argument n explicit concurrent_vector(size_type n) { From fd76ffbc485dc5c187b4a3a2cdaeb1e79fd505e0 Mon Sep 17 00:00:00 2001 From: Matthew Mott Date: Wed, 8 Jun 2022 11:53:46 +0100 Subject: [PATCH 4/7] Fix failure to use correct OSX architecture generating .def files The explicit invocation of ${CMAKE_CXX_COMPILER} to generate lists of exported symbols was not taking into account the target architecture; instead it would inherit whatever architecture was running the actual build process. This could cause missing symbol errors when building the macOS arm64 target from an x86_64 shell session. --- CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d81d89b5..758d6c31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -248,14 +248,20 @@ if (MSVC) COMMENT "Preprocessing tbbmalloc.def" ) else() + + if (APPLE) + list(GET CMAKE_OSX_ARCHITECTURES 0 TARGET_ARCH) + set(ARCH_COMPILER_OPTION "-arch ${TARGET_ARCH}") + endif(APPLE) + add_custom_command(OUTPUT tbb.def - COMMAND ${CMAKE_CXX_COMPILER} -xc++ -std=c++11 -E ${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/${ARCH_PREFIX}-tbb-export.def -I ${CMAKE_CURRENT_SOURCE_DIR}/include -o tbb.def + COMMAND ${CMAKE_CXX_COMPILER} ${ARCH_COMPILER_OPTION} -xc++ -std=c++11 -E ${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/${ARCH_PREFIX}-tbb-export.def -I ${CMAKE_CURRENT_SOURCE_DIR}/include -o tbb.def MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/${ARCH_PREFIX}-tbb-export.def COMMENT "Preprocessing tbb.def" ) add_custom_command(OUTPUT tbbmalloc.def - COMMAND ${CMAKE_CXX_COMPILER} -xc++ -std=c++11 -E ${CMAKE_CURRENT_SOURCE_DIR}/src/tbbmalloc/${ARCH_PREFIX}-tbbmalloc-export.def -I ${CMAKE_CURRENT_SOURCE_DIR}/include -o tbbmalloc.def + COMMAND ${CMAKE_CXX_COMPILER} ${ARCH_COMPILER_OPTION} -xc++ -std=c++11 -E ${CMAKE_CURRENT_SOURCE_DIR}/src/tbbmalloc/${ARCH_PREFIX}-tbbmalloc-export.def -I ${CMAKE_CURRENT_SOURCE_DIR}/include -o tbbmalloc.def MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/src/tbbmalloc/${ARCH_PREFIX}-tbbmalloc-export.def COMMENT "Preprocessing tbbmalloc.def" ) From 00321bc650eb4f3eb001a8a0d7fd57ed5cb5303c Mon Sep 17 00:00:00 2001 From: mikw Date: Thu, 9 Jun 2022 13:32:13 +0100 Subject: [PATCH 5/7] Implicit Linking on Windows must be explicity enabled with __TBB_IMPLICIT_LINKAGE --- CMakeLists.txt | 8 ++++---- build/Makefile.rml | 2 +- build/Makefile.test | 2 +- include/tbb/concurrent_vector.h | 7 ++++++- include/tbb/internal/_tbb_windef.h | 6 +++--- include/tbb/runtime_loader.h | 2 +- include/tbb/scalable_allocator.h | 6 +++--- include/tbb/tbb_config.h | 2 +- python/rml/Makefile | 2 +- src/tbb/concurrent_vector.cpp | 2 +- src/tbb/itt_notify.cpp | 2 +- src/tbbmalloc/tbb_function_replacement.cpp | 2 +- src/test/harness_concurrency_tracker.h | 8 ++++---- src/test/harness_inject_scheduler.h | 2 +- src/test/harness_tbb_independence.h | 2 +- src/test/harness_test_cases_framework.h | 2 +- src/test/test_concurrent_map.cpp | 2 +- src/test/test_concurrent_set.cpp | 2 +- src/test/test_concurrent_unordered_map.cpp | 2 +- src/test/test_concurrent_unordered_set.cpp | 2 +- src/test/test_concurrent_vector.cpp | 6 +++++- src/test/test_malloc_compliance.cpp | 2 +- src/test/test_malloc_new_handler.cpp | 2 +- src/test/test_malloc_used_by_lib.cpp | 2 +- src/test/test_model_plugin.cpp | 2 +- src/test/test_parallel_for.cpp | 2 ++ src/test/test_task_arena.cpp | 2 +- src/test/test_task_priority.cpp | 4 ++-- src/test/test_task_scheduler_init.cpp | 4 ++-- src/test/test_task_scheduler_observer.cpp | 4 ++-- 30 files changed, 53 insertions(+), 42 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 758d6c31..82bb3ee1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -287,7 +287,7 @@ if (TBB_BUILD_STATIC) if (MSVC) target_compile_definitions(tbb_static - PUBLIC -D__TBB_NO_IMPLICIT_LINKAGE=1 + PUBLIC -D__TBB_IMPLICIT_LINKAGE=0 PRIVATE -D_CRT_SECURE_NO_WARNINGS) endif() @@ -310,7 +310,7 @@ if (TBB_BUILD_SHARED) if (MSVC) target_compile_definitions(tbb - PUBLIC -D__TBB_NO_IMPLICIT_LINKAGE=1 + PUBLIC -D__TBB_IMPLICIT_LINKAGE=0 PRIVATE -D_CRT_SECURE_NO_WARNINGS) endif() @@ -361,7 +361,7 @@ if(TBB_BUILD_TBBMALLOC) set_property(TARGET tbbmalloc_static APPEND PROPERTY COMPILE_DEFINITIONS "__TBB_SOURCE_DIRECTLY_INCLUDED=1") set_property(TARGET tbbmalloc_static APPEND_STRING PROPERTY COMPILE_FLAGS ${DISABLE_RTTI}) if (MSVC) - target_compile_definitions(tbbmalloc_static PUBLIC __TBB_NO_IMPLICIT_LINKAGE=1 __TBBMALLOC_NO_IMPLICIT_LINKAGE=1) + target_compile_definitions(tbbmalloc_static PUBLIC __TBB_IMPLICIT_LINKAGE=0 __TBBMALLOC_NO_IMPLICIT_LINKAGE=1) endif() if (TBB_INSTALL_TARGETS) install(TARGETS tbbmalloc_static ARCHIVE DESTINATION ${TBB_INSTALL_ARCHIVE_DIR}) @@ -385,7 +385,7 @@ if(TBB_BUILD_TBBMALLOC) set_property(TARGET tbbmalloc APPEND PROPERTY LINK_FLAGS "-Wl,-version-script,\"${CMAKE_CURRENT_BINARY_DIR}/tbbmalloc.def\"") endif() if (MSVC) - target_compile_definitions(tbbmalloc PUBLIC __TBB_NO_IMPLICIT_LINKAGE=1 __TBBMALLOC_NO_IMPLICIT_LINKAGE=1) + target_compile_definitions(tbbmalloc PUBLIC __TBB_IMPLICIT_LINKAGE=0 __TBBMALLOC_NO_IMPLICIT_LINKAGE=1) endif() if (TBB_INSTALL_TARGETS) install(TARGETS tbbmalloc EXPORT TBB diff --git a/build/Makefile.rml b/build/Makefile.rml index fc0cb774..a08e13c2 100644 --- a/build/Makefile.rml +++ b/build/Makefile.rml @@ -81,7 +81,7 @@ endif # Suppress superfluous warnings for RML compilation R_CPLUS_FLAGS = $(subst DO_ITT_NOTIFY,DO_ITT_NOTIFY=0,$(CPLUS_FLAGS)) $(WARNING_SUPPRESS) \ - $(DEFINE_KEY)TBB_USE_THREADING_TOOLS=0 $(DEFINE_KEY)__TBB_RML_STATIC=1 $(DEFINE_KEY)__TBB_NO_IMPLICIT_LINKAGE=1 + $(DEFINE_KEY)TBB_USE_THREADING_TOOLS=0 $(DEFINE_KEY)__TBB_RML_STATIC=1 $(DEFINE_KEY)__TBB_IMPLICIT_LINKAGE=0 %.$(OBJ): %.cpp $(CPLUS) $(COMPILE_ONLY) $(R_CPLUS_FLAGS) $(PIC_KEY) $(DSE_KEY) $(INCLUDES) $< diff --git a/build/Makefile.test b/build/Makefile.test index eb2c7053..3b3ba1c9 100644 --- a/build/Makefile.test +++ b/build/Makefile.test @@ -31,7 +31,7 @@ DEBUG_SUFFIX=$(findstring _debug,$(call cross_cfg,_$(cfg))) #------------------------------------------------------------ VPATH = $(tbb_root)/src/tbb/$(ASSEMBLY_SOURCE) $(tbb_root)/src/tbb $(tbb_root)/src/rml/client $(tbb_root)/src/old $(tbb_root)/src/test $(tbb_root)/src/perf -CPLUS_FLAGS += $(if $(crosstest),$(DEFINE_KEY)__TBB_NO_IMPLICIT_LINKAGE=1) \ +CPLUS_FLAGS += $(if $(crosstest),$(DEFINE_KEY)__TBB_IMPLICIT_LINKAGE=0) \ $(if $(no_exceptions),$(DEFINE_KEY)__TBB_TEST_NO_EXCEPTIONS=1) \ $(if $(LINK_TBB.LIB),$(DEFINE_KEY)TEST_USES_TBB=1) diff --git a/include/tbb/concurrent_vector.h b/include/tbb/concurrent_vector.h index 647ea941..b9fe17c0 100644 --- a/include/tbb/concurrent_vector.h +++ b/include/tbb/concurrent_vector.h @@ -675,7 +675,12 @@ class concurrent_vector: protected internal::allocator_base, #endif -#if !defined(_MSC_VER) // This deprecated function declaration causes a compiler error in Visual Studio 2017 +#if !defined(_MSC_VER) +#define CONCURRENT_VECTOR_COPY_CONSTRUCT_FROM_OTHER_ALLOCATOR +#endif + +// This deprecated function declaration causes a compiler error in Visual Studio 2017 +#if defined(CONCURRENT_VECTOR_COPY_CONSTRUCT_FROM_OTHER_ALLOCATOR) //! Copying constructor for vector with different allocator type template __TBB_DEPRECATED concurrent_vector( const concurrent_vector& vector, const allocator_type& a = allocator_type() ) diff --git a/include/tbb/internal/_tbb_windef.h b/include/tbb/internal/_tbb_windef.h index b2eb9d5d..d8d7fbec 100644 --- a/include/tbb/internal/_tbb_windef.h +++ b/include/tbb/internal/_tbb_windef.h @@ -50,12 +50,12 @@ namespace std { # endif #endif -#if (__TBB_BUILD || __TBBMALLOC_BUILD || __TBBBIND_BUILD) && !defined(__TBB_NO_IMPLICIT_LINKAGE) -#define __TBB_NO_IMPLICIT_LINKAGE 1 +#if (__TBB_BUILD || __TBBMALLOC_BUILD || __TBBBIND_BUILD) && !defined(__TBB_IMPLICIT_LINKAGE) +#define __TBB_IMPLICIT_LINKAGE 0 #endif #if _MSC_VER - #if !__TBB_NO_IMPLICIT_LINKAGE + #if __TBB_IMPLICIT_LINKAGE #ifdef __TBB_LIB_NAME #pragma comment(lib, __TBB_STRING(__TBB_LIB_NAME)) #else diff --git a/include/tbb/runtime_loader.h b/include/tbb/runtime_loader.h index 9aaeea5b..d84b513e 100644 --- a/include/tbb/runtime_loader.h +++ b/include/tbb/runtime_loader.h @@ -39,7 +39,7 @@ #include #if _MSC_VER - #if ! __TBB_NO_IMPLICIT_LINKAGE + #if __TBB_IMPLICIT_LINKAGE #ifdef _DEBUG #pragma comment( linker, "/nodefaultlib:tbb_debug.lib" ) #pragma comment( linker, "/defaultlib:tbbproxy_debug.lib" ) diff --git a/include/tbb/scalable_allocator.h b/include/tbb/scalable_allocator.h index f1fc98ed..38d30c0f 100644 --- a/include/tbb/scalable_allocator.h +++ b/include/tbb/scalable_allocator.h @@ -199,10 +199,10 @@ size_t pool_msize(MemoryPool *memPool, void *object); #include /* To use new with the placement argument */ /* Ensure that including this header does not cause implicit linkage with TBB */ -#ifndef __TBB_NO_IMPLICIT_LINKAGE - #define __TBB_NO_IMPLICIT_LINKAGE 1 +#ifndef __TBB_IMPLICIT_LINKAGE + #define __TBB_IMPLICIT_LINKAGE 0 #include "tbb_stddef.h" - #undef __TBB_NO_IMPLICIT_LINKAGE + #undef __TBB_IMPLICIT_LINKAGE #else #include "tbb_stddef.h" #endif diff --git a/include/tbb/tbb_config.h b/include/tbb/tbb_config.h index 7a8d06a0..adf3b895 100644 --- a/include/tbb/tbb_config.h +++ b/include/tbb/tbb_config.h @@ -529,7 +529,7 @@ There are four cases that are supported: it's necessary to test internal functions not exported from TBB DLLs **/ #if (_WIN32||_WIN64) && (__TBB_SOURCE_DIRECTLY_INCLUDED || TBB_USE_PREVIEW_BINARY) - #define __TBB_NO_IMPLICIT_LINKAGE 1 + #define __TBB_IMPLICIT_LINKAGE 0 #define __TBBMALLOC_NO_IMPLICIT_LINKAGE 1 #endif diff --git a/python/rml/Makefile b/python/rml/Makefile index dc3b0bd1..d107442e 100644 --- a/python/rml/Makefile +++ b/python/rml/Makefile @@ -74,7 +74,7 @@ T_INCLUDES = $(INCLUDES) $(INCLUDE_KEY)$(tbb_root)/src/test $(INCLUDE_KEY)$(RML_ # Suppress superfluous warnings for RML compilation R_CPLUS_FLAGS = $(subst DO_ITT_NOTIFY,DO_ITT_NOTIFY=0,$(CPLUS_FLAGS)) $(WARNING_SUPPRESS) \ - $(DEFINE_KEY)TBB_USE_THREADING_TOOLS=0 $(DEFINE_KEY)__TBB_RML_STATIC=1 $(DEFINE_KEY)__TBB_NO_IMPLICIT_LINKAGE=1 + $(DEFINE_KEY)TBB_USE_THREADING_TOOLS=0 $(DEFINE_KEY)__TBB_RML_STATIC=1 $(DEFINE_KEY)__TBB_IMPLICIT_LINKAGE=0 %.$(OBJ): %.cpp $(CPLUS) $(COMPILE_ONLY) $(R_CPLUS_FLAGS) $(PIC_KEY) $(DSE_KEY) $(INCLUDES) $< diff --git a/src/tbb/concurrent_vector.cpp b/src/tbb/concurrent_vector.cpp index 660aff15..3c0b3f0b 100644 --- a/src/tbb/concurrent_vector.cpp +++ b/src/tbb/concurrent_vector.cpp @@ -14,7 +14,7 @@ limitations under the License. */ -#if (_MSC_VER) +#if defined(_MSC_VER) && !defined(_SCL_SECURE_NO_WARNINGS) //MSVC 10 "deprecated" application of some std:: algorithms to raw pointers as not safe. //The reason is that destination is not checked against bounds/having enough place. #define _SCL_SECURE_NO_WARNINGS diff --git a/src/tbb/itt_notify.cpp b/src/tbb/itt_notify.cpp index ac505344..19fce54b 100644 --- a/src/tbb/itt_notify.cpp +++ b/src/tbb/itt_notify.cpp @@ -63,7 +63,7 @@ int __TBB_load_ittnotify() { #endif /* DO_ITT_NOTIFY */ -#define __TBB_NO_IMPLICIT_LINKAGE 1 +#define __TBB_IMPLICIT_LINKAGE 0 #include "itt_notify.h" namespace tbb { diff --git a/src/tbbmalloc/tbb_function_replacement.cpp b/src/tbbmalloc/tbb_function_replacement.cpp index 602ec681..1fe2676d 100644 --- a/src/tbbmalloc/tbb_function_replacement.cpp +++ b/src/tbbmalloc/tbb_function_replacement.cpp @@ -21,7 +21,7 @@ #ifndef _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_DEPRECATE 1 #endif -#define __TBB_NO_IMPLICIT_LINKAGE 1 +#define __TBB_IMPLICIT_LINKAGE 0 // no standard-conforming implementation of snprintf prior to VS 2015 #if !defined(_MSC_VER) || _MSC_VER>=1900 diff --git a/src/test/harness_concurrency_tracker.h b/src/test/harness_concurrency_tracker.h index 436ac55c..f7b4f065 100644 --- a/src/test/harness_concurrency_tracker.h +++ b/src/test/harness_concurrency_tracker.h @@ -22,8 +22,8 @@ #include "tbb/atomic.h" #include "../tbb/tls.h" // Note: This file is used by RML tests which do not link TBB. -// Functionality that requires TBB binaries must be guarded by !__TBB_NO_IMPLICIT_LINKAGE -#if !defined(__TBB_NO_IMPLICIT_LINKAGE) +// Functionality that requires TBB binaries must be guarded by __TBB_IMPLICIT_LINKAGE +#if __TBB_IMPLICIT_LINKAGE #include "tbb/mutex.h" #include "tbb/task.h" #include "tbb/combinable.h" @@ -79,7 +79,7 @@ class ConcurrencyTracker { } }; // ConcurrencyTracker -#if !defined(__TBB_NO_IMPLICIT_LINKAGE) +#if __TBB_IMPLICIT_LINKAGE struct ExactConcurrencyLevel : NoCopy { typedef tbb::combinable Combinable; private: @@ -163,7 +163,7 @@ struct ExactConcurrencyLevel : NoCopy { tbb::mutex ExactConcurrencyLevel::global_mutex; -#endif /* !defined(__TBB_NO_IMPLICIT_LINKAGE) */ +#endif /* __TBB_IMPLICIT_LINKAGE */ } // namespace Harness diff --git a/src/test/harness_inject_scheduler.h b/src/test/harness_inject_scheduler.h index 2c792bcf..c544db2b 100644 --- a/src/test/harness_inject_scheduler.h +++ b/src/test/harness_inject_scheduler.h @@ -28,7 +28,7 @@ #endif // Suppress usage of #pragma comment -#define __TBB_NO_IMPLICIT_LINKAGE 1 +#define __TBB_IMPLICIT_LINKAGE 0 // Enable preview features if any #define __TBB_BUILD 1 diff --git a/src/test/harness_tbb_independence.h b/src/test/harness_tbb_independence.h index acd16393..6568d243 100644 --- a/src/test/harness_tbb_independence.h +++ b/src/test/harness_tbb_independence.h @@ -27,7 +27,7 @@ #if __linux__ && __ia64__ -#define __TBB_NO_IMPLICIT_LINKAGE 1 +#define __TBB_IMPLICIT_LINKAGE 0 #include "tbb/tbb_machine.h" #include diff --git a/src/test/harness_test_cases_framework.h b/src/test/harness_test_cases_framework.h index 06a63915..796867da 100644 --- a/src/test/harness_test_cases_framework.h +++ b/src/test/harness_test_cases_framework.h @@ -17,7 +17,7 @@ #ifndef tbb_harness_test_cases_framework_H #define tbb_harness_test_cases_framework_H -#if defined(_MSC_VER) +#if defined(_MSC_VER) && !defined(_SCL_SECURE_NO_WARNINGS) #define _SCL_SECURE_NO_WARNINGS #endif diff --git a/src/test/test_concurrent_map.cpp b/src/test/test_concurrent_map.cpp index 3ed8e88b..9d6f7bb3 100644 --- a/src/test/test_concurrent_map.cpp +++ b/src/test/test_concurrent_map.cpp @@ -15,7 +15,7 @@ */ #define __TBB_EXTRA_DEBUG 1 -#if _MSC_VER +#if defined(_MSC_VER) && !defined(_SCL_SECURE_NO_WARNINGS) #define _SCL_SECURE_NO_WARNINGS #endif diff --git a/src/test/test_concurrent_set.cpp b/src/test/test_concurrent_set.cpp index 428409e8..911dbbde 100644 --- a/src/test/test_concurrent_set.cpp +++ b/src/test/test_concurrent_set.cpp @@ -15,7 +15,7 @@ */ #define __TBB_EXTRA_DEBUG 1 -#if _MSC_VER +#if defined(_MSC_VER) && !defined(_SCL_SECURE_NO_WARNINGS) #define _SCL_SECURE_NO_WARNINGS #endif diff --git a/src/test/test_concurrent_unordered_map.cpp b/src/test/test_concurrent_unordered_map.cpp index 2fa4efe9..01d90be3 100644 --- a/src/test/test_concurrent_unordered_map.cpp +++ b/src/test/test_concurrent_unordered_map.cpp @@ -15,7 +15,7 @@ */ #define __TBB_EXTRA_DEBUG 1 -#if _MSC_VER +#if defined(_MSC_VER) && !defined(_SCL_SECURE_NO_WARNINGS) #define _SCL_SECURE_NO_WARNINGS #endif diff --git a/src/test/test_concurrent_unordered_set.cpp b/src/test/test_concurrent_unordered_set.cpp index d904defd..192474bf 100644 --- a/src/test/test_concurrent_unordered_set.cpp +++ b/src/test/test_concurrent_unordered_set.cpp @@ -14,7 +14,7 @@ limitations under the License. */ -#if _MSC_VER +#if defined(_MSC_VER) && !defined(_SCL_SECURE_NO_WARNINGS) #define _SCL_SECURE_NO_WARNINGS #endif diff --git a/src/test/test_concurrent_vector.cpp b/src/test/test_concurrent_vector.cpp index 3671f855..cb72adbc 100644 --- a/src/test/test_concurrent_vector.cpp +++ b/src/test/test_concurrent_vector.cpp @@ -14,7 +14,7 @@ limitations under the License. */ -#if _MSC_VER +#if defined(_MSC_VER) && !defined(_SCL_SECURE_NO_WARNINGS) #define _SCL_SECURE_NO_WARNINGS #endif @@ -401,6 +401,7 @@ void TestSequentialFor() { } // cross-allocator tests +#if defined(CONCURRENT_VECTOR_COPY_CONSTRUCT_FROM_OTHER_ALLOCATOR) #if !defined(_WIN64) || defined(_CPPLIB_VER) typedef local_counting_allocator, size_t> allocator1_t; typedef tbb::cache_aligned_allocator allocator2_t; @@ -412,6 +413,7 @@ void TestSequentialFor() { ASSERT( !(v1 < v) && !(v2 > v), NULL); ASSERT( (v1 <= v) && (v2 >= v), NULL); #endif +#endif } namespace test_grow_to_at_least_helpers { @@ -1646,11 +1648,13 @@ void TypeTester( const std::vector &vec ) { tbb::concurrent_vector< Type, debug_allocator > c4; std::copy( vec.begin(), vec.end(), std::back_inserter(c4) ); Examine( c4, vec ); +#if defined(CONCURRENT_VECTOR_COPY_CONSTRUCT_FROM_OTHER_ALLOCATOR) // Copying constructor for vector with different allocator type. tbb::concurrent_vector c5(c4); Examine( c5, vec ); tbb::concurrent_vector< Type, debug_allocator > c6(c3); Examine( c6, vec ); +#endif // Construction with initial size specified by argument n. do_default_construction_test()(test_default_construction(vec)); // Construction with initial size specified by argument n, initialization by copying of t, and given allocator instance. diff --git a/src/test/test_malloc_compliance.cpp b/src/test/test_malloc_compliance.cpp index c34e8dca..41f21610 100644 --- a/src/test/test_malloc_compliance.cpp +++ b/src/test/test_malloc_compliance.cpp @@ -105,7 +105,7 @@ void limitMem( size_t limit ) #include #include #include // for CHAR_BIT -#define __TBB_NO_IMPLICIT_LINKAGE 1 +#define __TBB_IMPLICIT_LINKAGE 0 #include "tbb/scalable_allocator.h" #define HARNESS_CUSTOM_MAIN 1 diff --git a/src/test/test_malloc_new_handler.cpp b/src/test/test_malloc_new_handler.cpp index 1c6a1572..8af0b262 100644 --- a/src/test/test_malloc_new_handler.cpp +++ b/src/test/test_malloc_new_handler.cpp @@ -16,7 +16,7 @@ #include "harness_allocator_overload.h" #define HARNESS_NO_PARSE_COMMAND_LINE 1 -#define __TBB_NO_IMPLICIT_LINKAGE 1 +#define __TBB_IMPLICIT_LINKAGE 0 #include "harness.h" diff --git a/src/test/test_malloc_used_by_lib.cpp b/src/test/test_malloc_used_by_lib.cpp index 8fba3628..c6b258d8 100644 --- a/src/test/test_malloc_used_by_lib.cpp +++ b/src/test/test_malloc_used_by_lib.cpp @@ -61,7 +61,7 @@ static RegisterProcessShutdownNotification reg; #else // _USRDLL -#define __TBB_NO_IMPLICIT_LINKAGE 1 +#define __TBB_IMPLICIT_LINKAGE 0 #include "harness_dynamic_libs.h" #if __TBB_WIN8UI_SUPPORT // FIXME: fix the test to support Windows* 8 Store Apps mode. diff --git a/src/test/test_model_plugin.cpp b/src/test/test_model_plugin.cpp index a93b7ea2..298cac5f 100644 --- a/src/test/test_model_plugin.cpp +++ b/src/test/test_model_plugin.cpp @@ -177,7 +177,7 @@ int TestMain () { REMARK("Iteration %d, loading plugin library...\n", i); hLib = Harness::OpenLibrary(TEST_LIBRARY_NAME("test_model_plugin_dll")); if ( !hLib ) { -#if !__TBB_NO_IMPLICIT_LINKAGE +#if __TBB_IMPLICIT_LINKAGE #if _WIN32 || _WIN64 report_error_in("LoadLibrary"); #else diff --git a/src/test/test_parallel_for.cpp b/src/test/test_parallel_for.cpp index abc21a0a..eb965b7e 100644 --- a/src/test/test_parallel_for.cpp +++ b/src/test/test_parallel_for.cpp @@ -31,7 +31,9 @@ #pragma warning (disable: 4267) #endif +#if !defined(_SCL_SECURE_NO_WARNINGS) #define _SCL_SECURE_NO_WARNINGS +#endif #endif //#if _MSC_VER #include "harness_defs.h" diff --git a/src/test/test_task_arena.cpp b/src/test/test_task_arena.cpp index 32cf5769..6930d3f3 100644 --- a/src/test/test_task_arena.cpp +++ b/src/test/test_task_arena.cpp @@ -47,7 +47,7 @@ #include "tbb/tbb_thread.h" #if _MSC_VER -// plays around __TBB_NO_IMPLICIT_LINKAGE. __TBB_LIB_NAME should be defined (in makefiles) +// works around !__TBB_IMPLICIT_LINKAGE. __TBB_LIB_NAME should be defined (in makefiles) #pragma comment(lib, __TBB_STRING(__TBB_LIB_NAME)) #endif diff --git a/src/test/test_task_priority.cpp b/src/test/test_task_priority.cpp index 557cb45f..fbd034cc 100644 --- a/src/test/test_task_priority.cpp +++ b/src/test/test_task_priority.cpp @@ -30,8 +30,8 @@ #include "tbb/atomic.h" #include -#if _MSC_VER && __TBB_NO_IMPLICIT_LINKAGE -// plays around __TBB_NO_IMPLICIT_LINKAGE. __TBB_LIB_NAME should be defined (in makefiles) +#if _MSC_VER && __TBB_IMPLICIT_LINKAGE +// works around !__TBB_IMPLICIT_LINKAGE. __TBB_LIB_NAME should be defined (in makefiles) #pragma comment(lib, __TBB_STRING(__TBB_LIB_NAME)) #endif diff --git a/src/test/test_task_scheduler_init.cpp b/src/test/test_task_scheduler_init.cpp index 6479ea1f..7d0a5e00 100644 --- a/src/test/test_task_scheduler_init.cpp +++ b/src/test/test_task_scheduler_init.cpp @@ -321,7 +321,7 @@ void TestBlockingTerminate() { int TestMain () { // Do not use tbb::task_scheduler_init directly in the scope of main's body, // as a static variable, or as a member of a static variable. -#if _MSC_VER && !__TBB_NO_IMPLICIT_LINKAGE && !defined(__TBB_LIB_NAME) +#if _MSC_VER && __TBB_IMPLICIT_LINKAGE && !defined(__TBB_LIB_NAME) #ifdef _DEBUG ASSERT(!GetModuleHandle(_T("tbb.dll")) && GetModuleHandle(_T("tbb_debug.dll")), "test linked with wrong (non-debug) TBB library"); @@ -329,7 +329,7 @@ int TestMain () { ASSERT(!GetModuleHandle(_T("tbb_debug.dll")) && GetModuleHandle(_T("tbb.dll")), "test linked with wrong (debug) TBB library"); #endif -#endif /* _MSC_VER && !__TBB_NO_IMPLICIT_LINKAGE && !__TBB_LIB_NAME */ +#endif std::srand(2); REMARK("testing master thread\n"); int threads = DefaultThreads*2; diff --git a/src/test/test_task_scheduler_observer.cpp b/src/test/test_task_scheduler_observer.cpp index c27944e2..cf05355b 100644 --- a/src/test/test_task_scheduler_observer.cpp +++ b/src/test/test_task_scheduler_observer.cpp @@ -30,8 +30,8 @@ #include "tbb/tick_count.h" #include "harness_barrier.h" -#if _MSC_VER && __TBB_NO_IMPLICIT_LINKAGE -// plays around __TBB_NO_IMPLICIT_LINKAGE. __TBB_LIB_NAME should be defined (in makefiles) +#if _MSC_VER && !__TBB_IMPLICIT_LINKAGE +// works around !__TBB_IMPLICIT_LINKAGE. __TBB_LIB_NAME should be defined (in makefiles) #pragma comment(lib, __TBB_STRING(__TBB_LIB_NAME)) #endif From 50f6df7047eb209d5ea1c8881e2a14c2de057e0a Mon Sep 17 00:00:00 2001 From: John-Paul Smith Date: Fri, 24 Jun 2022 13:11:54 +0100 Subject: [PATCH 6/7] Fix cross compliation on macOS There was a quoting error in fd76ffb which meant the space between -arch and the architecture was escaped. Also this commit adds the stdlib argument to suppress a warning about the failure to find libstdc++, which has not been available on macOS for some time. --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 82bb3ee1..60ad9b2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -251,17 +251,18 @@ else() if (APPLE) list(GET CMAKE_OSX_ARCHITECTURES 0 TARGET_ARCH) - set(ARCH_COMPILER_OPTION "-arch ${TARGET_ARCH}") + set(ARCH_COMPILER_OPTION -arch ${TARGET_ARCH}) + set(STDLIB_COMPILER_OPTION -stdlib=libc++) endif(APPLE) add_custom_command(OUTPUT tbb.def - COMMAND ${CMAKE_CXX_COMPILER} ${ARCH_COMPILER_OPTION} -xc++ -std=c++11 -E ${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/${ARCH_PREFIX}-tbb-export.def -I ${CMAKE_CURRENT_SOURCE_DIR}/include -o tbb.def + COMMAND ${CMAKE_CXX_COMPILER} ${ARCH_COMPILER_OPTION} ${STDLIB_COMPILER_OPTION} -xc++ -std=c++11 -E ${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/${ARCH_PREFIX}-tbb-export.def -I ${CMAKE_CURRENT_SOURCE_DIR}/include -o tbb.def MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/src/tbb/${ARCH_PREFIX}-tbb-export.def COMMENT "Preprocessing tbb.def" ) add_custom_command(OUTPUT tbbmalloc.def - COMMAND ${CMAKE_CXX_COMPILER} ${ARCH_COMPILER_OPTION} -xc++ -std=c++11 -E ${CMAKE_CURRENT_SOURCE_DIR}/src/tbbmalloc/${ARCH_PREFIX}-tbbmalloc-export.def -I ${CMAKE_CURRENT_SOURCE_DIR}/include -o tbbmalloc.def + COMMAND ${CMAKE_CXX_COMPILER} ${ARCH_COMPILER_OPTION} ${STDLIB_COMPILER_OPTION} -xc++ -std=c++11 -E ${CMAKE_CURRENT_SOURCE_DIR}/src/tbbmalloc/${ARCH_PREFIX}-tbbmalloc-export.def -I ${CMAKE_CURRENT_SOURCE_DIR}/include -o tbbmalloc.def MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/src/tbbmalloc/${ARCH_PREFIX}-tbbmalloc-export.def COMMENT "Preprocessing tbbmalloc.def" ) From 56f7609c6b38f5dc424b4acffd49357f4fe305de Mon Sep 17 00:00:00 2001 From: Matthew Mott Date: Thu, 26 Jun 2025 10:27:16 +0100 Subject: [PATCH 7/7] Fix Linux compilation with certain GCC versions Newer GCCs do not allow the meaning of "task" to change in the scope of a class declaration, which is apparently invalid C++. --- include/tbb/task.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/tbb/task.h b/include/tbb/task.h index 5e137c69..b5fb1ac3 100644 --- a/include/tbb/task.h +++ b/include/tbb/task.h @@ -249,7 +249,7 @@ namespace internal { #if __TBB_TASK_PRIORITY //! Pointer to the next offloaded lower priority task. /** Used to maintain a list of offloaded tasks inside the scheduler. **/ - task* next_offloaded; + tbb::task* next_offloaded; #endif #if __TBB_PREVIEW_RESUMABLE_TASKS