store.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_STORE_H
  7. #define LIBSIMDPP_SIMDPP_CORE_STORE_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/store.h>
  13. namespace simdpp {
  14. namespace SIMDPP_ARCH_NAMESPACE {
  15. /** Stores a 128-bit or 256-bit integer vector to an aligned memory location.
  16. @par 128-bit version:
  17. @code
  18. *(p) = a[0..127]
  19. @endcode
  20. @a p must be aligned to 16 bytes.
  21. @par 256-bit version:
  22. @code
  23. *(p) = a[0..255]
  24. @endcode
  25. @a p must be aligned to 32 bytes.
  26. @icost{SSE2-SSE4.1, NEON, ALTIVEC, 2}
  27. @icost{AVX (integer vectors), 2}
  28. */
  29. template<class T, unsigned N, class V> SIMDPP_INL
  30. void store(T* p, const any_vec<N,V>& a)
  31. {
  32. static_assert(!is_mask<V>::value, "Masks can not be stored"); // FIXME: automatically convert
  33. detail::insn::i_store(reinterpret_cast<char*>(p), a.wrapped().eval());
  34. }
  35. } // namespace SIMDPP_ARCH_NAMESPACE
  36. } // namespace simdpp
  37. #endif