Skip to content

Commit f96a3c6

Browse files
author
Yuqi Gu
committed
Add zip_hi/zip_lo for shuffling operations
Add zip_hi/zip_lo for shuffling operations mentioned in issues#412. Change-Id: I0244c4bbfca246636bdfd0baf03eb77fdf1b95e9 Signed-off-by: Yuqi Gu <guyuqi@apache.com>
1 parent 5b8046e commit f96a3c6

17 files changed

+196
-0
lines changed

include/xsimd/types/xsimd_base.hpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,12 @@ namespace xsimd
282282
template <class X>
283283
batch_type_t<X> select(const typename simd_batch_traits<X>::batch_bool_type& cond, const simd_base<X>& a, const simd_base<X>& b);
284284

285+
template <class X>
286+
batch_type_t<X> zip_lo(const simd_base<X>& lhs, const simd_base<X>& rhs);
287+
288+
template <class X>
289+
batch_type_t<X> zip_hi(const simd_base<X>& lhs, const simd_base<X>& rhs);
290+
285291
template <class X>
286292
typename simd_batch_traits<X>::batch_bool_type
287293
isnan(const simd_base<X>& x);
@@ -1777,6 +1783,36 @@ namespace xsimd
17771783
return kernel::select(cond, a(), b());
17781784
}
17791785

