load_packed3.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Copyright (C) 2013-2014 Povilas Kanapickas <[email protected]>
  2. Distributed under the Boost Software License, Version 1.0.
  3. (See accompanying file LICENSE_1_0.txt or copy at
  4. http://www.boost.org/LICENSE_1_0.txt)
  5. */
  6. #ifndef LIBSIMDPP_SIMDPP_CORE_LOAD_PACKED3_H
  7. #define LIBSIMDPP_SIMDPP_CORE_LOAD_PACKED3_H
  8. #ifndef LIBSIMDPP_SIMD_H
  9. #error "This file must be included through simd.h"
  10. #endif
  11. #include <simdpp/types.h>
  12. #include <simdpp/detail/insn/load_packed3.h>
  13. namespace simdpp {
  14. namespace SIMDPP_ARCH_NAMESPACE {
  15. /** Loads values packed in triplets, de-interleaves them and stores the result
  16. into three vectors.
  17. @code
  18. a = [ *(p), *(p+3), *(p+6), ... , *(p+M*3-3) ]
  19. b = [ *(p+1), *(p+4), *(p+7), ... , *(p+M*3-2) ]
  20. c = [ *(p+2), *(p+5), *(p+8), ... , *(p+M*3-1) ]
  21. @endcode
  22. Here M is the number of elements in the vector
  23. @a p must be aligned to the vector size in bytes
  24. */
  25. template<unsigned N, class V, class T> SIMDPP_INL
  26. void load_packed3(any_vec<N,V>& a, any_vec<N,V>& b, any_vec<N,V>& c,
  27. const T* p)
  28. {
  29. static_assert(!is_mask<V>::value, "Mask types can not be loaded");
  30. typename detail::get_expr_nosign<V>::type ra, rb, rc;
  31. detail::insn::i_load_packed3(ra, rb, rc, reinterpret_cast<const char*>(p));
  32. a.wrapped() = ra;
  33. b.wrapped() = rb;
  34. c.wrapped() = rc;
  35. }
  36. } // namespace SIMDPP_ARCH_NAMESPACE
  37. } // namespace simdpp
  38. #endif