Skip to content

Commit 1089bd9

Browse files
committed
formatting
1 parent de88be8 commit 1089bd9

File tree

4 files changed

+116
-66
lines changed

4 files changed

+116
-66
lines changed

.github/workflows/benchmarks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
sys:
21-
- {compiler: clang, version: '20', name: xsimd, flags: -DXTENSOR_USE_XSIMD=ON}
22-
- {compiler: clang, version: '20', name: xsimd-tbb, flags: -DXTENSOR_USE_XSIMD=ON -DXTENSOR_USE_TBB=ON}
21+
- {compiler: clang, version: '20', name: xsimd, flags: -DXTENSOR_USE_XSIMD=ON}
22+
- {compiler: clang, version: '20', name: xsimd-tbb, flags: -DXTENSOR_USE_XSIMD=ON -DXTENSOR_USE_TBB=ON}
2323
- {compiler: gcc, version: '14', name: xsimd, flags: -DXTENSOR_USE_XSIMD=ON}
2424
- {compiler: gcc, version: '14', name: xsimd-tbb, flags: -DXTENSOR_USE_XSIMD=ON -DXTENSOR_USE_TBB=ON}
2525

benchmark/benchmark_stl.cpp

Lines changed: 112 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -6,102 +6,152 @@
66
* The full license is in the file LICENSE, distributed with this software. *
77
****************************************************************************/
88

