Skip to content

Commit

Permalink
Update tbb version 2021.12.0 (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
TLCFEM authored Apr 26, 2024
1 parent 008bae4 commit 8025704
Show file tree
Hide file tree
Showing 59 changed files with 368 additions and 184 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
1. update `Armadillo` to version `12.8.2` [#193](https://github.com/TLCFEM/suanPan/pull/193)
2. plane strain Duncan-Selig soil model [#195](https://github.com/TLCFEM/suanPan/pull/195)
3. update `Catch2` to version `3.5.4`
4. update `TBB` to version `2021.12.0` [#199](https://github.com/TLCFEM/suanPan/pull/199)

## version 3.3

Expand Down
4 changes: 3 additions & 1 deletion Include/oneapi/tbb.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2005-2021 Intel Corporation
Copyright (c) 2005-2023 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -63,6 +63,8 @@
#include "oneapi/tbb/queuing_rw_mutex.h"
#include "oneapi/tbb/spin_mutex.h"
#include "oneapi/tbb/spin_rw_mutex.h"
#include "oneapi/tbb/mutex.h"
#include "oneapi/tbb/rw_mutex.h"
#include "oneapi/tbb/task.h"
#include "oneapi/tbb/task_arena.h"
#include "oneapi/tbb/task_group.h"
Expand Down
134 changes: 132 additions & 2 deletions Include/oneapi/tbb/concurrent_queue.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2005-2022 Intel Corporation
Copyright (c) 2005-2023 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -91,6 +91,10 @@ class concurrent_queue {
push(*begin);
}

concurrent_queue( std::initializer_list<value_type> init, const allocator_type& alloc = allocator_type() ) :
concurrent_queue(init.begin(), init.end(), alloc)
{}

concurrent_queue(const concurrent_queue& src, const allocator_type& a) :
concurrent_queue(a)
{
Expand Down Expand Up @@ -132,6 +136,53 @@ class concurrent_queue {
r1::cache_aligned_deallocate(my_queue_representation);
}

concurrent_queue& operator=( const concurrent_queue& other ) {
//TODO: implement support for std::allocator_traits::propagate_on_container_copy_assignment
if (my_queue_representation != other.my_queue_representation) {
clear();
my_allocator = other.my_allocator;
my_queue_representation->assign(*other.my_queue_representation, my_allocator, copy_construct_item);
}
return *this;
}

concurrent_queue& operator=( concurrent_queue&& other ) {
//TODO: implement support for std::allocator_traits::propagate_on_container_move_assignment
if (my_queue_representation != other.my_queue_representation) {
clear();
if (my_allocator == other.my_allocator) {
internal_swap(other);
} else {
my_queue_representation->assign(*other.my_queue_representation, other.my_allocator, move_construct_item);
other.clear();
my_allocator = std::move(other.my_allocator);
}
}
return *this;
}

concurrent_queue& operator=( std::initializer_list<value_type> init ) {
assign(init);
return *this;
}

template <typename InputIterator>
void assign( InputIterator first, InputIterator last ) {
concurrent_queue src(first, last);
clear();
my_queue_representation->assign(*src.my_queue_representation, my_allocator, move_construct_item);
}

void assign( std::initializer_list<value_type> init ) {
assign(init.begin(), init.end());
}

void swap ( concurrent_queue& other ) {
//TODO: implement support for std::allocator_traits::propagate_on_container_swap
__TBB_ASSERT(my_allocator == other.my_allocator, "unequal allocators");
internal_swap(other);
}

// Enqueue an item at tail of queue.
void push(const T& value) {
internal_push(value);
Expand Down Expand Up @@ -215,6 +266,20 @@ class concurrent_queue {

queue_allocator_type my_allocator;
queue_representation_type* my_queue_representation;

friend void swap( concurrent_queue& lhs, concurrent_queue& rhs ) {
lhs.swap(rhs);
}

friend bool operator==( const concurrent_queue& lhs, const concurrent_queue& rhs ) {
return lhs.unsafe_size() == rhs.unsafe_size() && std::equal(lhs.unsafe_begin(), lhs.unsafe_end(), rhs.unsafe_begin());
}

#if !__TBB_CPP20_COMPARISONS_PRESENT
friend bool operator!=( const concurrent_queue& lhs, const concurrent_queue& rhs ) {
return !(lhs == rhs);
}
#endif // __TBB_CPP20_COMPARISONS_PRESENT
}; // class concurrent_queue

#if __TBB_CPP17_DEDUCTION_GUIDES_PRESENT
Expand Down Expand Up @@ -304,6 +369,10 @@ class concurrent_bounded_queue {
push(*begin);
}

concurrent_bounded_queue( std::initializer_list<value_type> init, const allocator_type& alloc = allocator_type() ):
concurrent_bounded_queue(init.begin(), init.end(), alloc)
{}

concurrent_bounded_queue( const concurrent_bounded_queue& src, const allocator_type& a ) :
concurrent_bounded_queue(a)
{
Expand Down Expand Up @@ -346,6 +415,53 @@ class concurrent_bounded_queue {
sizeof(queue_representation_type));
}

concurrent_bounded_queue& operator=( const concurrent_bounded_queue& other ) {
//TODO: implement support for std::allocator_traits::propagate_on_container_copy_assignment
if (my_queue_representation != other.my_queue_representation) {
clear();
my_allocator = other.my_allocator;
my_queue_representation->assign(*other.my_queue_representation, my_allocator, copy_construct_item);
}
return *this;
}

concurrent_bounded_queue& operator=( concurrent_bounded_queue&& other ) {
//TODO: implement support for std::allocator_traits::propagate_on_container_move_assignment
if (my_queue_representation != other.my_queue_representation) {
clear();
if (my_allocator == other.my_allocator) {
internal_swap(other);
} else {
my_queue_representation->assign(*other.my_queue_representation, other.my_allocator, move_construct_item);
other.clear();
my_allocator = std::move(other.my_allocator);
}
}
return *this;
}

concurrent_bounded_queue& operator=( std::initializer_list<value_type> init ) {
assign(init);
return *this;
}

template <typename InputIterator>
void assign( InputIterator first, InputIterator last ) {
concurrent_bounded_queue src(first, last);
clear();
my_queue_representation->assign(*src.my_queue_representation, my_allocator, move_construct_item);
}

void assign( std::initializer_list<value_type> init ) {
assign(init.begin(), init.end());
}

void swap ( concurrent_bounded_queue& other ) {
//TODO: implement support for std::allocator_traits::propagate_on_container_swap
__TBB_ASSERT(my_allocator == other.my_allocator, "unequal allocators");
internal_swap(other);
}

// Enqueue an item at tail of queue.
void push( const T& value ) {
internal_push(value);
Expand Down Expand Up @@ -544,6 +660,20 @@ class concurrent_bounded_queue {
queue_representation_type* my_queue_representation;

r1::concurrent_monitor* my_monitors;

friend void swap( concurrent_bounded_queue& lhs, concurrent_bounded_queue& rhs ) {
lhs.swap(rhs);
}

friend bool operator==( const concurrent_bounded_queue& lhs, const concurrent_bounded_queue& rhs ) {
return lhs.size() == rhs.size() && std::equal(lhs.unsafe_begin(), lhs.unsafe_end(), rhs.unsafe_begin());
}

#if !__TBB_CPP20_COMPARISONS_PRESENT
friend bool operator!=( const concurrent_bounded_queue& lhs, const concurrent_bounded_queue& rhs ) {
return !(lhs == rhs);
}
#endif // __TBB_CPP20_COMPARISONS_PRESENT
}; // class concurrent_bounded_queue

#if __TBB_CPP17_DEDUCTION_GUIDES_PRESENT
Expand All @@ -555,7 +685,7 @@ concurrent_bounded_queue( It, It, Alloc = Alloc() )
#endif /* __TBB_CPP17_DEDUCTION_GUIDES_PRESENT */

} //namespace d2
} // namesapce detail
} // namespace detail

inline namespace v1 {

Expand Down
20 changes: 12 additions & 8 deletions Include/oneapi/tbb/detail/_concurrent_unordered_base.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2005-2022 Intel Corporation
Copyright (c) 2005-2023 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -677,13 +677,17 @@ class concurrent_unordered_base {
size_type current_bucket_count = my_bucket_count.load(std::memory_order_acquire);
size_type necessary_bucket_count = current_bucket_count;

do {
// TODO: Log2 seems useful here
while (necessary_bucket_count * max_load_factor() < elements_count) {
// max_load_factor() is currently unsafe, so we can assume that my_max_load_factor
// would not be changed during the calculation
// TODO: Log2 seems useful here
while (necessary_bucket_count * max_load_factor() < elements_count) {
necessary_bucket_count <<= 1;
}
} while (current_bucket_count >= necessary_bucket_count ||
!my_bucket_count.compare_exchange_strong(current_bucket_count, necessary_bucket_count));
}

while (!my_bucket_count.compare_exchange_strong(current_bucket_count, necessary_bucket_count)) {
if (current_bucket_count >= necessary_bucket_count)
break;
}
}

// Observers
Expand Down Expand Up @@ -917,7 +921,7 @@ class concurrent_unordered_base {
node_allocator_traits::deallocate(dummy_node_allocator, node, 1);
} else {
// GCC 11.1 issues a warning here that incorrect destructor might be called for dummy_nodes
#if (__TBB_GCC_VERSION >= 110100 && __TBB_GCC_VERSION < 130000 ) && !__clang__ && !__INTEL_COMPILER
#if (__TBB_GCC_VERSION >= 110100 && __TBB_GCC_VERSION < 140000 ) && !__clang__ && !__INTEL_COMPILER
volatile
#endif
value_node_ptr val_node = static_cast<value_node_ptr>(node);
Expand Down
17 changes: 13 additions & 4 deletions Include/oneapi/tbb/detail/_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
/* Check which standard library we use. */
#include <cstddef>

#ifdef __has_include
#if __has_include(<version>)
#include <version>
#endif
#endif

#include "_export.h"

#if _MSC_VER
Expand Down Expand Up @@ -182,7 +188,7 @@

/** __TBB_DYNAMIC_LOAD_ENABLED describes the system possibility to load shared libraries at run time **/
#ifndef __TBB_DYNAMIC_LOAD_ENABLED
#define __TBB_DYNAMIC_LOAD_ENABLED 1
#define __TBB_DYNAMIC_LOAD_ENABLED (!__EMSCRIPTEN__)
#endif

/** __TBB_WIN8UI_SUPPORT enables support of Windows* Store Apps and limit a possibility to load
Expand All @@ -195,7 +201,7 @@

/** __TBB_WEAK_SYMBOLS_PRESENT denotes that the system supports the weak symbol mechanism **/
#ifndef __TBB_WEAK_SYMBOLS_PRESENT
#define __TBB_WEAK_SYMBOLS_PRESENT ( !_WIN32 && !__APPLE__ && !__sun && (__TBB_GCC_VERSION >= 40000 || __INTEL_COMPILER ) )
#define __TBB_WEAK_SYMBOLS_PRESENT ( !__EMSCRIPTEN__ && !_WIN32 && !__APPLE__ && !__sun && (__TBB_GCC_VERSION >= 40000 || __INTEL_COMPILER ) )
#endif

/** Presence of compiler features **/
Expand All @@ -220,7 +226,7 @@
/** Library features presence macros **/

#define __TBB_CPP14_INTEGER_SEQUENCE_PRESENT (__TBB_LANG >= 201402L)
#define __TBB_CPP17_INVOKE_RESULT_PRESENT (__TBB_LANG >= 201703L)
#define __TBB_CPP17_INVOKE_PRESENT (__TBB_LANG >= 201703L)

// TODO: Remove the condition(__INTEL_COMPILER > 2021) from the __TBB_CPP17_DEDUCTION_GUIDES_PRESENT
// macro when this feature start working correctly on this compiler.
Expand Down Expand Up @@ -265,7 +271,7 @@
#if defined(__cpp_impl_three_way_comparison) && defined(__cpp_lib_three_way_comparison)
#define __TBB_CPP20_COMPARISONS_PRESENT ((__cpp_impl_three_way_comparison >= 201907L) && (__cpp_lib_three_way_comparison >= 201907L))
#else
#define __TBB_CPP20_COMPARISONS_PRESENT __TBB_CPP20_PRESENT
#define __TBB_CPP20_COMPARISONS_PRESENT 0
#endif

#define __TBB_RESUMABLE_TASKS (!__TBB_WIN8UI_SUPPORT && !__ANDROID__ && !__QNXNTO__ && (!__linux__ || __GLIBC__))
Expand Down Expand Up @@ -374,6 +380,9 @@
#define __TBB_ARENA_BINDING 1
#endif

// Thread pinning is not available on macOS*
#define __TBB_CPUBIND_PRESENT (__TBB_ARENA_BINDING && !__APPLE__)

#ifndef __TBB_ENQUEUE_ENFORCED_CONCURRENCY
#define __TBB_ENQUEUE_ENFORCED_CONCURRENCY 1
#endif
Expand Down
10 changes: 5 additions & 5 deletions Include/oneapi/tbb/detail/_flow_graph_body_impl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2005-2022 Intel Corporation
Copyright (c) 2005-2023 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -109,7 +109,7 @@ template <typename Input, typename Output, typename B>
class function_body_leaf : public function_body< Input, Output > {
public:
function_body_leaf( const B &_body ) : body(_body) { }
Output operator()(const Input &i) override { return body(i); }
Output operator()(const Input &i) override { return tbb::detail::invoke(body,i); }
B get_body() { return body; }
function_body_leaf* clone() override {
return new function_body_leaf< Input, Output, B >(body);
Expand Down Expand Up @@ -184,7 +184,7 @@ class multifunction_body_leaf : public multifunction_body<Input, OutputSet> {
public:
multifunction_body_leaf(const B &_body) : body(_body) { }
void operator()(const Input &input, OutputSet &oset) override {
body(input, oset); // body may explicitly put() to one or more of oset.
tbb::detail::invoke(body, input, oset); // body may explicitly put() to one or more of oset.
}
void* get_body_ptr() override { return &body; }
multifunction_body_leaf* clone() override {
Expand Down Expand Up @@ -218,7 +218,7 @@ template <typename Input, typename Output, typename B>
class type_to_key_function_body_leaf : public type_to_key_function_body<Input, Output> {
public:
type_to_key_function_body_leaf( const B &_body ) : body(_body) { }
Output operator()(const Input &i) override { return body(i); }
Output operator()(const Input &i) override { return tbb::detail::invoke(body, i); }
type_to_key_function_body_leaf* clone() override {
return new type_to_key_function_body_leaf< Input, Output, B>(body);
}
Expand All @@ -231,7 +231,7 @@ class type_to_key_function_body_leaf<Input,Output&,B> : public type_to_key_funct
public:
type_to_key_function_body_leaf( const B &_body ) : body(_body) { }
const Output& operator()(const Input &i) override {
return body(i);
return tbb::detail::invoke(body, i);
}
type_to_key_function_body_leaf* clone() override {
return new type_to_key_function_body_leaf< Input, Output&, B>(body);
Expand Down
8 changes: 4 additions & 4 deletions Include/oneapi/tbb/detail/_flow_graph_node_impl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2005-2022 Intel Corporation
Copyright (c) 2005-2023 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -361,7 +361,7 @@ class function_input : public function_input_base<Input, Policy, A, function_inp
template<typename Body>
function_input(
graph &g, size_t max_concurrency, Body& body, node_priority_t a_priority )
: base_type(g, max_concurrency, a_priority, noexcept(body(input_type())))
: base_type(g, max_concurrency, a_priority, noexcept(tbb::detail::invoke(body, input_type())))
, my_body( new function_body_leaf< input_type, output_type, Body>(body) )
, my_init_body( new function_body_leaf< input_type, output_type, Body>(body) ) {
}
Expand Down Expand Up @@ -392,7 +392,7 @@ class function_input : public function_input_base<Input, Policy, A, function_inp
// There is an extra copied needed to capture the
// body execution without the try_put
fgt_begin_body( my_body );
output_type v = (*my_body)(i);
output_type v = tbb::detail::invoke(*my_body, i);
fgt_end_body( my_body );
return v;
}
Expand Down Expand Up @@ -496,7 +496,7 @@ class multifunction_input : public function_input_base<Input, Policy, A, multifu
// constructor
template<typename Body>
multifunction_input(graph &g, size_t max_concurrency,Body& body, node_priority_t a_priority )
: base_type(g, max_concurrency, a_priority, noexcept(body(input_type(), my_output_ports)))
: base_type(g, max_concurrency, a_priority, noexcept(tbb::detail::invoke(body, input_type(), my_output_ports)))
, my_body( new multifunction_body_leaf<input_type, output_ports_type, Body>(body) )
, my_init_body( new multifunction_body_leaf<input_type, output_ports_type, Body>(body) )
, my_output_ports(init_output_ports<output_ports_type>::call(g, my_output_ports)){
Expand Down
Loading

0 comments on commit 8025704

Please sign in to comment.