Skip to content

Commit e628bf1

Browse files
committed
Actually can't use onetbb with STL algorithms
1 parent 8a8ae04 commit e628bf1

File tree

3 files changed

+51
-41
lines changed

3 files changed

+51
-41
lines changed

CMakeLists.txt

+8-2
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ conan_cmake_configure(
193193
gtest/1.13.0
194194
pugixml/1.12.1
195195
xerces-c/3.2.3
196-
onetbb/2021.9.0
196+
tbb/2020.3 # onetbb/2021.9.0 is incompatible with STL algorithms, the tbb::task is removed
197197
GENERATORS ${CONAN_GENERATOR}
198198
)
199199

@@ -285,7 +285,7 @@ foreach( bench_file ${BENCH_FILES} )
285285
add_executable( ${bench_name} ${bench_file} )
286286
target_link_libraries(${bench_name} PRIVATE
287287
CONAN_PKG::benchmark
288-
CONAN_PKG::onetbb
288+
CONAN_PKG::tbb
289289
)
290290
endif()
291291
elseif(bench_name MATCHES "bench_string_trim")
@@ -325,6 +325,12 @@ int main() { }"
325325

326326
endforeach()
327327

328+
add_executable( test_regex test.cpp )
329+
target_link_libraries(test_regex PRIVATE
330+
CONAN_PKG::boost
331+
CONAN_PKG::fmt
332+
)
333+
328334

