Skip to content

Commit

Permalink
gcc benchmark build fix; gcc perf exceedingly poor due to aliasing
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod committed Nov 27, 2023
1 parent f332351 commit 6b56376
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion benchmark/dual_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ template <typename T, ptrdiff_t N, bool SIMDArry = false> struct ManualDual {

template <std::floating_point T, ptrdiff_t N> struct ManualDual<T, N, false> {
T value;
poly::simd::Vec<N, T> partials;
poly::simd::Vec<ptrdiff_t(std::bit_ceil(size_t(N))), T> partials;
};
template <std::floating_point T, ptrdiff_t N> struct ManualDual<T, N, true> {
T value;
Expand Down
4 changes: 2 additions & 2 deletions include/Math/Dual.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ template <class T, ptrdiff_t N> struct Dual<T, N, false> {
constexpr Dual() = default;
constexpr Dual(T v) : val(v) {}
constexpr Dual(T v, ptrdiff_t n) : val(v) { partials[n] = T{1}; }
constexpr Dual(T v, SVector<T, N> g) : val(v) { partials << g; }
constexpr Dual(T v, SVector<T, N> g) : val(v), partials(g) {}
constexpr Dual(std::integral auto v) : val(v) {}
constexpr Dual(std::floating_point auto v) : val(v) {}
constexpr auto value() -> T & { return val; }
Expand All @@ -123,7 +123,7 @@ template <class T, ptrdiff_t N> struct Dual<T, N, false> {
[[nodiscard]] constexpr auto gradient(ptrdiff_t i) const -> const T & {
return partials[i];
}
[[gnu::always_inline]] constexpr auto operator-() const & -> Dual {
[[gnu::always_inline]] constexpr auto operator-() const -> Dual {
return {-val, -partials};
}
[[gnu::always_inline]] constexpr auto
Expand Down

0 comments on commit 6b56376

Please sign in to comment.