load_packed4.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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_PACKED4_H
  7. #define LIBSIMDPP_SIMDPP_CORE_LOAD_PACKED4_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_packed4.h>
  13. namespace simdpp {
  14. namespace SIMDPP_ARCH_NAMESPACE {
  15. /** Loads values packed in quartets, de-interleaves them and stores the result
  16. into four vectors.
  17. @code
  18. a = [ *(p), *(p+4), *(p+8), ... , *(p+M*4-4) ]
  19. b = [ *(p+1), *(p+5), *(p+9), ... , *(p+M*4-3) ]
  20. c = [ *(p+2), *(p+6), *(p+10), ... , *(p+M*4-2) ]
  21. d = [ *(p+3), *(p+7), *(p+11), ... , *(p+M*4-1) ]
  22. @endcode
  23. Here M is the number of elements in the vector
  24. @a p must be aligned to the vector size in bytes
  25. */
  26. template<unsigned N, class V, class T> SIMDPP_INL
  27. void load_packed4(any_vec<N,V>& a, any_vec<N,V>& b,
  28. any_vec<N,V>& c, any_vec<N,V>& d,
  29. const T* p)
  30. {
  31. static_assert(!is_mask<V>::value, "Mask types can not be loaded");
  32. typename detail::get_expr_nosign<V>::type ra, rb, rc, rd;
  33. detail::insn::i_load_packed4(ra, rb, rc, rd, reinterpret_cast<const char*>(p));
  34. a.wrapped() = ra;
  35. b.wrapped() = rb;
  36. c.wrapped() = rc;
  37. d.wrapped() = rd;
  38. }
  39. } // namespace SIMDPP_ARCH_NAMESPACE
  40. } // namespace simdpp
  41. #endif