329335
add_library(testlib
330336
TestClass.hpp

bench_embedded.cpp

+12-14
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ static void CurrentCLike(benchmark::State& state) {
99

1010
static constexpr size_t embedded_file_count = 2;
1111

12-
static const char *embedded_file_name_0 = ":/Resources/sandia/Sandia_Modules.json";
13-
static const char *embedded_file_name_1 = ":/Resources/sandia/Sandia_Modules2.json";
12+
static const char* embedded_file_name_0 = ":/Resources/sandia/Sandia_Modules.json";
13+
static const char* embedded_file_name_1 = ":/Resources/sandia/Sandia_Modules2.json";
1414

15-
static const uint8_t embedded_file_0[] = {0x78,0x9c,0xed,0xbd,0x5d,0xaf,0xe3,0xd8};
16-
static const uint8_t embedded_file_1[] = {0xed,0xaf,0xe3, 0xbd,0x5d,0xaf,0xe3,0xd8,0xe3};
15+
static const uint8_t embedded_file_0[] = {0x78, 0x9c, 0xed, 0xbd, 0x5d, 0xaf, 0xe3, 0xd8};
16+
static const uint8_t embedded_file_1[] = {0xed, 0xaf, 0xe3, 0xbd, 0x5d, 0xaf, 0xe3, 0xd8, 0xe3};
1717

1818
static const size_t embedded_file_len_0 = 8;
1919
static const size_t embedded_file_len_1 = 9;
2020

21-
static const char *embedded_file_names[] = {
21+
static const char* embedded_file_names[] = {
2222
embedded_file_name_0,
2323
embedded_file_name_1,
2424

@@ -28,14 +28,14 @@ static void CurrentCLike(benchmark::State& state) {
2828
embedded_file_len_1,
2929

3030
};
31-
static const uint8_t *embedded_files[] = {
31+
static const uint8_t* embedded_files[] = {
3232
embedded_file_0,
3333
embedded_file_1,
3434
};
3535

3636
// Make sure the variable is not optimized away by compiler
3737
benchmark::DoNotOptimize(embedded_file_names);
38-
benchmark::DoNotOptimize(embedded_file_lens);
38+
// benchmark::DoNotOptimize(embedded_file_lens);
3939
benchmark::DoNotOptimize(embedded_files);
4040

4141
for (size_t i = 0; i < embedded_file_count; ++i) {
@@ -60,13 +60,13 @@ static void ConstexprCLike(benchmark::State& state) {
6060
static constexpr auto embedded_file_name_0 = ":/Resources/sandia/Sandia_Modules.json";
6161
static constexpr auto embedded_file_name_1 = ":/Resources/sandia/Sandia_Modules2.json";
6262

63-
static constexpr uint8_t embedded_file_0[] = {0x78,0x9c,0xed,0xbd,0x5d,0xaf,0xe3,0xd8};
64-
static constexpr uint8_t embedded_file_1[] = {0xed,0xaf,0xe3, 0xbd,0x5d,0xaf,0xe3,0xd8,0xe3};
63+
static constexpr uint8_t embedded_file_0[] = {0x78, 0x9c, 0xed, 0xbd, 0x5d, 0xaf, 0xe3, 0xd8};
64+
static constexpr uint8_t embedded_file_1[] = {0xed, 0xaf, 0xe3, 0xbd, 0x5d, 0xaf, 0xe3, 0xd8, 0xe3};
6565

6666
static constexpr size_t embedded_file_len_0 = 8;
6767
static constexpr size_t embedded_file_len_1 = 9;
6868

69-
static const char *embedded_file_names[] = {
69+
static const char* embedded_file_names[] = {
7070
embedded_file_name_0,
7171
embedded_file_name_1,
7272

@@ -76,14 +76,14 @@ static void ConstexprCLike(benchmark::State& state) {
7676
embedded_file_len_1,
7777

7878
};
79-
static const uint8_t *embedded_files[] = {
79+
static const uint8_t* embedded_files[] = {
8080
embedded_file_0,
8181
embedded_file_1,
8282
};
8383

8484
// Make sure the variable is not optimized away by compiler
8585
benchmark::DoNotOptimize(embedded_file_names);
86-
benchmark::DoNotOptimize(embedded_file_lens);
86+
// benchmark::DoNotOptimize(embedded_file_lens);
8787
benchmark::DoNotOptimize(embedded_files);
8888

8989
for (size_t i = 0; i < embedded_file_count; ++i) {
@@ -97,8 +97,6 @@ static void ConstexprCLike(benchmark::State& state) {
9797
}
9898
}
9999

100-
101-
102100
// Register the function as a benchmark
103101
BENCHMARK(ConstexprCLike);
104102

bench_string_trim.cpp

+31-25
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,33 @@ std::string trim2(std::string_view const in) {
6464
return {view.begin(), view.end()};
6565
}
6666

67+
} // namespace range
68+
69+
static void BM_Trim_Ranges(benchmark::State& state) {
70+
for (auto _ : state) {
71+
std::string str = getTestString();
72+
str = range::trim(str);
73+
benchmark::DoNotOptimize(str);
74+
}
75+
}
76+
77+
static void BM_Trim_Ranges2(benchmark::State& state) {
78+
for (auto _ : state) {
79+
std::string str = getTestString();
80+
str = range::trim2(str);
81+
benchmark::DoNotOptimize(str);
82+
}
83+
}
84+
85+
// Register the function as a benchmark
86+
BENCHMARK(BM_Trim_Boost);
87+
BENCHMARK(BM_Trim_ASCII);
88+
BENCHMARK(BM_Trim_Ranges);
89+
BENCHMARK(BM_Trim_Ranges2);
90+
91+
#if 0
92+
namespace range {
93+
6794
template <std::ranges::view V, typename Pred>
6895
requires std::ranges::bidirectional_range<V>&& std::indirect_unary_predicate<Pred, std::ranges::iterator_t<V>> class drop_last_while_view
6996
: public std::ranges::view_interface<drop_last_while_view<V, Pred>>
@@ -93,17 +120,17 @@ requires std::ranges::bidirectional_range<V>&& std::indirect_unary_predicate<Pre
93120

94121
namespace myviews {
95122

96-
#ifdef __GNUC__
123+
# ifdef __GNUC__
97124
using std::views::__adaptor::_RangeAdaptor;
98125

99126
struct drop_last_while_fn : _RangeAdaptor<drop_last_while_fn>
100127
{
101128
using _RangeAdaptor<drop_last_while_fn>::operator();
102129
static constexpr int _S_arity = 2;
103-
#else
130+
# else
104131
struct drop_last_while_fn
105132
{
106-
#endif
133+
# endif
107134
template <std::ranges::viewable_range R, typename Pred>
108135
constexpr auto operator()(R&& r, Pred pred) const -> range::drop_last_while_view<std::views::all_t<R>, Pred> {
109136
return range::drop_last_while_view<std::views::all_t<R>, Pred>(std::views::all(std::forward<R>(r)), std::move(pred));
@@ -118,25 +145,8 @@ std::string trim3(std::string_view const in) {
118145
auto view = in | std::views::drop_while(isspace) | myviews::drop_last_while(isspace);
119146
return {view.begin(), view.end()};
120147
}
121-
122148
} // namespace range
123149

124-
static void BM_Trim_Ranges(benchmark::State& state) {
125-
for (auto _ : state) {
126-
std::string str = getTestString();
127-
str = range::trim(str);
128-
benchmark::DoNotOptimize(str);
129-
}
130-
}
131-
132-
static void BM_Trim_Ranges2(benchmark::State& state) {
133-
for (auto _ : state) {
134-
std::string str = getTestString();
135-
str = range::trim2(str);
136-
benchmark::DoNotOptimize(str);
137-
}
138-
}
139-
140150
static void BM_Trim_Ranges3(benchmark::State& state) {
141151
for (auto _ : state) {
142152
std::string str = getTestString();
@@ -145,9 +155,5 @@ static void BM_Trim_Ranges3(benchmark::State& state) {
145155
}
146156
}
147157

148-
// Register the function as a benchmark
149-
BENCHMARK(BM_Trim_Boost);
150-
BENCHMARK(BM_Trim_ASCII);
151-
BENCHMARK(BM_Trim_Ranges);
152-
BENCHMARK(BM_Trim_Ranges2);
153158
BENCHMARK(BM_Trim_Ranges3);
159+
#endif

0 commit comments

Comments
 (0)