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