Skip to content

Commit deaa553

Browse files
committed
Erased all code under BOOST_CONTAINER_SEGMENTED_LOOP_UNROLLING and unconditionally activate BOOST_CONTAINER_SEGMENTED_ENABLE_DUAL_RA_OPTIMIZATION code
1 parent beb17e2 commit deaa553

30 files changed

Lines changed: 17 additions & 1619 deletions

include/boost/container/experimental/segmented_copy.hpp

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -42,58 +42,6 @@ namespace detail_algo {
4242
// is optimised away, giving the same code as an unbounded loop.
4343
//////////////////////////////////////////////////////////////////////////////
4444

45-
#if defined(BOOST_CONTAINER_SEGMENTED_LOOP_UNROLLING)
46-
47-
template <class RASrcIter, class DstIter, class DstSent>
48-
BOOST_CONTAINER_FORCEINLINE segduo<RASrcIter, DstIter> segmented_copy_dst_bounded
49-
(RASrcIter first, RASrcIter last, DstIter dst_first, DstSent dst_last,
50-
const non_segmented_iterator_tag &, const std::random_access_iterator_tag &)
51-
{
52-
typedef typename iterator_traits<RASrcIter>::difference_type difference_type;
53-
54-
difference_type n = last - first;
55-
56-
while(n >= difference_type(4)) {
57-
if(dst_first == dst_last)
58-
goto out_path;
59-
*dst_first = *first; ++first; ++dst_first;
60-
if(dst_first == dst_last)
61-
goto out_path;
62-
*dst_first = *first; ++first; ++dst_first;
63-
if(dst_first == dst_last)
64-
goto out_path;
65-
*dst_first = *first; ++first; ++dst_first;
66-
if(dst_first == dst_last)
67-
goto out_path;
68-
*dst_first = *first; ++first; ++dst_first;
69-
n -= 4;
70-
}
71-
72-
switch(n) {
73-
case 3:
74-
if(dst_first == dst_last)
75-
goto out_path;
76-
*dst_first = *first; ++first; ++dst_first;
77-
BOOST_FALLTHROUGH;
78-
case 2:
79-
if(dst_first == dst_last)
80-
goto out_path;
81-
*dst_first = *first; ++first; ++dst_first;
82-
BOOST_FALLTHROUGH;
83-
case 1:
84-
if(dst_first == dst_last)
85-
goto out_path;
86-
*dst_first = *first; ++first; ++dst_first;
87-
BOOST_FALLTHROUGH;
88-
default:
89-
break;
90-
}
91-
out_path:
92-
return segduo<RASrcIter, DstIter>(first, dst_first);
93-
}
94-
95-
#endif //BOOST_CONTAINER_SEGMENTED_LOOP_UNROLLING
96-
9745
template <class SrcIter, class Sent, class DstIter, class DstSent, class DstTag, class SrcCat>
9846
BOOST_CONTAINER_FORCEINLINE typename algo_enable_if_c<!DstTag::value, segduo<SrcIter, DstIter> >::type
9947
segmented_copy_dst_bounded
@@ -110,8 +58,6 @@ segmented_copy_dst_bounded
11058
return segduo<SrcIter, DstIter>(first, dst_first);
11159
}
11260

113-
#if defined(BOOST_CONTAINER_SEGMENTED_ENABLE_DUAL_RA_OPTIMIZATION)
114-
11561
template <class RASrcIter, class RADstIter>
11662
BOOST_CONTAINER_FORCEINLINE
11763
typename iterator_enable_if_tag
@@ -128,8 +74,6 @@ segmented_copy_dst_bounded
12874
non_segmented_iterator_tag(), src_tag);
12975
}
13076

