Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:25:42

0001 /*  This file is part of the Vc library. {{{
0002 Copyright © 2016 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_SCALAR_DETAIL_H_
0029 #define VC_SCALAR_DETAIL_H_
0030 
0031 #include "../common/detail.h"
0032 #include "macros.h"
0033 
0034 namespace Vc_VERSIONED_NAMESPACE
0035 {
0036 namespace Detail
0037 {
0038 //InterleaveImpl{{{1
0039 template<typename V, size_t Size, size_t VSize> struct InterleaveImpl;
0040 template<typename V, size_t VSize> struct InterleaveImpl<V, 1, VSize> {
0041     template <typename I>  // interleave 2 args {{{2
0042     static inline void interleave(typename V::EntryType *const data, const I &i,
0043                                   const typename V::AsArg v0, const typename V::AsArg v1)
0044     {
0045         data[i[0] + 0] = v0.data();
0046         data[i[0] + 1] = v1.data();
0047     }
0048     template <typename I>  // interleave 3 args {{{2
0049     static inline void interleave(typename V::EntryType *const data, const I &i,
0050                                   const typename V::AsArg v0, const typename V::AsArg v1,
0051                                   const typename V::AsArg v2)
0052     {
0053         data[i[0] + 0] = v0.data();
0054         data[i[0] + 1] = v1.data();
0055         data[i[0] + 2] = v2.data();
0056     }
0057     template <typename I>  // interleave 4 args {{{2
0058     static inline void interleave(typename V::EntryType *const data, const I &i,
0059                                   const typename V::AsArg v0, const typename V::AsArg v1,
0060                                   const typename V::AsArg v2, const typename V::AsArg v3)
0061     {
0062         data[i[0] + 0] = v0.data();
0063         data[i[0] + 1] = v1.data();
0064         data[i[0] + 2] = v2.data();
0065         data[i[0] + 3] = v3.data();
0066     }
0067     template <typename I>  // interleave 5 args {{{2
0068     static inline void interleave(typename V::EntryType *const data, const I &i,
0069                                   const typename V::AsArg v0, const typename V::AsArg v1,
0070                                   const typename V::AsArg v2, const typename V::AsArg v3,
0071                                   const typename V::AsArg v4)
0072     {
0073         interleave(data, i, v0, v1, v2, v3);
0074         data[i[0] + 4] = v4.data();
0075     }
0076     template <typename I>  // interleave 6 args {{{2
0077     static inline void interleave(typename V::EntryType *const data, const I &i,
0078                                   const typename V::AsArg v0, const typename V::AsArg v1,
0079                                   const typename V::AsArg v2, const typename V::AsArg v3,
0080                                   const typename V::AsArg v4, const typename V::AsArg v5)
0081     {
0082         interleave(data, i, v0, v1, v2, v3);
0083         interleave(data + 4, i, v4, v5);
0084     }
0085     template <typename I>  // interleave 7 args {{{2
0086     static inline void interleave(typename V::EntryType *const data, const I &i,
0087                                   const typename V::AsArg v0, const typename V::AsArg v1,
0088                                   const typename V::AsArg v2, const typename V::AsArg v3,
0089                                   const typename V::AsArg v4, const typename V::AsArg v5,
0090                                   const typename V::AsArg v6)
0091     {
0092         interleave(data, i, v0, v1, v2, v3);
0093         interleave(data + 4, i, v4, v5, v6);
0094     }
0095     template <typename I>  // interleave 8 args {{{2
0096     static inline void interleave(typename V::EntryType *const data, const I &i,
0097                                   const typename V::AsArg v0, const typename V::AsArg v1,
0098                                   const typename V::AsArg v2, const typename V::AsArg v3,
0099                                   const typename V::AsArg v4, const typename V::AsArg v5,
0100                                   const typename V::AsArg v6, const typename V::AsArg v7)
0101     {
0102         interleave(data, i, v0, v1, v2, v3);
0103         interleave(data + 4, i, v4, v5, v6, v7);
0104     }
0105     //}}}2
0106     template <typename I>  // deinterleave 2 args{{{2
0107     static inline void deinterleave(typename V::EntryType const *const data, const I &i,
0108                                     V &v0, V &v1)
0109     {
0110         v0.data() = data[i[0] + 0];
0111         v1.data() = data[i[0] + 1];
0112     }
0113     template <typename I>  // deinterleave 3 args{{{2
0114     static inline void deinterleave(typename V::EntryType const *const data, const I &i,
0115                                     V &v0, V &v1, V &v2)
0116     {
0117         v0.data() = data[i[0] + 0];
0118         v1.data() = data[i[0] + 1];
0119         v2.data() = data[i[0] + 2];
0120     }
0121     template <typename I>  // deinterleave 4 args{{{2
0122     static inline void deinterleave(typename V::EntryType const *const data, const I &i,
0123                                     V &v0, V &v1, V &v2, V &v3)
0124     {
0125         v0.data() = data[i[0] + 0];
0126         v1.data() = data[i[0] + 1];
0127         v2.data() = data[i[0] + 2];
0128         v3.data() = data[i[0] + 3];
0129     }
0130     template <typename I>  // deinterleave 5 args{{{2
0131     static inline void deinterleave(typename V::EntryType const *const data, const I &i,
0132                                     V &v0, V &v1, V &v2, V &v3, V &v4)
0133     {
0134         deinterleave(data, i, v0, v1, v2, v3);
0135         v4.data() = data[i[0] + 4];
0136     }
0137     template <typename I>  // deinterleave 6 args{{{2
0138     static inline void deinterleave(typename V::EntryType const *const data, const I &i,
0139                                     V &v0, V &v1, V &v2, V &v3, V &v4, V &v5)
0140     {
0141         deinterleave(data, i, v0, v1, v2, v3);
0142         deinterleave(data + 4, i, v4, v5);
0143     }
0144     template <typename I>  // deinterleave 7 args{{{2
0145     static inline void deinterleave(typename V::EntryType const *const data, const I &i,
0146                                     V &v0, V &v1, V &v2, V &v3, V &v4, V &v5, V &v6)
0147     {
0148         deinterleave(data, i, v0, v1, v2, v3);
0149         deinterleave(data + 4, i, v4, v5, v6);
0150     }
0151     template <typename I>  // deinterleave 8 args{{{2
0152     static inline void deinterleave(typename V::EntryType const *const data, const I &i,
0153                                     V &v0, V &v1, V &v2, V &v3, V &v4, V &v5, V &v6,
0154                                     V &v7)
0155     {
0156         deinterleave(data, i, v0, v1, v2, v3);
0157         deinterleave(data + 4, i, v4, v5, v6, v7);
0158     }
0159 };
0160 //}}}1
0161 }  // namespace Detail
0162 }  // namespace Vc
0163 
0164 #endif  // VC_SCALAR_DETAIL_H_
0165 
0166 // vim: foldmethod=marker