| 1 | /* Copyright (C) 2013-2014 Povilas Kanapickas <povilas@radix.lt> |
| 2 | |
| 3 | Distributed under the Boost Software License, Version 1.0. |
| 4 | (See accompanying file LICENSE_1_0.txt or copy at |
| 5 | http://www.boost.org/LICENSE_1_0.txt) |
| 6 | */ |
| 7 | |
| 8 | #ifndef LIBSIMDPP_SIMDPP_CORE_SPLAT_H |
| 9 | #define LIBSIMDPP_SIMDPP_CORE_SPLAT_H |
| 10 | |
| 11 | #ifndef LIBSIMDPP_SIMD_H |
| 12 | #error "This file must be included through simd.h" |
| 13 | #endif |
| 14 | |
| 15 | #include <simdpp/types.h> |
| 16 | #include <simdpp/detail/insn/splat.h> |
| 17 | #include <simdpp/detail/get_expr.h> |
| 18 | |
| 19 | namespace simdpp { |
| 20 | namespace SIMDPP_ARCH_NAMESPACE { |
| 21 | |
| 22 | /** Broadcasts the specified element to all elements. |
| 23 | |
| 24 | @code |
| 25 | r0 = a[s] |
| 26 | r1 = a[s] |
| 27 | ... |
| 28 | rN = a[s] |
| 29 | @endcode |
| 30 | |
| 31 | @par int8 |
| 32 | |
| 33 | @par 128-bit version: |
| 34 | @icost{SSE2-AVX, 5} |
| 35 | @icost{AVX2, 2} |
| 36 | |
| 37 | @par 256-bit version: |
| 38 | @icost{SSE2-AVX, 6} |
| 39 | @icost{NEON, ALTIVEC, 2} |
| 40 | |
| 41 | @par int16 |
| 42 | |
| 43 | @par 128-bit version: |
| 44 | @icost{SSE2-AVX, 5} |
| 45 | @icost{AVX2, 2} |
| 46 | |
| 47 | @par 256-bit version: |
| 48 | @icost{SSE2-AVX, 6} |
| 49 | @icost{NEON, ALTIVEC, 2} |
| 50 | |
| 51 | @par int32 |
| 52 | |
| 53 | @par 256-bit version: |
| 54 | @icost{NEON, ALTIVEC, 2} |
| 55 | |
| 56 | @par int64 |
| 57 | |
| 58 | @par 128-bit version: |
| 59 | @icost{ALTIVEC, 1-2} |
| 60 | |
| 61 | @par 256-bit version: |
| 62 | @icost{SSE2-AVX, NEON, 2} |
| 63 | @icost{ALTIVEC, 1-2} |
| 64 | |
| 65 | @par float32 |
| 66 | |
| 67 | @par 256-bit version: |
| 68 | @icost{SSE2-AVX, NEON, ALTIVEC, 2} |
| 69 | |
| 70 | @par float64 |
| 71 | |
| 72 | @par 128-bit version: |
| 73 | @novec{NEON, ALTIVEC} |
| 74 | |
| 75 | @par 256-bit version: |
| 76 | @icost{SSE2-AVX, 2} |
| 77 | @novec{NEON, ALTIVEC} |
| 78 | */ |
| 79 | template<unsigned s, unsigned N, class V> SIMDPP_INL |
| 80 | typename detail::get_expr_nomask<V>::empty |
| 81 | splat(const any_vec<N,V>& a) |
| 82 | { |
| 83 | static_assert(s < V::length, "Access out of bounds" ); |
| 84 | typename detail::get_expr_nomask<V>::type ra = a.wrapped().eval(); |
| 85 | return detail::insn::i_splat<s>(ra); |
| 86 | } |
| 87 | |
| 88 | } // namespace SIMDPP_ARCH_NAMESPACE |
| 89 | } // namespace simdpp |
| 90 | |
| 91 | #endif |
| 92 | |
| 93 | |