131-
#endif //BOOST_CONTAINER_SEGMENTED_ENABLE_DUAL_RA_OPTIMIZATION
132-
13377
template <class SrcIter, class Sent, class SegDstIter, class SrcCat>
13478
segduo<SrcIter, SegDstIter> segmented_copy_dst_bounded
13579
(SrcIter first, Sent last, SegDstIter dst_first, SegDstIter dst_last,

include/boost/container/experimental/segmented_copy_if.hpp

Lines changed: 17 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -42,65 +42,6 @@ namespace detail_algo {
4242
// is optimised away, giving the same code as an unbounded loop.
4343
//////////////////////////////////////////////////////////////////////////////
4444

45-
#if defined(BOOST_CONTAINER_SEGMENTED_LOOP_UNROLLING)
46-
47-
template <class RASrcIter, class DstIter, class DstSent, class Pred>
48-
BOOST_CONTAINER_FORCEINLINE segduo<RASrcIter, DstIter> segmented_copy_if_dst_bounded
49-
(RASrcIter first, RASrcIter last, DstIter dst_first, DstSent dst_last, Pred pred,
50-
const non_segmented_iterator_tag &, const std::random_access_iterator_tag &)
51-
{
52-
typedef typename iterator_traits<RASrcIter>::difference_type difference_type;
53-
54-
difference_type n = last - first;
55-
56-
while(n >= difference_type(4)) {
57-
if(pred(*first)) {
58-
if(dst_first == dst_last) goto out_path;
59-
*dst_first = *first; ++dst_first;
60-
} ++first;
61-
if(pred(*first)) {
62-
if(dst_first == dst_last) goto out_path;
63-
*dst_first = *first; ++dst_first;
64-
} ++first;
65-
if(pred(*first)) {
66-
if(dst_first == dst_last) goto out_path;
67-
*dst_first = *first; ++dst_first;
68-
} ++first;
69-
if(pred(*first)) {
70-
if(dst_first == dst_last) goto out_path;
71-
*dst_first = *first; ++dst_first;
72-
} ++first;
73-
n -= 4;
74-
}
75-
76-
switch(n) {
77-
case 3:
78-
if(pred(*first)) {
79-
if(dst_first == dst_last) goto out_path;
80-
*dst_first = *first; ++dst_first;
81-
} ++first;
82-
BOOST_FALLTHROUGH;
83-
case 2:
84-
if(pred(*first)) {
85-
if(dst_first == dst_last) goto out_path;
86-
*dst_first = *first; ++dst_first;
87-
} ++first;
88-
BOOST_FALLTHROUGH;
89-
case 1:
90-
if(pred(*first)) {
91-
if(dst_first == dst_last) goto out_path;
92-
*dst_first = *first; ++dst_first;
93-
} ++first;
94-
BOOST_FALLTHROUGH;
95-
default:
96-
break;
97-
}
98-
out_path:
99-
return segduo<RASrcIter, DstIter>(first, dst_first);
100-
}
101-
102-
#endif //BOOST_CONTAINER_SEGMENTED_LOOP_UNROLLING
103-
10445
template <class SrcIter, class Sent, class DstIter, class DstSent, class Pred, class DstTag, class SrcCat>
10546
BOOST_CONTAINER_FORCEINLINE
10647
typename algo_enable_if_c<!DstTag::value, segduo<SrcIter, DstIter> >::type
@@ -175,32 +116,32 @@ segduo<SrcIter, SegDstIter> segmented_copy_if_dst_bounded
175116
typedef typename dst_traits::segment_iterator dst_segment_iterator;
176117
typedef typename segmented_iterator_traits<dst_local_iterator>::is_segmented_iterator dst_is_local_seg_t;
177118

178-
dst_segment_iterator sfirst = dst_traits::segment(dst_first);
179-
const dst_segment_iterator slast = dst_traits::segment(dst_last);
119+
dst_segment_iterator dsfirst = dst_traits::segment(dst_first);
120+
const dst_segment_iterator dslast = dst_traits::segment(dst_last);
180121

181-
if(sfirst == slast) {
122+
if(dsfirst == dslast) {
182123
segduo<SrcIter, dst_local_iterator> r = (segmented_copy_if_dst_bounded)
183124
(first, last, dst_traits::local(dst_first), dst_traits::local(dst_last), pred, dst_is_local_seg_t(), SrcCat());
184-
return segduo<SrcIter, SegDstIter>(r.first, dst_traits::compose(sfirst, r.second));
125+
return segduo<SrcIter, SegDstIter>(r.first, dst_traits::compose(dsfirst, r.second));
185126
}
186127
else {
187128
segduo<SrcIter, dst_local_iterator> r = (segmented_copy_if_dst_bounded)
188-
(first, last, dst_traits::local(dst_first), dst_traits::end(sfirst), pred, dst_is_local_seg_t(), SrcCat());
189-
first = r.first;
190-
if(first == last)
191-
return segduo<SrcIter, SegDstIter>(first, dst_traits::compose(sfirst, r.second));
129+
(first, last, dst_traits::local(dst_first), dst_traits::end(dsfirst), pred, dst_is_local_seg_t(), SrcCat());
130+
if (r.first != last) {
131+
first = r.first;
132+
133+
for (++dsfirst; dsfirst != dslast; ++dsfirst) {
134+
r = (segmented_copy_if_dst_bounded)
135+
(first, last, dst_traits::begin(dsfirst), dst_traits::end(dsfirst), pred, dst_is_local_seg_t(), SrcCat());
136+
first = r.first;
137+
if (first == last)
138+
return segduo<SrcIter, SegDstIter>(first, dst_traits::compose(dsfirst, r.second));
139+
}
192140

193-
for(++sfirst; sfirst != slast; ++sfirst) {
194141
r = (segmented_copy_if_dst_bounded)
195-
(first, last, dst_traits::begin(sfirst), dst_traits::end(sfirst), pred, dst_is_local_seg_t(), SrcCat());
196-
first = r.first;
197-
if(first == last)
198-
return segduo<SrcIter, SegDstIter>(first, dst_traits::compose(sfirst, r.second));
142+
(first, last, dst_traits::begin(dslast), dst_traits::local(dst_last), pred, dst_is_local_seg_t(), SrcCat());
199143
}
200-
201-
r = (segmented_copy_if_dst_bounded)
202-
(first, last, dst_traits::begin(slast), dst_traits::local(dst_last), pred, dst_is_local_seg_t(), SrcCat());
203-
return segduo<SrcIter, SegDstIter>(r.first, dst_traits::compose(sfirst, r.second));
144+
return segduo<SrcIter, SegDstIter>(r.first, dst_traits::compose(dsfirst, r.second));
204145
}
205146
}
206147

include/boost/container/experimental/segmented_copy_n.hpp

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -44,46 +44,6 @@ namespace detail_algo {
4444
// is optimised away, giving the same code as an unbounded loop.
4545
//////////////////////////////////////////////////////////////////////////////
4646

47-
#if defined(BOOST_CONTAINER_SEGMENTED_LOOP_UNROLLING)
48-
49-
template <class SrcIter, class SrcSent, class Size, class DstIter, class DstSent>
50-
BOOST_CONTAINER_FORCEINLINE
51-
segduo<SrcIter, DstIter> segmented_copy_n_src_dst_bounded
52-
(SrcIter first, SrcSent last, Size& BOOST_RESTRICT count, DstIter dst_first, DstSent dst_last)
53-
{
54-
while(count >= Size(4)) {
55-
if(dst_first == dst_last || first == last) goto out_path;
56-
*dst_first = *first; ++first; ++dst_first; --count;
57-
if(dst_first == dst_last || first == last) goto out_path;
58-
*dst_first = *first; ++first; ++dst_first; --count;
59-
if(dst_first == dst_last || first == last) goto out_path;
60-
*dst_first = *first; ++first; ++dst_first; --count;
61-
if(dst_first == dst_last || first == last) goto out_path;
62-
*dst_first = *first; ++first; ++dst_first; --count;
63-
}
64-
65-
switch(count) {
66-
case 3:
67-
if(dst_first == dst_last || first == last) goto out_path;
68-
*dst_first = *first; ++first; ++dst_first; --count;
69-
BOOST_FALLTHROUGH;
70-
case 2:
71-
if(dst_first == dst_last || first == last) goto out_path;
72-
*dst_first = *first; ++first; ++dst_first; --count;
73-
BOOST_FALLTHROUGH;
74-
case 1:
75-
if(dst_first == dst_last || first == last) goto out_path;
76-
*dst_first = *first; ++first; ++dst_first; --count;
77-
BOOST_FALLTHROUGH;
78-
default:
79-
break;
80-
}
81-
out_path:
82-
return segduo<SrcIter, DstIter>(first, dst_first);
83-
}
84-
85-
#else
86-
8747
template <class SrcIter, class SrcSent, class Size, class DstIter, class DstSent>
8848
BOOST_CONTAINER_FORCEINLINE segduo<SrcIter, DstIter>
8949
segmented_copy_n_src_dst_bounded
@@ -100,24 +60,16 @@ segmented_copy_n_src_dst_bounded
10060
return segduo<SrcIter, DstIter>(first, dst_first);
10161
}
10262

103-
#endif //BOOST_CONTAINER_SEGMENTED_LOOP_UNROLLING
104-
10563
template <class SrcIter, class SrcSent, class Size, class DstIter, class DstSent>
10664
BOOST_CONTAINER_FORCEINLINE
107-
#if defined(BOOST_CONTAINER_SEGMENTED_ENABLE_DUAL_RA_OPTIMIZATION)
10865
typename iterator_disable_if_tag
10966
<DstIter, std::random_access_iterator_tag, segduo<SrcIter, DstIter> >::type
110-
#else
111-
segduo<SrcIter, DstIter>
112-
#endif
11367
segmented_copy_n_dst_bounded
11468
(SrcIter first, SrcSent last, Size& BOOST_RESTRICT count, DstIter dst_first, DstSent dst_last, const non_segmented_iterator_tag &)
11569
{
11670
return (segmented_copy_n_src_dst_bounded)(first, last, count, dst_first, dst_last);
11771
}
11872

119-
#if defined(BOOST_CONTAINER_SEGMENTED_ENABLE_DUAL_RA_OPTIMIZATION)
120-
12173
template <class RASrcIter, class SrcSent, class Size, class RADstIter>
12274
BOOST_CONTAINER_FORCEINLINE
12375
typename iterator_enable_if_tag
@@ -138,8 +90,6 @@ segmented_copy_n_dst_bounded
13890
return r;
13991
}
14092

141-
#endif //BOOST_CONTAINER_SEGMENTED_ENABLE_DUAL_RA_OPTIMIZATION
142-
14393
template <class SrcIter, class SrcSent, class Size, class SegDstIter>
14494
segduo<SrcIter, SegDstIter> segmented_copy_n_dst_bounded
14595
(SrcIter first, SrcSent last, Size& BOOST_RESTRICT count, SegDstIter dst_first, SegDstIter dst_last, const segmented_iterator_tag &)
@@ -351,7 +301,6 @@ OutIter segmented_copy_n(InIter first, Size count, OutIter result)
351301
typename traits::is_segmented_iterator(), typename iterator_traits<InIter>::iterator_category());
352302
}
353303

