Skip to content

Commit 4d18c0f

Browse files
Cleanup saturated operators testing
Also always use the generic implementation for floating point version.
1 parent 31fd404 commit 4d18c0f

File tree

6 files changed

+30
-64
lines changed

6 files changed

+30
-64
lines changed

include/xsimd/arch/generic/xsimd_generic_arithmetic.hpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,30 @@ namespace xsimd
121121
self, other);
122122
}
123123

124+
// sadd
125+
template <class A>
126+
inline batch<float, A> sadd(batch<float, A> const& self, batch<float, A> const& other, requires_arch<generic>) noexcept
127+
{
128+
return add(self, other); // no saturated arithmetic on floating point numbers
129+
}
130+
template <class A>
131+
inline batch<double, A> sadd(batch<double, A> const& self, batch<double, A> const& other, requires_arch<generic>) noexcept
132+
{
133+
return add(self, other); // no saturated arithmetic on floating point numbers
134+
}
135+
136+
// ssub
137+
template <class A>
138+
inline batch<float, A> ssub(batch<float, A> const& self, batch<float, A> const& other, requires_arch<generic>) noexcept
139+
{
140+
return sub(self, other); // no saturated arithmetic on floating point numbers
141+
}
142+
template <class A>
143+
inline batch<double, A> ssub(batch<double, A> const& self, batch<double, A> const& other, requires_arch<generic>) noexcept
144+
{
145+
return sub(self, other); // no saturated arithmetic on floating point numbers
146+
}
147+
124148
}
125149

126150
}

include/xsimd/arch/xsimd_avx.hpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,16 +1132,6 @@ namespace xsimd
11321132
}
11331133

11341134
// sadd
1135-
template <class A>
1136-
inline batch<float, A> sadd(batch<float, A> const& self, batch<float, A> const& other, requires_arch<avx>) noexcept
1137-
{
1138-
return add(self, other); // no saturated arithmetic on floating point numbers
1139-
}
1140-
template <class A>
1141-
inline batch<double, A> sadd(batch<double, A> const& self, batch<double, A> const& other, requires_arch<avx>) noexcept
1142-
{
1143-
return add(self, other); // no saturated arithmetic on floating point numbers
1144-
}
11451135
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
11461136
inline batch<T, A> sadd(batch<T, A> const& self, batch<T, A> const& other, requires_arch<avx>) noexcept
11471137
{
@@ -1357,16 +1347,6 @@ namespace xsimd
13571347
}
13581348

13591349
// ssub
1360-
template <class A>
1361-
inline batch<float, A> ssub(batch<float, A> const& self, batch<float, A> const& other, requires_arch<avx>) noexcept
1362-
{
1363-
return _mm256_sub_ps(self, other); // no saturated arithmetic on floating point numbers
1364-
}
1365-
template <class A>
1366-
inline batch<double, A> ssub(batch<double, A> const& self, batch<double, A> const& other, requires_arch<avx>) noexcept
1367-
{
1368-
return _mm256_sub_pd(self, other); // no saturated arithmetic on floating point numbers
1369-
}
13701350
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
13711351
inline batch<T, A> ssub(batch<T, A> const& self, batch<T, A> const& other, requires_arch<avx>) noexcept
13721352
{

include/xsimd/arch/xsimd_avx512f.hpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,16 +1350,6 @@ namespace xsimd
13501350
}
13511351

13521352
// sadd
1353-
template <class A>
1354-
inline batch<float, A> sadd(batch<float, A> const& self, batch<float, A> const& other, requires_arch<avx512f>) noexcept
1355-
{
1356-
return add(self, other); // no saturated arithmetic on floating point numbers
1357-
}
1358-
template <class A>
1359-
inline batch<double, A> sadd(batch<double, A> const& self, batch<double, A> const& other, requires_arch<avx512f>) noexcept
1360-
{
1361-
return add(self, other); // no saturated arithmetic on floating point numbers
1362-
}
13631353
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
13641354
inline batch<T, A> sadd(batch<T, A> const& self, batch<T, A> const& other, requires_arch<avx512f>) noexcept
13651355
{
@@ -1642,16 +1632,6 @@ namespace xsimd
16421632
}
16431633

