Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /*  This file is part of the Vc library. {{{
0002 Copyright © 2010-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_DEINTERLEAVE_H_
0029 #define VC_COMMON_DEINTERLEAVE_H_
0030 
0031 #include "macros.h"
0032 
0033 namespace Vc_VERSIONED_NAMESPACE
0034 {
0035 
0036 /**
0037  * \ingroup Vectors
0038  *
0039  * \deprecated Turn to InterleavedMemoryWrapper for a more flexible and complete solution.
0040  *
0041  * Loads two vectors of values from an interleaved array.
0042  *
0043  * \param a, b The vectors to load the values from memory into.
0044  * \param memory The memory location where to read the next 2 * V::Size values from
0045  * \param align Either pass Vc::Aligned or Vc::Unaligned. It defaults to Vc::Aligned if nothing is
0046  * specified.
0047  *
0048  * If you store your data as
0049  * \code
0050  * struct { float x, y; } m[1000];
0051  * \endcode
0052  * then the deinterleave function allows you to read \p Size concurrent x and y values like this:
0053  * \code
0054  * Vc::float_v x, y;
0055  * Vc::deinterleave(&x, &y, &m[10], Vc::Unaligned);
0056  * \endcode
0057  * This code will load m[10], m[12], m[14], ... into \p x and m[11], m[13], m[15], ... into \p y.
0058  *
0059  * The deinterleave function supports the following type combinations:
0060 \verbatim
0061   V \  M | float | double | ushort | short | uint | int
0062 =========|=======|========|========|=======|======|=====
0063  float_v |   X   |        |    X   |   X   |      |
0064 ---------|-------|--------|--------|-------|------|-----
0065 double_v |       |    X   |        |       |      |
0066 ---------|-------|--------|--------|-------|------|-----
0067    int_v |       |        |        |   X   |      |  X
0068 ---------|-------|--------|--------|-------|------|-----
0069   uint_v |       |        |    X   |       |   X  |
0070 ---------|-------|--------|--------|-------|------|-----
0071  short_v |       |        |        |   X   |      |
0072 ---------|-------|--------|--------|-------|------|-----
0073 ushort_v |       |        |    X   |       |      |
0074 \endverbatim
0075  */
0076 template<typename V, typename M, typename A> Vc_ALWAYS_INLINE void deinterleave(V *a, V *b,
0077         const M *memory, A align)
0078 {
0079     Detail::deinterleave(*a, *b, memory, align);
0080 }
0081 
0082 // documented as default for align above
0083 template<typename V, typename M> Vc_ALWAYS_INLINE void deinterleave(V *a, V *b,
0084         const M *memory)
0085 {
0086     Detail::deinterleave(*a, *b, memory, Aligned);
0087 }
0088 
0089 }  // namespace Vc
0090 
0091 #endif // VC_COMMON_DEINTERLEAVE_H_