Skip to content

Commit 4db420e

Browse files
Altivec support extension
Add support for ceil, floor, round, trunc, fma and fms.
1 parent ff06802 commit 4db420e

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

include/xsimd/arch/xsimd_altivec.hpp

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,13 @@ namespace xsimd
221221
return vec_splats(val);
222222
}
223223

224+
// ceil
225+
template <class A, class T, class = typename std::enable_if<std::is_floating_point<T>::value, void>::type>
226+
XSIMD_INLINE batch<T, A> ceil(batch<T, A> const& self, requires_arch<altivec>) noexcept
227+
{
228+
return vec_ceil(self.data);
229+
}
230+
224231
// store_complex
225232
namespace detail
226233
{
@@ -294,6 +301,32 @@ namespace xsimd
294301
}
295302
}
296303

304+
// fma
305+
template <class A>
306+
XSIMD_INLINE batch<float, A> fma(batch<float, A> const& x, batch<float, A> const& y, batch<float, A> const& z, requires_arch<altivec>) noexcept
307+
{
308+
return vec_madd(x.data, y.data, z.data);
309+
}
310+
311+
template <class A>
312+
XSIMD_INLINE batch<double, A> fma(batch<double, A> const& x, batch<double, A> const& y, batch<double, A> const& z, requires_arch<altivec>) noexcept
313+
{
314+
return vec_madd(x.data, y.data, z.data);
315+
}
316+
317+
// fms
318+
template <class A>
319+
XSIMD_INLINE batch<float, A> fms(batch<float, A> const& x, batch<float, A> const& y, batch<float, A> const& z, requires_arch<altivec>) noexcept
320+
{
321+
return vec_msub(x.data, y.data, z.data);
322+
}
323+
324+
template <class A>
325+
XSIMD_INLINE batch<double, A> fms(batch<double, A> const& x, batch<double, A> const& y, batch<double, A> const& z, requires_arch<altivec>) noexcept
326+
{
327+
return vec_msub(x.data, y.data, z.data);
328+
}
329+
297330
// eq
298331
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
299332
XSIMD_INLINE batch_bool<T, A> eq(batch<T, A> const& self, batch<T, A> const& other, requires_arch<altivec>) noexcept
@@ -315,6 +348,13 @@ namespace xsimd
315348
return vec_extract(self.data, 0);
316349
}
317350

351+
// floor
352+
template <class A, class T, class = typename std::enable_if<std::is_floating_point<T>::value, void>::type>
353+
XSIMD_INLINE batch<T, A> floor(batch<T, A> const& self, requires_arch<altivec>) noexcept
354+
{
355+
return vec_floor(self.data);
356+
}
357+
318358
// ge
319359
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
320360
XSIMD_INLINE batch_bool<T, A> ge(batch<T, A> const& self, batch<T, A> const& other, requires_arch<altivec>) noexcept
@@ -445,7 +485,6 @@ namespace xsimd
445485
XSIMD_INLINE batch<T, A> mul(batch<T, A> const& self, batch<T, A> const& other, requires_arch<altivec>) noexcept
446486
{
447487
return self.data * other.data;
448-
// return vec_mul(self.data, other.data);
449488
}
450489

451490
// neg
@@ -523,6 +562,13 @@ namespace xsimd
523562
return hadd(self, common {});
524563
}
525564

565+
// round
566+
template <class A, class T, class = typename std::enable_if<std::is_floating_point<T>::value, void>::type>
567+
XSIMD_INLINE batch<T, A> round(batch<T, A> const& self, requires_arch<altivec>) noexcept
568+
{
569+
return vec_round(self.data);
570+
}
571+
526572
// rsqrt
527573
template <class A>
528574
XSIMD_INLINE batch<float, A> rsqrt(batch<float, A> const& val, requires_arch<altivec>) noexcept
@@ -778,6 +824,13 @@ namespace xsimd
778824
return bitwise_cast<int16_t>(swizzle(bitwise_cast<uint16_t>(self), mask, altivec {}));
779825
}
780826

827+
// trunc
828+
template <class A, class T, class = typename std::enable_if<std::is_floating_point<T>::value, void>::type>
829+
XSIMD_INLINE batch<T, A> trunc(batch<T, A> const& self, requires_arch<altivec>) noexcept
830+
{
831+
return vec_trunc(self.data);
832+
}
833+
781834
// zip_hi
782835
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
783836
XSIMD_INLINE batch<T, A> zip_hi(batch<T, A> const& self, batch<T, A> const& other, requires_arch<altivec>) noexcept

0 commit comments

Comments
 (0)