1786+
/**
1787+
* Unpack and interleave data from the LOW half of batches \c lhs and \c rhs.
1788+
* Store the results in the Return value.
1789+
* @param lhs a batch of integer or floating point or double precision values.
1790+
* @param rhs a batch of integer or floating point or double precision values.
1791+
* @return a batch of the low part of shuffled values.
1792+
*/
1793+
template <class X>
1794+
inline batch_type_t<X> zip_lo(const simd_base<X>& lhs, const simd_base<X>& rhs)
1795+
{
1796+
using value_type = typename simd_batch_traits<X>::value_type;
1797+
using kernel = detail::batch_kernel<value_type, simd_batch_traits<X>::size>;
1798+
return kernel::zip_lo(lhs(), rhs());
1799+
}
1800+
1801+
/**
1802+
* Unpack and interleave data from the HIGH half of batches \c lhs and \c rhs.
1803+
* Store the results in the Return value.
1804+
* @param lhs a batch of integer or floating point or double precision values.
1805+
* @param rhs a batch of integer or floating point or double precision values.
1806+
* @return a batch of the high part of shuffled values.
1807+
*/
1808+
template <class X>
1809+
inline batch_type_t<X> zip_hi(const simd_base<X>& lhs, const simd_base<X>& rhs)
1810+
{
1811+
using value_type = typename simd_batch_traits<X>::value_type;
1812+
using kernel = detail::batch_kernel<value_type, simd_batch_traits<X>::size>;
1813+
return kernel::zip_hi(lhs(), rhs());
1814+
}
1815+
17801816
/**
17811817
* Determines if the scalars in the given batch \c x are NaN values.
17821818
* @param x batch of floating point values.

include/xsimd/types/xsimd_neon_double.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,16 @@ namespace xsimd
580580
return vbslq_f64(cond, a, b);
581581
}
582582

583+
static batch_type zip_lo(const batch_type& lhs, const batch_type& rhs)
584+
{
585+
return vzip1q_f64(lhs, rhs);
586+
}
587+
588+
static batch_type zip_hi(const batch_type& lhs, const batch_type& rhs)
589+
{
590+
return vzip2q_f64(lhs, rhs);
591+
}
592+
583593
static batch_bool_type isnan(const batch_type& x)
584594
{
585595
return !(x == x);

include/xsimd/types/xsimd_neon_float.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,16 @@ namespace xsimd
639639
return vbslq_f32(cond, a, b);
640640
}
641641

642+
static batch_type zip_lo(const batch_type& lhs, const batch_type& rhs)
643+
{
644+
return vzip1q_f32(lhs, rhs);
645+
}
646+
647+
static batch_type zip_hi(const batch_type& lhs, const batch_type& rhs)
648+
{
649+
return vzip2q_f32(lhs, rhs);
650+
}
651+
642652
static batch_bool_type isnan(const batch_type& x)
643653
{
644654
return !(x == x);

include/xsimd/types/xsimd_neon_int16.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,16 @@ namespace xsimd
344344
{
345345
return vbslq_s16(cond, a, b);
346346
}
347+
348+
static batch_type zip_lo(const batch_type& lhs, const batch_type& rhs)
349+
{
350+
return vzip1q_s16(lhs, rhs);
351+
}
352+
353+
static batch_type zip_hi(const batch_type& lhs, const batch_type& rhs)
354+
{
355+
return vzip2q_s16(lhs, rhs);
356+
}
347357
};
348358
}
349359

include/xsimd/types/xsimd_neon_int32.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,16 @@ namespace xsimd
424424
{
425425
return vbslq_s32(cond, a, b);
426426
}
427+
428+
static batch_type zip_lo(const batch_type& lhs, const batch_type& rhs)
429+
{
430+
return vzip1q_s32(lhs, rhs);
431+
}
432+
433+
static batch_type zip_hi(const batch_type& lhs, const batch_type& rhs)
434+
{
435+
return vzip2q_s32(lhs, rhs);
436+
}
427437
};
428438
}
429439

include/xsimd/types/xsimd_neon_int64.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,16 @@ namespace xsimd
439439
{
440440
return vbslq_s64(cond, a, b);
441441
}
442+
443+
static batch_type zip_lo(const batch_type& lhs, const batch_type& rhs)
444+
{
445+
return vzip1q_s64(lhs, rhs);
446+
}
447+
448+
static batch_type zip_hi(const batch_type& lhs, const batch_type& rhs)
449+
{
450+
return vzip2q_s64(lhs, rhs);
451+
}
442452
};
443453
}
444454

include/xsimd/types/xsimd_neon_int8.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,16 @@ namespace xsimd
345345
{
346346
return vbslq_s8(cond, a, b);
347347
}
348+
349+
static batch_type zip_lo(const batch_type& lhs, const batch_type& rhs)
350+
{
351+
return vzip1q_s8(lhs, rhs);
352+
}
353+
354+
static batch_type zip_hi(const batch_type& lhs, const batch_type& rhs)
355+
{
356+
return vzip2q_s8(lhs, rhs);
357+
}
348358
};
349359
}
350360

include/xsimd/types/xsimd_neon_uint16.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,16 @@ namespace xsimd
318318
{
319319
return vbslq_u16(cond, a, b);
320320
}
321+
322+
static batch_type zip_lo(const batch_type& lhs, const batch_type& rhs)
323+
{
324+
return vzip1q_u16(lhs, rhs);
325+
}
326+
327+
static batch_type zip_hi(const batch_type& lhs, const batch_type& rhs)
328+
{
329+
return vzip2q_u16(lhs, rhs);
330+
}
321331
};
322332
}
323333

include/xsimd/types/xsimd_neon_uint32.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,16 @@ namespace xsimd
415415
{
416416
return vbslq_u32(cond, a, b);
417417
}
418+
419+
static batch_type zip_lo(const batch_type& lhs, const batch_type& rhs)
420+
{
421+
return vzip1q_u32(lhs, rhs);
422+
}
423+
424+
static batch_type zip_hi(const batch_type& lhs, const batch_type& rhs)
425+
{
426+
return vzip2q_u32(lhs, rhs);
427+
}
418428
};
419429

420430
inline batch<uint32_t, 4> shift_left(const batch<uint32_t, 4>& lhs, int32_t n)

include/xsimd/types/xsimd_neon_uint64.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,16 @@ namespace xsimd
467467
{
468468
return vbslq_u64(cond, a, b);
469469
}
470+
471+
static batch_type zip_lo(const batch_type& lhs, const batch_type& rhs)
472+
{
473+
return vzip1q_u64(lhs, rhs);
474+
}
475+
476+
static batch_type zip_hi(const batch_type& lhs, const batch_type& rhs)
477+
{
478+
return vzip2q_u64(lhs, rhs);
479+
}
470480
};
471481

472482
inline batch<uint64_t, 2> shift_left(const batch<uint64_t, 2>& lhs, int32_t n)

0 commit comments

Comments
 (0)