Skip to content

Commit 4c839e5

Browse files
committed
Intel TBB 4.2 Update 5
1 parent 364b4a5 commit 4c839e5

File tree

589 files changed

+10759
-4640
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

589 files changed

+10759
-4640
lines changed

inst/include/serial/tbb/parallel_for.h

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2005-2013 Intel Corporation. All Rights Reserved.
2+
Copyright 2005-2014 Intel Corporation. All Rights Reserved.
33
44
This file is part of Threading Building Blocks.
55
@@ -51,7 +51,7 @@
5151

5252
namespace tbb {
5353
namespace serial {
54-
namespace interface6 {
54+
namespace interface7 {
5555

5656
// parallel_for serial annotated implementation
5757

@@ -72,10 +72,10 @@ class start_for : tbb::internal::no_copy {
7272

7373
//! Splitting constructor used to generate children.
7474
/** this becomes left child. Newly constructed object is right child. */
75-
start_for( start_for& parent_, split ) :
76-
my_range( parent_.my_range, split() ),
75+
start_for( start_for& parent_, typename Partitioner::split_type& split_obj ) :
76+
my_range( parent_.my_range, split_obj ),
7777
my_body( parent_.my_body ),
78-
my_partition( parent_.my_partition, split() )
78+
my_partition( parent_.my_partition, split_obj )
7979
{
8080
}
8181

@@ -94,14 +94,15 @@ class start_for : tbb::internal::no_copy {
9494

9595
template< typename Range, typename Body, typename Partitioner >
9696
void start_for< Range, Body, Partitioner >::execute() {
97-
if( !my_range.is_divisible() || !my_partition.divisions_left() ) {
97+
if( !my_range.is_divisible() || !my_partition.is_divisible() ) {
9898
ANNOTATE_TASK_BEGIN( tbb_parallel_for_range );
9999
{
100100
my_body( my_range );
101101
}
102102
ANNOTATE_TASK_END( tbb_parallel_for_range );
103103
} else {
104-
start_for b( *this, split() );
104+
typename Partitioner::split_type split_obj;
105+
start_for b( *this, split_obj );
105106
this->execute(); // Execute the left interval first to keep the serial order.
106107
b.execute(); // Execute the right interval then.
107108
}
@@ -111,28 +112,28 @@ void start_for< Range, Body, Partitioner >::execute() {
111112
/** @ingroup algorithms **/
112113
template<typename Range, typename Body>
113114
void parallel_for( const Range& range, const Body& body ) {
114-
serial::interface6::start_for<Range,Body,const __TBB_DEFAULT_PARTITIONER>::run(range,body,__TBB_DEFAULT_PARTITIONER());
115+
serial::interface7::start_for<Range,Body,const __TBB_DEFAULT_PARTITIONER>::run(range,body,__TBB_DEFAULT_PARTITIONER());
115116
}
116117

117118
//! Parallel iteration over range with simple partitioner.
118119
/** @ingroup algorithms **/
119120
template<typename Range, typename Body>
120121
void parallel_for( const Range& range, const Body& body, const simple_partitioner& partitioner ) {
121-
serial::interface6::start_for<Range,Body,const simple_partitioner>::run(range,body,partitioner);
122+
serial::interface7::start_for<Range,Body,const simple_partitioner>::run(range,body,partitioner);
122123
}
123124

124125
//! Parallel iteration over range with auto_partitioner.
125126
/** @ingroup algorithms **/
126127
template<typename Range, typename Body>
127128
void parallel_for( const Range& range, const Body& body, const auto_partitioner& partitioner ) {
128-
serial::interface6::start_for<Range,Body,const auto_partitioner>::run(range,body,partitioner);
129+
serial::interface7::start_for<Range,Body,const auto_partitioner>::run(range,body,partitioner);
129130
}
130131

131132
//! Parallel iteration over range with affinity_partitioner.
132133
/** @ingroup algorithms **/
133134
template<typename Range, typename Body>
134135
void parallel_for( const Range& range, const Body& body, affinity_partitioner& partitioner ) {
135-
serial::interface6::start_for<Range,Body,affinity_partitioner>::run(range,body,partitioner);
136+
serial::interface7::start_for<Range,Body,affinity_partitioner>::run(range,body,partitioner);
136137
}
137138

138139
//! Implementation of parallel iteration over stepped range of integers with explicit step and partitioner (ignored)
@@ -194,14 +195,14 @@ void parallel_for(Index first, Index last, const Function& f, affinity_partition
194195
parallel_for_impl(first, last, static_cast<Index>(1), f, p);
195196
}
196197

197-
} // namespace interface6
198+
} // namespace interface7
198199

199-
using interface6::parallel_for;
200+
using interface7::parallel_for;
200201

201202
} // namespace serial
202203

203204
#ifndef __TBB_NORMAL_EXECUTION
204-
using serial::interface6::parallel_for;
205+
using serial::interface7::parallel_for;
205206
#endif
206207

207208
} // namespace tbb

inst/include/serial/tbb/tbb_annotate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2005-2013 Intel Corporation. All Rights Reserved.
2+
Copyright 2005-2014 Intel Corporation. All Rights Reserved.
33
44
This file is part of Threading Building Blocks.
55

inst/include/tbb/aggregator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2005-2013 Intel Corporation. All Rights Reserved.
2+
Copyright 2005-2014 Intel Corporation. All Rights Reserved.
33
44
This file is part of Threading Building Blocks.
55
@@ -189,7 +189,7 @@ class aggregator_ext : tbb::internal::no_copy {
189189
class aggregator : private aggregator_ext<internal::basic_handler> {
190190
public:
191191
aggregator() : aggregator_ext<internal::basic_handler>(internal::basic_handler()) {}
192-
//! BASIC INTERFACE: Enter a function for exclusvie execution by the aggregator.
192+
//! BASIC INTERFACE: Enter a function for exclusive execution by the aggregator.
193193
/** The calling thread stores the function object in a basic_operation and
194194
places the operation in the aggregator's mailbox */
195195
template<typename Body>

inst/include/tbb/aligned_space.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2005-2013 Intel Corporation. All Rights Reserved.
2+
Copyright 2005-2014 Intel Corporation. All Rights Reserved.
33
44
This file is part of Threading Building Blocks.
55
@@ -37,7 +37,7 @@ namespace tbb {
3737
//! Block of space aligned sufficiently to construct an array T with N elements.
3838
/** The elements are not constructed or destroyed by this class.
3939
@ingroup memory_allocation */
40-
template<typename T,size_t N>
40+
template<typename T,size_t N=1>
4141
class aligned_space {
4242
private:
4343
typedef __TBB_TypeWithAlignmentAtLeastAsStrict(T) element_type;

inst/include/tbb/atomic.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2005-2013 Intel Corporation. All Rights Reserved.
2+
Copyright 2005-2014 Intel Corporation. All Rights Reserved.
33
44
This file is part of Threading Building Blocks.
55
@@ -425,7 +425,7 @@ struct atomic: internal::atomic_impl<T> {
425425
#if __TBB_ATOMIC_CTORS
426426
#define __TBB_DECL_ATOMIC(T) \
427427
template<> struct atomic<T>: internal::atomic_impl_with_arithmetic<T,T,char> { \
428-
atomic() = default; \
428+
atomic() = default; \
429429
constexpr atomic(T arg): internal::atomic_impl_with_arithmetic<T,T,char>(arg) {} \
430430
\
431431
T operator=( T rhs ) {return store_with_release(rhs);} \
@@ -458,7 +458,7 @@ __TBB_DECL_ATOMIC(unsigned long)
458458
perspective of /Wp64. */
459459
#define __TBB_DECL_ATOMIC_ALT(T,U) \
460460
template<> struct atomic<T>: internal::atomic_impl_with_arithmetic<T,T,char> { \
461-
atomic() = default ; \
461+
atomic() = default ; \
462462
constexpr atomic(T arg): internal::atomic_impl_with_arithmetic<T,T,char>(arg) {} \
463463
T operator=( U rhs ) {return store_with_release(T(rhs));} \
464464
atomic<T>& operator=( const atomic<T>& rhs ) {store_with_release(rhs); return *this;} \
@@ -530,7 +530,7 @@ template <memory_semantics M, typename T>
530530
void store ( atomic<T>& a, T value ) { return a.template store<M>(value); }
531531

532532
namespace interface6{
533-
//! Make an atomic for use in an initialization (list), as an alternative to zero-initializaton or normal assignment.
533+
//! Make an atomic for use in an initialization (list), as an alternative to zero-initialization or normal assignment.
534534
template<typename T>
535535
atomic<T> make_atomic(T t) {
536536
atomic<T> a;
@@ -541,6 +541,12 @@ atomic<T> make_atomic(T t) {
541541
using interface6::make_atomic;
542542

543543
namespace internal {
544+
template<memory_semantics M, typename T >
545+
void swap(atomic<T> & lhs, atomic<T> & rhs){
546+
T tmp = load<M>(lhs);
547+
store<M>(lhs,load<M>(rhs));
548+
store<M>(rhs,tmp);
549+
}
544550

545551
// only to aid in the gradual conversion of ordinary variables to proper atomics
546552
template<typename T>

inst/include/tbb/blocked_range.h

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2005-2013 Intel Corporation. All Rights Reserved.
2+
Copyright 2005-2014 Intel Corporation. All Rights Reserved.
33
44
This file is part of Threading Building Blocks.
55
@@ -60,8 +60,8 @@ class blocked_range {
6060
blocked_range() : my_end(), my_begin() {}
6161

6262
//! Construct range over half-open interval [begin,end), with the given grainsize.
63-
blocked_range( Value begin_, Value end_, size_type grainsize_=1 ) :
64-
my_end(end_), my_begin(begin_), my_grainsize(grainsize_)
63+
blocked_range( Value begin_, Value end_, size_type grainsize_=1 ) :
64+
my_end(end_), my_begin(begin_), my_grainsize(grainsize_)
6565
{
6666
__TBB_ASSERT( my_grainsize>0, "grainsize must be positive" );
6767
}
@@ -93,14 +93,34 @@ class blocked_range {
9393
/** Unspecified if end()<begin(). */
9494
bool is_divisible() const {return my_grainsize<size();}
9595

96-
//! Split range.
97-
/** The new Range *this has the second half, the old range r has the first half.
96+
//! Split range.
97+
/** The new Range *this has the second part, the old range r has the first part.
9898
Unspecified if end()<begin() or !is_divisible(). */
99-
blocked_range( blocked_range& r, split ) :
99+
blocked_range( blocked_range& r, split ) :
100100
my_end(r.my_end),
101-
my_begin(do_split(r)),
101+
my_begin(do_split(r, split())),
102102
my_grainsize(r.my_grainsize)
103-
{}
103+
{
104+
// only comparison 'less than' is required from values of blocked_range objects
105+
__TBB_ASSERT( !(my_begin < r.my_end) && !(r.my_end < my_begin), "blocked_range has been split incorrectly" );
106+
}
107+
108+
#if !TBB_DEPRECATED
109+
//! Static field to support proportional split
110+
static const bool is_divisible_in_proportion = true;
111+
112+
//! Split range.
113+
/** The new Range *this has the second part split according to specified proportion, the old range r has the first part.
114+
Unspecified if end()<begin() or !is_divisible(). */
115+
blocked_range( blocked_range& r, proportional_split& proportion ) :
116+
my_end(r.my_end),
117+
my_begin(do_split(r, proportion)),
118+
my_grainsize(r.my_grainsize)
119+
{
120+
// only comparison 'less than' is required from values of blocked_range objects
121+
__TBB_ASSERT( !(my_begin < r.my_end) && !(r.my_end < my_begin), "blocked_range has been split incorrectly" );
122+
}
123+
#endif
104124

105125
private:
106126
/** NOTE: my_end MUST be declared before my_begin, otherwise the forking constructor will break. */
@@ -110,20 +130,38 @@ class blocked_range {
110130

111131
//! Auxiliary function used by forking constructor.
112132
/** Using this function lets us not require that Value support assignment or default construction. */
113-
static Value do_split( blocked_range& r ) {
133+
static Value do_split( blocked_range& r, split )
134+
{
114135
__TBB_ASSERT( r.is_divisible(), "cannot split blocked_range that is not divisible" );
115-
Value middle = r.my_begin + (r.my_end-r.my_begin)/2u;
136+
Value middle = r.my_begin + (r.my_end - r.my_begin) / 2u;
116137
r.my_end = middle;
117138
return middle;
118139
}
119140

141+
#if !TBB_DEPRECATED
142+
static Value do_split( blocked_range& r, proportional_split& proportion )
143+
{
144+
__TBB_ASSERT( r.is_divisible(), "cannot split blocked_range that is not divisible" );
145+
146+
// usage of 32-bit floating point arithmetic is not enough to handle ranges of
147+
// more than 2^24 iterations accurately. However, even on ranges with 2^64
148+
// iterations the computational error approximately equals to 0.000001% which
149+
// makes small impact on uniform distribution of such range's iterations (assuming
150+
// all iterations take equal time to complete). See 'test_partitioner_whitebox'
151+
// for implementation of an exact split algorithm
152+
size_type right_part = size_type(float(r.size()) * float(proportion.right())
153+
/ float(proportion.left() + proportion.right()) + 0.5f);
154+
return r.my_end = Value(r.my_end - right_part);
155+
}
156+
#endif
157+
120158
template<typename RowValue, typename ColValue>
121159
friend class blocked_range2d;
122160

123161
template<typename RowValue, typename ColValue, typename PageValue>
124162
friend class blocked_range3d;
125163
};
126164

127-
} // namespace tbb
165+
} // namespace tbb
128166

129167
#endif /* __TBB_blocked_range_H */

inst/include/tbb/blocked_range2d.h

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2005-2013 Intel Corporation. All Rights Reserved.
2+
Copyright 2005-2014 Intel Corporation. All Rights Reserved.
33
44
This file is part of Threading Building Blocks.
55
@@ -42,22 +42,22 @@ class blocked_range2d {
4242
//! Type for size of an iteration range
4343
typedef blocked_range<RowValue> row_range_type;
4444
typedef blocked_range<ColValue> col_range_type;
45-
45+
4646
private:
4747
row_range_type my_rows;
4848
col_range_type my_cols;
4949

5050
public:
5151

5252
blocked_range2d( RowValue row_begin, RowValue row_end, typename row_range_type::size_type row_grainsize,
53-
ColValue col_begin, ColValue col_end, typename col_range_type::size_type col_grainsize ) :
53+
ColValue col_begin, ColValue col_end, typename col_range_type::size_type col_grainsize ) :
5454
my_rows(row_begin,row_end,row_grainsize),
5555
my_cols(col_begin,col_end,col_grainsize)
5656
{
5757
}
5858

5959
blocked_range2d( RowValue row_begin, RowValue row_end,
60-
ColValue col_begin, ColValue col_end ) :
60+
ColValue col_begin, ColValue col_end ) :
6161
my_rows(row_begin,row_end),
6262
my_cols(col_begin,col_end)
6363
{
@@ -74,24 +74,43 @@ class blocked_range2d {
7474
return my_rows.is_divisible() || my_cols.is_divisible();
7575
}
7676

77-
blocked_range2d( blocked_range2d& r, split ) :
77+
blocked_range2d( blocked_range2d& r, split ) :
78+
my_rows(r.my_rows),
79+
my_cols(r.my_cols)
80+
{
81+
split split_obj;
82+
do_split(r, split_obj);
83+
}
84+
85+
#if !TBB_DEPRECATED
86+
//! Static field to support proportional split
87+
static const bool is_divisible_in_proportion = true;
88+
89+
blocked_range2d( blocked_range2d& r, proportional_split& proportion ) :
7890
my_rows(r.my_rows),
7991
my_cols(r.my_cols)
92+
{
93+
do_split(r, proportion);
94+
}
95+
#endif
96+
97+
template <typename Split>
98+
void do_split( blocked_range2d& r, Split& split_obj )
8099
{
81100
if( my_rows.size()*double(my_cols.grainsize()) < my_cols.size()*double(my_rows.grainsize()) ) {
82-
my_cols.my_begin = col_range_type::do_split(r.my_cols);
101+
my_cols.my_begin = col_range_type::do_split(r.my_cols, split_obj);
83102
} else {
84-
my_rows.my_begin = row_range_type::do_split(r.my_rows);
103+
my_rows.my_begin = row_range_type::do_split(r.my_rows, split_obj);
85104
}
86105
}
87106

88-
//! The rows of the iteration space
107+
//! The rows of the iteration space
89108
const row_range_type& rows() const {return my_rows;}
90109

91-
//! The columns of the iteration space
110+
//! The columns of the iteration space
92111
const col_range_type& cols() const {return my_cols;}
93112
};
94113

95-
} // namespace tbb
114+
} // namespace tbb
96115

97116
#endif /* __TBB_blocked_range2d_H */

0 commit comments

Comments
 (0)