Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit 75a1bdf

Browse files
authored
fix: benchmark deprecation warning (#144)
Try to fix google benchmark deprecation warning. Also uses explicit return types from the benchmark cases, to prevent spurious optimizations
1 parent c72515c commit 75a1bdf

2 files changed

Lines changed: 21 additions & 14 deletions

File tree

benchmarks/common/include/benchmark/common/benchmark_vector.hpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ requires std::invocable<unaryOP, vector_t<scalar_t>> struct vector_unaryOP_bm
8484
// Run the benchmark
8585
for (auto _ : state) {
8686
for (std::size_t i{0}; i < n_samples; ++i) {
87-
const result_t result = unaryOP{}(this->a[i]);
87+
result_t result = unaryOP{}(this->a[i]);
8888
::benchmark::DoNotOptimize(result);
8989
}
9090
}
@@ -119,7 +119,7 @@ requires std::invocable<binaryOP, vector_t<scalar_t>,
119119
// Run the benchmark
120120
for (auto _ : state) {
121121
for (std::size_t i{0}; i < n_samples; ++i) {
122-
const result_t result = binaryOP{}(this->a[i], this->b[i]);
122+
result_t result = binaryOP{}(this->a[i], this->b[i]);
123123
::benchmark::DoNotOptimize(result);
124124
}
125125
}
@@ -132,48 +132,49 @@ namespace bench_op {
132132
struct add {
133133
inline static const std::string name{"add"};
134134
template <concepts::vector vector_t>
135-
auto operator()(const vector_t &a, const vector_t &b) const {
135+
vector_t operator()(const vector_t &a, const vector_t &b) const {
136136
return a + b;
137137
}
138138
};
139139
struct sub {
140140
inline static const std::string name{"sub"};
141141
template <concepts::vector vector_t>
142-
auto operator()(const vector_t &a, const vector_t &b) const {
142+
vector_t operator()(const vector_t &a, const vector_t &b) const {
143143
return a - b;
144144
}
145145
};
146146
struct dot {
147147
inline static const std::string name{"dot"};
148148
template <concepts::vector vector_t>
149-
auto operator()(const vector_t &a, const vector_t &b) const {
149+
algebra::traits::scalar_t<vector_t> operator()(const vector_t &a,
150+
const vector_t &b) const {
150151
return algebra::vector::dot(a, b);
151152
}
152153
};
153154
struct cross {
154155
inline static const std::string name{"cross"};
155156
template <concepts::vector vector_t>
156-
auto operator()(const vector_t &a, const vector_t &b) const {
157+
vector_t operator()(const vector_t &a, const vector_t &b) const {
157158
return algebra::vector::cross(a, b);
158159
}
159160
};
160161

161162
// Macro for declaring vector unary ops
162-
#define ALGEBRA_PLUGINS_BENCH_VECTOR(OP) \
163+
#define ALGEBRA_PLUGINS_BENCH_VECTOR(OP, RES) \
163164
struct OP { \
164165
inline static const std::string name{#OP}; \
165166
template <concepts::vector vector_t> \
166-
auto operator()(const vector_t &a) const { \
167+
RES operator()(const vector_t &a) const { \
167168
return algebra::vector::OP(a); \
168169
} \
169170
};
170171

171-
ALGEBRA_PLUGINS_BENCH_VECTOR(phi)
172-
ALGEBRA_PLUGINS_BENCH_VECTOR(theta)
173-
ALGEBRA_PLUGINS_BENCH_VECTOR(eta)
174-
ALGEBRA_PLUGINS_BENCH_VECTOR(perp)
175-
ALGEBRA_PLUGINS_BENCH_VECTOR(norm)
176-
ALGEBRA_PLUGINS_BENCH_VECTOR(normalize)
172+
ALGEBRA_PLUGINS_BENCH_VECTOR(phi, algebra::traits::scalar_t<vector_t>)
173+
ALGEBRA_PLUGINS_BENCH_VECTOR(theta, algebra::traits::scalar_t<vector_t>)
174+
ALGEBRA_PLUGINS_BENCH_VECTOR(eta, algebra::traits::scalar_t<vector_t>)
175+
ALGEBRA_PLUGINS_BENCH_VECTOR(perp, algebra::traits::scalar_t<vector_t>)
176+
ALGEBRA_PLUGINS_BENCH_VECTOR(norm, algebra::traits::scalar_t<vector_t>)
177+
ALGEBRA_PLUGINS_BENCH_VECTOR(normalize, vector_t)
177178

178179
} // namespace bench_op
179180

storage/vc_soa/include/algebra/storage/vc_soa.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ struct scalar<
8787
algebra::storage::matrix<vc_soa::storage_type, Vc::Vector<T>, ROWS, COLS>> {
8888
using type = Vc::Vector<T>;
8989
};
90+
91+
template <concepts::value T, std::size_t N>
92+
struct scalar<
93+
algebra::storage::vector<N, Vc::Vector<T>, vc_soa::storage_type>> {
94+
using type = Vc::Vector<T>;
95+
};
9096
/// @}
9197

9298
// Vector and storage types are different

0 commit comments

Comments
 (0)