16441634
// ssub
1645-
template <class A>
1646-
inline batch<float, A> ssub(batch<float, A> const& self, batch<float, A> const& other, requires_arch<avx512f>) noexcept
1647-
{
1648-
return _mm512_sub_ps(self, other); // no saturated arithmetic on floating point numbers
1649-
}
1650-
template <class A>
1651-
inline batch<double, A> ssub(batch<double, A> const& self, batch<double, A> const& other, requires_arch<avx512f>) noexcept
1652-
{
1653-
return _mm512_sub_pd(self, other); // no saturated arithmetic on floating point numbers
1654-
}
16551635
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
16561636
inline batch<T, A> ssub(batch<T, A> const& self, batch<T, A> const& other, requires_arch<avx512f>) noexcept
16571637
{

include/xsimd/arch/xsimd_sse2.hpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,11 +1325,7 @@ namespace xsimd
13251325
}
13261326

13271327
// sadd
1328-
template <class A>
1329-
inline batch<float, A> sadd(batch<float, A> const& self, batch<float, A> const& other, requires_arch<sse2>) noexcept
1330-
{
1331-
return _mm_add_ps(self, other); // no saturated arithmetic on floating point numbers
1332-
}
1328+
13331329
// TODO: move this in xsimd_generic
13341330
namespace detail
13351331
{
@@ -1386,11 +1382,6 @@ namespace xsimd
13861382
}
13871383
}
13881384
}
1389-
template <class A>
1390-
inline batch<double, A> sadd(batch<double, A> const& self, batch<double, A> const& other, requires_arch<sse2>) noexcept
1391-
{
1392-
return _mm_add_pd(self, other); // no saturated arithmetic on floating point numbers
1393-
}
13941385

13951386
// set
13961387
template <class A, class... Values>
@@ -1449,11 +1440,6 @@ namespace xsimd
14491440
}
14501441

14511442
// ssub
1452-
template <class A>
1453-
inline batch<float, A> ssub(batch<float, A> const& self, batch<float, A> const& other, requires_arch<sse2>) noexcept
1454-
{
1455-
return _mm_sub_ps(self, other); // no saturated arithmetic on floating point numbers
1456-
}
14571443
// TODO: move this in xsimd_generic
14581444
namespace detail
14591445
{
@@ -1507,12 +1493,6 @@ namespace xsimd
15071493
}
15081494
}
15091495

1510-
template <class A>
1511-
inline batch<double, A> ssub(batch<double, A> const& self, batch<double, A> const& other, requires_arch<sse2>) noexcept
1512-
{
1513-
return _mm_sub_pd(self, other); // no saturated arithmetic on floating point numbers
1514-
}
1515-
15161496
// store_aligned
15171497
template <class A>
15181498
inline void store_aligned(float* mem, batch<float, A> const& self, requires_arch<sse2>) noexcept

include/xsimd/types/xsimd_api.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,7 @@ namespace xsimd
16841684
* @return the result of the saturated addition.
16851685
*/
16861686
template <class T, class A>
1687-
inline auto sadd(batch<T, A> const& x, batch<T, A> const& y) noexcept -> decltype(x + y)
1687+
inline batch<T, A> sadd(batch<T, A> const& x, batch<T, A> const& y) noexcept
16881688
{
16891689
detail::static_check_supported_config<T, A>();
16901690
return kernel::sadd<A>(x, y, A {});
@@ -1884,7 +1884,7 @@ namespace xsimd
18841884
* @return the result of the saturated difference.
18851885
*/
18861886
template <class T, class A>
1887-
inline auto ssub(batch<T, A> const& x, batch<T, A> const& y) noexcept -> decltype(x - y)
1887+
inline batch<T, A> ssub(batch<T, A> const& x, batch<T, A> const& y) noexcept
18881888
{
18891889
detail::static_check_supported_config<T, A>();
18901890
return kernel::ssub<A>(x, y, A {});

test/test_batch.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ struct batch_test
250250

251251
void test_saturated_arithmetic() const
252252
{
253-
#ifdef T
254253
// batch + batch
255254
{
256255
array_type expected;
@@ -259,6 +258,7 @@ struct batch_test
259258
INFO("sadd(batch, batch)");
260259
CHECK_BATCH_EQ(res, expected);
261260
}
261+
#if 0
262262
// batch + scalar
263263
{
264264
array_type expected;
@@ -271,6 +271,7 @@ struct batch_test
271271
INFO("sadd(scalar, batch)");
272272
CHECK_BATCH_EQ(rres, expected);
273273
}
274+
#endif
274275
// batch - batch
275276
{
276277
array_type expected;
@@ -280,6 +281,7 @@ struct batch_test
280281
INFO("ssub(batch, batch)");
281282
CHECK_BATCH_EQ(res, expected);
282283
}
284+
#if 0
283285
// batch - scalar
284286
{
285287
array_type expected;

0 commit comments

Comments
 (0)