9-
#include <benchmark/benchmark.h>
10-
#include "xtensor/containers/xtensor.hpp"
11-
#include "xtensor/core/xmath.hpp"
12-
#include "xtensor/generators/xrandom.hpp"
13-
14-
namespace xt
15-
{
16-
namespace{
17-
constexpr std::array<size_t, 2> cContainerAssignShape{2000,2000};
18-
template<class Shape>
9+
#include <benchmark/benchmark.h>
10+
11+
#include "xtensor/containers/xtensor.hpp"
12+
#include "xtensor/core/xmath.hpp"
13+
#include "xtensor/generators/xrandom.hpp"
14+
15+
namespace xt
16+
{
17+
namespace
18+
{
19+
constexpr std::array<size_t, 2> cContainerAssignShape{2000, 2000};
20+
21+
template <class Shape>
1922
auto generateRandomInt16From0To100(Shape&& x)
2023
{
2124
return xt::random::randint(x, 0, 100);
2225
}
2326
}
2427

25-
static void Xtensor_Uint16_2000x2000_DivideBy2_StdTransform(benchmark::State& aState) {
26-
xt::xtensor<uint16_t, 2> vInput = generateRandomInt16From0To100(cContainerAssignShape);
28+
static void Xtensor_Uint16_2000x2000_DivideBy2_StdTransform(benchmark::State& aState)
29+
{
30+
xt::xtensor<uint16_t, 2> vInput = generateRandomInt16From0To100(cContainerAssignShape);
2731
auto vOutput = xt::xtensor<uint16_t, 2>::from_shape(cContainerAssignShape);
28-
29-
for (auto _ : aState) {
30-
std::transform(vInput.begin(), vInput.end(), vOutput.begin(), [](auto&& aInputValue) { return aInputValue / 2; });
32+
33+
for (auto _ : aState)
34+
{
35+
std::transform(
36+
vInput.begin(),
37+
vInput.end(),
38+
vOutput.begin(),
39+
[](auto&& aInputValue)
40+
{
41+
return aInputValue / 2;
42+
}
43+
);
3144
}
3245
}
33-
34-
static void Xtensor_Uint16_2000x2000_DivideBy2_Xtensor(benchmark::State& aState) {
35-
xt::xtensor<uint16_t, 2> vInput = generateRandomInt16From0To100(cContainerAssignShape);
46+
47+
static void Xtensor_Uint16_2000x2000_DivideBy2_Xtensor(benchmark::State& aState)
48+
{
49+
xt::xtensor<uint16_t, 2> vInput = generateRandomInt16From0To100(cContainerAssignShape);
3650
auto vOutput = xt::xtensor<uint16_t, 2>::from_shape(cContainerAssignShape);
37-
38-
for (auto _ : aState) {
51+
52+
for (auto _ : aState)
53+
{
3954
vOutput = vInput / 2;
4055
}
4156
}
42-
43-
static void Xtensor_Uint16_2000x2000_DivideBy2Double_StdTransform(benchmark::State& aState) {
44-
xt::xtensor<uint16_t, 2> vInput = generateRandomInt16From0To100(cContainerAssignShape);
57+
58+
static void Xtensor_Uint16_2000x2000_DivideBy2Double_StdTransform(benchmark::State& aState)
59+
{
60+
xt::xtensor<uint16_t, 2> vInput = generateRandomInt16From0To100(cContainerAssignShape);
4561
auto vOutput = xt::xtensor<uint16_t, 2>::from_shape(cContainerAssignShape);
46-
47-
for (auto _ : aState) {
48-
std::transform(vInput.begin(), vInput.end(), vOutput.begin(), [](auto&& aInputValue) { return aInputValue / 2.0; });
62+
63+
for (auto _ : aState)
64+
{
65+
std::transform(
66+
vInput.begin(),
67+
vInput.end(),
68+
vOutput.begin(),
69+
[](auto&& aInputValue)
70+
{
71+
return aInputValue / 2.0;
72+
}
73+
);
4974
}
5075
}
51-
52-
static void Xtensor_Uint16_2000x2000_DivideBy2Double_Xtensor(benchmark::State& aState) {
53-
xt::xtensor<uint16_t, 2> vInput = generateRandomInt16From0To100(cContainerAssignShape);
76+
77+
static void Xtensor_Uint16_2000x2000_DivideBy2Double_Xtensor(benchmark::State& aState)
78+
{
79+
xt::xtensor<uint16_t, 2> vInput = generateRandomInt16From0To100(cContainerAssignShape);
5480
auto vOutput = xt::xtensor<uint16_t, 2>::from_shape(cContainerAssignShape);
55-
56-
for (auto _ : aState) {
81+
82+
for (auto _ : aState)
83+
{
5784
vOutput = vInput / 2.0;
5885
}
5986
}
60-
61-
static void Xtensor_Uint16_2000x2000_MultiplyBy2_StdTransform(benchmark::State& aState) {
62-
xt::xtensor<uint16_t, 2> vInput = generateRandomInt16From0To100(cContainerAssignShape);
87+
88+
static void Xtensor_Uint16_2000x2000_MultiplyBy2_StdTransform(benchmark::State& aState)
89+
{
90+
xt::xtensor<uint16_t, 2> vInput = generateRandomInt16From0To100(cContainerAssignShape);
6391
auto vOutput = xt::xtensor<uint16_t, 2>::from_shape(cContainerAssignShape);
64-
65-
for (auto _ : aState) {
66-
std::transform(vInput.begin(), vInput.end(), vOutput.begin(), [](auto&& aInputValue) { return aInputValue * 2; });
92+
93+
for (auto _ : aState)
94+
{
95+
std::transform(
96+
vInput.begin(),
97+
vInput.end(),
98+
vOutput.begin(),
99+
[](auto&& aInputValue)
100+
{
101+
return aInputValue * 2;
102+
}
103+
);
67104
}
68105
}
69-
70-
static void Xtensor_Uint16_2000x2000_MultiplyBy2_Xtensor(benchmark::State& aState) {
71-
xt::xtensor<uint16_t, 2> vInput = generateRandomInt16From0To100(cContainerAssignShape);
106+
107+
static void Xtensor_Uint16_2000x2000_MultiplyBy2_Xtensor(benchmark::State& aState)
108+
{
109+
xt::xtensor<uint16_t, 2> vInput = generateRandomInt16From0To100(cContainerAssignShape);
72110
auto vOutput = xt::xtensor<uint16_t, 2>::from_shape(cContainerAssignShape);
73-
74-
for (auto _ : aState) {
111+
112+
for (auto _ : aState)
113+
{
75114
vOutput = vInput * 2;
76115
}
77116
}
78-
79-
static void Xtensor_Uint16_2000x2000_Maximum_StdTransform(benchmark::State& aState) {
80-
xt::xtensor<uint16_t, 2> vInput1 = generateRandomInt16From0To100(cContainerAssignShape);
81-
xt::xtensor<uint16_t, 2> vInput2 = generateRandomInt16From0To100(cContainerAssignShape);
117+
118+
static void Xtensor_Uint16_2000x2000_Maximum_StdTransform(benchmark::State& aState)
119+
{
120+
xt::xtensor<uint16_t, 2> vInput1 = generateRandomInt16From0To100(cContainerAssignShape);
121+
xt::xtensor<uint16_t, 2> vInput2 = generateRandomInt16From0To100(cContainerAssignShape);
82122
auto vOutput = xt::xtensor<uint16_t, 2>::from_shape(cContainerAssignShape);
83123

84-
for (auto _ : aState) {
124+
for (auto _ : aState)
125+
{
85126
auto vInput2It = vInput2.begin();
86-
std::transform(vInput1.begin(), vInput1.end(), vOutput.begin(), [&vInput2It](auto&& aInput1Value) { return std::max(aInput1Value, *vInput2It++); });
127+
std::transform(
128+
vInput1.begin(),
129+
vInput1.end(),
130+
vOutput.begin(),
131+
[&vInput2It](auto&& aInput1Value)
132+
{
133+
return std::max(aInput1Value, *vInput2It++);
134+
}
135+
);
87136
}
88137
}
89-
90-
static void Xtensor_Uint16_2000x2000_Maximum_Xtensor(benchmark::State& aState) {
91-
xt::xtensor<uint16_t, 2> vInput1 = generateRandomInt16From0To100(cContainerAssignShape);
92-
xt::xtensor<uint16_t, 2> vInput2 = generateRandomInt16From0To100(cContainerAssignShape);
138+
139+
static void Xtensor_Uint16_2000x2000_Maximum_Xtensor(benchmark::State& aState)
140+
{
141+
xt::xtensor<uint16_t, 2> vInput1 = generateRandomInt16From0To100(cContainerAssignShape);
142+
xt::xtensor<uint16_t, 2> vInput2 = generateRandomInt16From0To100(cContainerAssignShape);
93143
auto vOutput = xt::xtensor<uint16_t, 2>::from_shape(cContainerAssignShape);
94-
95-
for (auto _ : aState) {
144+
145+
for (auto _ : aState)
146+
{
96147
vOutput = xt::maximum(vInput1, vInput2);
97148
}
98149
}
99150

100-
BENCHMARK(Xtensor_Uint16_2000x2000_Maximum_Xtensor);
101-
BENCHMARK(Xtensor_Uint16_2000x2000_Maximum_StdTransform);
102-
BENCHMARK(Xtensor_Uint16_2000x2000_MultiplyBy2_Xtensor);
103-
BENCHMARK(Xtensor_Uint16_2000x2000_MultiplyBy2_StdTransform);
104-
BENCHMARK(Xtensor_Uint16_2000x2000_DivideBy2Double_Xtensor);
105-
BENCHMARK(Xtensor_Uint16_2000x2000_DivideBy2Double_StdTransform);
106-
}
107-
151+
BENCHMARK(Xtensor_Uint16_2000x2000_Maximum_Xtensor);
152+
BENCHMARK(Xtensor_Uint16_2000x2000_Maximum_StdTransform);
153+
BENCHMARK(Xtensor_Uint16_2000x2000_MultiplyBy2_Xtensor);
154+
BENCHMARK(Xtensor_Uint16_2000x2000_MultiplyBy2_StdTransform);
155+
BENCHMARK(Xtensor_Uint16_2000x2000_DivideBy2Double_Xtensor);
156+
BENCHMARK(Xtensor_Uint16_2000x2000_DivideBy2Double_StdTransform);
157+
}

benchmark/benchmark_view_assignment.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,6 @@ namespace xt
155155
// BENCHMARK(assign_create_strided_view);
156156
BENCHMARK(assign_create_view);
157157
BENCHMARK(assign_create_manual_view);
158-
//BENCHMARK(data_offset);
158+
// BENCHMARK(data_offset);
159159
BENCHMARK(data_offset_view);
160160
}

benchmark/downloadGBenchmark.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ExternalProject_Add(googlebenchmark
1818
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googlebenchmark-build"
1919
CONFIGURE_COMMAND ""
2020
BUILD_COMMAND ""
21-
CMAKE_ARGS "BENCHMARK_DOWNLOAD_DEPENDENCIES=TRUE"
21+
CMAKE_ARGS "BENCHMARK_DOWNLOAD_DEPENDENCIES=TRUE"
2222
INSTALL_COMMAND ""
2323
TEST_COMMAND ""
2424
)

0 commit comments

Comments
 (0)