Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:25:49

0001 /*  This file is part of the Vc library. {{{
0002 Copyright © 2014-2015 Matthias Kretz <kretz@kde.org>
0003 
0004 Redistribution and use in source and binary forms, with or without
0005 modification, are permitted provided that the following conditions are met:
0006     * Redistributions of source code must retain the above copyright
0007       notice, this list of conditions and the following disclaimer.
0008     * Redistributions in binary form must reproduce the above copyright
0009       notice, this list of conditions and the following disclaimer in the
0010       documentation and/or other materials provided with the distribution.
0011     * Neither the names of contributing organizations nor the
0012       names of its contributors may be used to endorse or promote products
0013       derived from this software without specific prior written permission.
0014 
0015 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
0016 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
0017 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
0018 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
0019 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
0020 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
0021 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
0022 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0023 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
0024 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0025 
0026 }}}*/
0027 
0028 #ifndef VC_COMMON_SIMDARRAYFWD_H_
0029 #define VC_COMMON_SIMDARRAYFWD_H_
0030 
0031 #include "../scalar/types.h"
0032 #include "../sse/types.h"
0033 #include "../avx/types.h"
0034 
0035 #include "utility.h"
0036 #include "macros.h"
0037 
0038 namespace Vc_VERSIONED_NAMESPACE
0039 {
0040 // specialization of Vector for fixed_size<N> {{{
0041 template <class T, int N>
0042 class Vector<T, simd_abi::fixed_size<N>> : public SimdArray<T, N>
0043 {
0044     using SimdArray<T, N>::SimdArray;
0045 
0046 public:
0047     // overload copy to force argument passing via the stack. This makes the type more
0048     // usable on ABI boundaries
0049     Vc_INTRINSIC Vector(const Vector &x) : SimdArray<T, N>(x) {}
0050     Vc_INTRINSIC Vector &operator=(const Vector &x)
0051     {
0052         SimdArray<T, N>::operator=(x);
0053         return *this;
0054     }
0055     Vector() = default;
0056 
0057     using abi_type = simd_abi::fixed_size<N>;
0058     using abi = abi_type;
0059 
0060     Vc_DEPRECATED("use Vector([](int n) { return n; }) instead of "
0061                   "Vector::IndexesFromZero()") static Vector IndexesFromZero()
0062     {
0063         return Vector([](size_t i) -> T { return i; });
0064     }
0065     Vc_DEPRECATED("use 0 instead of Vector::Zero()") static Vector Zero() { return 0; }
0066     Vc_DEPRECATED("use 1 instead of Vector::One()") static Vector One() { return 1; }
0067 };
0068 
0069 template <class T, int N>
0070 class Mask<T, simd_abi::fixed_size<N>> : public SimdMaskArray<T, N>
0071 {
0072     using SimdMaskArray<T, N>::SimdMaskArray;
0073 
0074 public:
0075     // overload copy to force argument passing via the stack. This makes the type more
0076     // usable on ABI boundaries
0077     Vc_INTRINSIC Mask(const Mask &x) : SimdMaskArray<T, N>(x) {}
0078     Vc_INTRINSIC Mask &operator=(const Mask &x)
0079     {
0080         SimdMaskArray<T, N>::operator=(x);
0081         return *this;
0082     }
0083     Mask() = default;
0084 
0085     using abi_type = simd_abi::fixed_size<N>;
0086     using abi = abi_type;
0087 };
0088 // }}}
0089 
0090 /** \internal
0091  * Simple traits for SimdArray to easily access internal types of non-atomic SimdArray
0092  * types.
0093  */
0094 template <typename T, std::size_t N> struct SimdArrayTraits {
0095     static constexpr std::size_t N0 = Common::left_size<N>();
0096     static constexpr std::size_t N1 = Common::right_size<N>();
0097 
0098     using storage_type0 = fixed_size_simd<T, N0>;
0099     using storage_type1 = fixed_size_simd<T, N1>;
0100 };
0101 
0102 template <typename T, std::size_t N, typename VectorType, std::size_t VectorSize>
0103 Vc_INTRINSIC_L typename SimdArrayTraits<T, N>::storage_type0 &internal_data0(
0104     SimdArray<T, N, VectorType, VectorSize> &x) Vc_INTRINSIC_R;
0105 template <typename T, std::size_t N, typename VectorType, std::size_t VectorSize>
0106 Vc_INTRINSIC_L typename SimdArrayTraits<T, N>::storage_type1 &internal_data1(
0107     SimdArray<T, N, VectorType, VectorSize> &x) Vc_INTRINSIC_R;
0108 template <typename T, std::size_t N, typename VectorType, std::size_t VectorSize>
0109 Vc_INTRINSIC_L const typename SimdArrayTraits<T, N>::storage_type0 &internal_data0(
0110     const SimdArray<T, N, VectorType, VectorSize> &x) Vc_INTRINSIC_R;
0111 template <typename T, std::size_t N, typename VectorType, std::size_t VectorSize>
0112 Vc_INTRINSIC_L const typename SimdArrayTraits<T, N>::storage_type1 &internal_data1(
0113     const SimdArray<T, N, VectorType, VectorSize> &x) Vc_INTRINSIC_R;
0114 
0115 template <typename T, std::size_t N, typename V>
0116 Vc_INTRINSIC_L V &internal_data(SimdArray<T, N, V, N> &x) Vc_INTRINSIC_R;
0117 template <typename T, std::size_t N, typename V>
0118 Vc_INTRINSIC_L const V &internal_data(const SimdArray<T, N, V, N> &x) Vc_INTRINSIC_R;
0119 
0120 namespace Traits
0121 {
0122 // is_fixed_size_simd {{{1
0123 template <class T> struct is_fixed_size_simd : std::false_type {
0124 };
0125 template <class T, int N>
0126 struct is_fixed_size_simd<fixed_size_simd<T, N>> : std::true_type {
0127 };
0128 template <class T, int N>
0129 struct is_fixed_size_simd<fixed_size_simd_mask<T, N>> : std::true_type {
0130 };
0131 
0132 // is_simd_vector_internal {{{1
0133 template <class T, int N>
0134 struct is_simd_vector_internal<fixed_size_simd<T, N>> : is_valid_vector_argument<T> {};
0135 
0136 // is_simd_mask_internal {{{1
0137 template <class T, int N>
0138 struct is_simd_mask_internal<fixed_size_simd_mask<T, N>> : is_valid_vector_argument<T> {};
0139 
0140 // is_atomic_simdarray_internal {{{1
0141 template <typename T, std::size_t N, typename V>
0142 struct is_atomic_simdarray_internal<SimdArray<T, N, V, N>> : is_valid_vector_argument<T> {};
0143 template <typename T, int N>
0144 struct is_atomic_simdarray_internal<fixed_size_simd<T, N>>
0145     : is_atomic_simdarray_internal<SimdArray<T, N>> {
0146 };
0147 
0148 // is_atomic_simd_mask_array_internal {{{1
0149 template <typename T, std::size_t N, typename V>
0150 struct is_atomic_simd_mask_array_internal<SimdMaskArray<T, N, V, N>>
0151     : is_valid_vector_argument<T> {
0152 };
0153 template <typename T, int N>
0154 struct is_atomic_simd_mask_array_internal<fixed_size_simd_mask<T, N>>
0155     : is_atomic_simd_mask_array_internal<SimdMaskArray<T, N>> {
0156 };
0157 
0158 // is_simdarray_internal {{{1
0159 template <typename T, std::size_t N, typename VectorType, std::size_t M>
0160 struct is_simdarray_internal<SimdArray<T, N, VectorType, M>>
0161     : is_valid_vector_argument<T> {
0162 };
0163 template <typename T, int N>
0164 struct is_simdarray_internal<fixed_size_simd<T, N>> : is_valid_vector_argument<T> {
0165 };
0166 
0167 // is_simd_mask_array_internal {{{1
0168 template <typename T, std::size_t N, typename VectorType, std::size_t M>
0169 struct is_simd_mask_array_internal<SimdMaskArray<T, N, VectorType, M>>
0170     : is_valid_vector_argument<T> {
0171 };
0172 template <typename T, int N>
0173 struct is_simd_mask_array_internal<fixed_size_simd_mask<T, N>>
0174     : is_valid_vector_argument<T> {
0175 };
0176 
0177 // is_integral_internal {{{1
0178 template <typename T, std::size_t N, typename V, std::size_t M>
0179 struct is_integral_internal<SimdArray<T, N, V, M>, false> : std::is_integral<T> {
0180 };
0181 
0182 // is_floating_point_internal {{{1
0183 template <typename T, std::size_t N, typename V, std::size_t M>
0184 struct is_floating_point_internal<SimdArray<T, N, V, M>, false>
0185     : std::is_floating_point<T> {
0186 };
0187 
0188 // is_signed_internal {{{1
0189 template <typename T, std::size_t N, typename V, std::size_t M>
0190 struct is_signed_internal<SimdArray<T, N, V, M>, false> : std::is_signed<T> {
0191 };
0192 
0193 // is_unsigned_internal {{{1
0194 template <typename T, std::size_t N, typename V, std::size_t M>
0195 struct is_unsigned_internal<SimdArray<T, N, V, M>, false> : std::is_unsigned<T> {
0196 };
0197 
0198 // has_no_allocated_data_impl {{{1
0199 template <typename T, std::size_t N>
0200 struct has_no_allocated_data_impl<Vc::SimdArray<T, N>> : std::true_type {
0201 };
0202 
0203 // }}}1
0204 }  // namespace Traits
0205 
0206 }  // namespace Vc
0207 
0208 #endif  // VC_COMMON_SIMDARRAYFWD_H_
0209 
0210 // vim: foldmethod=marker