354-
355304
} // namespace container
356305
} // namespace boost
357306

include/boost/container/experimental/segmented_count.hpp

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -32,74 +32,6 @@ segmented_count(InpIter first, Sent last, const T& BOOST_RESTRICT value);
3232

3333
namespace detail_algo {
3434

35-
#if defined(BOOST_CONTAINER_SEGMENTED_LOOP_UNROLLING)
36-
37-
template <class RAIter, class T>
38-
BOOST_CONTAINER_FORCEINLINE
39-
typename iterator_traits<RAIter>::difference_type
40-
segmented_count_dispatch
41-
(RAIter first, RAIter last, const T& BOOST_RESTRICT value, const non_segmented_iterator_tag &, const std::random_access_iterator_tag &)
42-
{
43-
typedef typename iterator_traits<RAIter>::difference_type difference_type;
44-
45-
difference_type n = last - first;
46-
difference_type count = 0;
47-
while(n >= difference_type(4)) {
48-
#if defined(BOOST_CONTAINER_SEGMENTED_COUNT_BRANCHLESS)
49-
count += static_cast<difference_type>(*first == value);
50-
++first;
51-
count += static_cast<difference_type>(*first == value);
52-
++first;
53-
count += static_cast<difference_type>(*first == value);
54-
++first;
55-
count += static_cast<difference_type>(*first == value);
56-
++first;
57-
#else
58-
if(*first == value) ++count;
59-
++first;
60-
if(*first == value) ++count;
61-
++first;
62-
if(*first == value) ++count;
63-
++first;
64-
if(*first == value) ++count;
65-
++first;
66-
#endif
67-
n -= 4;
68-
}
69-
70-
switch(n) {
71-
case 3:
72-
#if defined(BOOST_CONTAINER_SEGMENTED_COUNT_BRANCHLESS)
73-
count += static_cast<difference_type>(*first == value);
74-
#else
75-
if(*first == value) ++count;
76-
#endif
77-
++first;
78-
BOOST_FALLTHROUGH;
79-
case 2:
80-
#if defined(BOOST_CONTAINER_SEGMENTED_COUNT_BRANCHLESS)
81-
count += static_cast<difference_type>(*first == value);
82-
#else
83-
if(*first == value) ++count;
84-
#endif
85-
++first;
86-
BOOST_FALLTHROUGH;
87-
case 1:
88-
#if defined(BOOST_CONTAINER_SEGMENTED_COUNT_BRANCHLESS)
89-
count += static_cast<difference_type>(*first == value);
90-
#else
91-
if(*first == value) ++count;
92-
#endif
93-
++first;
94-
BOOST_FALLTHROUGH;
95-
default:
96-
break;
97-
}
98-
return count;
99-
}
100-
101-
#endif //BOOST_CONTAINER_SEGMENTED_LOOP_UNROLLING
102-
10335
template <class InpIter, class Sent, class T, class Tag, class Cat>
10436
BOOST_CONTAINER_FORCEINLINE
10537
typename algo_enable_if_c<

0 commit comments

Comments
 (0)