Skip to content

Commit 376e8f1

Browse files
Rename hadd into reduce_add for the generic implementation
It matches the implementation of other operations.
1 parent 429da70 commit 376e8f1

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

include/xsimd/arch/common/xsimd_common_arithmetic.hpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -139,20 +139,6 @@ namespace xsimd
139139
return fma(x, y, select(mask, neg(z), z));
140140
}
141141

142-
// hadd
143-
template <class A, class T, class /*=typename std::enable_if<std::is_integral<T>::value, void>::type*/>
144-
XSIMD_INLINE T hadd(batch<T, A> const& self, requires_arch<common>) noexcept
145-
{
146-
alignas(A::alignment()) T buffer[batch<T, A>::size];
147-
self.store_aligned(buffer);
148-
T res = 0;
149-
for (T val : buffer)
150-
{
151-
res += val;
152-
}
153-
return res;
154-
}
155-
156142
// incr
157143
template <class A, class T>
158144
XSIMD_INLINE batch<T, A> incr(batch<T, A> const& self, requires_arch<common>) noexcept

include/xsimd/arch/common/xsimd_common_math.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,6 +2103,20 @@ namespace xsimd
21032103
return { reduce_add(self.real()), reduce_add(self.imag()) };
21042104
}
21052105

2106+
template <class A, class T, class /*=typename std::enable_if<std::is_scalar<T>::value, void>::type*/>
2107+
XSIMD_INLINE T reduce_add(batch<T, A> const& self, requires_arch<common>) noexcept
2108+
{
2109+
alignas(A::alignment()) T buffer[batch<T, A>::size];
2110+
self.store_aligned(buffer);
2111+
T res = 0;
2112+
for (T val : buffer)
2113+
{
2114+
res += val;
2115+
}
2116+
return res;
2117+
}
2118+
2119+
21062120
namespace detail
21072121
{
21082122
template <class T, T N>

include/xsimd/arch/xsimd_avx.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ namespace xsimd
10461046
}
10471047

10481048
// reduce_add
1049-
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value || std::is_same<T, float>::value || std::is_same<T, double>::value, void>::type>
1049+
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
10501050
XSIMD_INLINE T reduce_add(batch<T, A> const& self, requires_arch<avx>) noexcept
10511051
{
10521052
typename batch<T, sse4_2>::register_type low, high;

include/xsimd/arch/xsimd_common_fwd.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ namespace xsimd
3636
XSIMD_INLINE batch<T, A> sadd(batch<T, A> const& self, batch<T, A> const& other, requires_arch<common>) noexcept;
3737
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
3838
XSIMD_INLINE batch<T, A> ssub(batch<T, A> const& self, batch<T, A> const& other, requires_arch<common>) noexcept;
39-
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
40-
XSIMD_INLINE T hadd(batch<T, A> const& self, requires_arch<common>) noexcept;
39+
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
40+
XSIMD_INLINE T reduce_add(batch<T, A> const& self, requires_arch<common>) noexcept;
4141
// Forward declarations for pack-level helpers
4242
namespace detail
4343
{

include/xsimd/arch/xsimd_sse2.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,7 @@ namespace xsimd
12901290
}
12911291
else
12921292
{
1293-
return hadd(self, common {});
1293+
return reduce_add(self, common {});
12941294
}
12951295
}
12961296

include/xsimd/arch/xsimd_vsx.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ namespace xsimd
559559
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
560560
XSIMD_INLINE T reduce_add(batch<T, A> const& self, requires_arch<vsx>) noexcept
561561
{
562-
return hadd(self, common {});
562+
return reduce_add(self, common {});
563563
}
564564

565565
// round

include/xsimd/arch/xsimd_wasm.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ namespace xsimd
12061206
}
12071207
else
12081208
{
1209-
return hadd(self, common {});
1209+
return reduce_add(self, common {});
12101210
}
12111211
}
12121212
template <class A>

0 commit comments

Comments
 (0)