File: vector.h

package info (click to toggle)
vc 1.4.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,552 kB
  • sloc: cpp: 19,220; ansic: 15,669; sh: 453; xml: 186; makefile: 30
file content (279 lines) | stat: -rw-r--r-- 9,143 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/*  This file is part of the Vc library. {{{
Copyright © 2009-2015 Matthias Kretz <kretz@kde.org>

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the names of contributing organizations nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

}}}*/

#ifndef VC_VECTOR_H_
#define VC_VECTOR_H_

// 1. define all of Vc::Scalar - this one is always present, so it makes sense to put it first
#include "scalar/vector.h"

#if defined(Vc_IMPL_SSE)
# include "sse/vector.h"
#endif
#ifdef Vc_IMPL_AVX
# include "avx/vector.h"
#endif

namespace Vc_VERSIONED_NAMESPACE
{
/**
 * \name Vector Type Aliases
 * \ingroup Vectors
 */
///@{
/**\addtogroup Vectors
 * @{
 */
/// vector of double precision
using double_v = Vector<double>;
/// vector of single precision
using float_v = Vector<float>;
/// vector of signed integers
using int_v = Vector<int>;
/// vector of unsigned integers
using uint_v = Vector<uint>;
/// vector of signed short integers
using short_v = Vector<short>;
/// vector of unsigned short integers
using ushort_v = Vector<ushort>;
///\internal vector of signed long long integers
using llong_v = Vector<llong>;
///\internal vector of unsigned long long integers
using ullong_v = Vector<ullong>;
///\internal vector of signed long integers
using long_v = Vector<long>;
///\internal vector of unsigned long integers
using ulong_v = Vector<ulong>;
///\internal vector of signed char-sized integers
using schar_v = Vector<schar>;
///\internal vector of unsigned char-sized integers
using uchar_v = Vector<uchar>;
///@}
///@}

/**
 * \name Mask Type Aliases
 * \ingroup Masks
 */
///@{
/**\addtogroup Masks
 * @{
 */
/// mask type for double_v vectors
using double_m = Mask<double>;
/// mask type for float_v vectors
using  float_m = Mask< float>;
///\internal mask type for llong_v vectors
using  llong_m = Mask< llong>;
///\internal mask type for ullong_v vectors
using ullong_m = Mask<ullong>;
///\internal mask type for long_v vectors
using   long_m = Mask<  long>;
///\internal mask type for ulong_v vectors
using  ulong_m = Mask< ulong>;
/// mask type for int_v vectors
using    int_m = Mask<   int>;
/// mask type for uint_v vectors
using   uint_m = Mask<  uint>;
/// mask type for short_v vectors
using  short_m = Mask< short>;
/// mask type for ushort_v vectors
using ushort_m = Mask<ushort>;
///\internal mask type for schar_v vectors
using  schar_m = Mask< schar>;
///\internal mask type for uchar_v vectors
using  uchar_m = Mask< uchar>;
///@}
///@}

  typedef Vector<std:: int_least64_t>  int_least64_v;
  typedef Vector<std::uint_least64_t> uint_least64_v;
  typedef Vector<std:: int_least32_t>  int_least32_v;
  typedef Vector<std::uint_least32_t> uint_least32_v;
  typedef Vector<std:: int_least16_t>  int_least16_v;
  typedef Vector<std::uint_least16_t> uint_least16_v;
  typedef Vector<std::  int_least8_t>   int_least8_v;
  typedef Vector<std:: uint_least8_t>  uint_least8_v;

  typedef Mask<std:: int_least64_t>  int_least64_m;
  typedef Mask<std::uint_least64_t> uint_least64_m;
  typedef Mask<std:: int_least32_t>  int_least32_m;
  typedef Mask<std::uint_least32_t> uint_least32_m;
  typedef Mask<std:: int_least16_t>  int_least16_m;
  typedef Mask<std::uint_least16_t> uint_least16_m;
  typedef Mask<std::  int_least8_t>   int_least8_m;
  typedef Mask<std:: uint_least8_t>  uint_least8_m;

  typedef Vector<std:: int_fast64_t>  int_fast64_v;
  typedef Vector<std::uint_fast64_t> uint_fast64_v;
  typedef Vector<std:: int_fast32_t>  int_fast32_v;
  typedef Vector<std::uint_fast32_t> uint_fast32_v;
  typedef Vector<std:: int_fast16_t>  int_fast16_v;
  typedef Vector<std::uint_fast16_t> uint_fast16_v;
  typedef Vector<std::  int_fast8_t>   int_fast8_v;
  typedef Vector<std:: uint_fast8_t>  uint_fast8_v;

  typedef Mask<std:: int_fast64_t>  int_fast64_m;
  typedef Mask<std::uint_fast64_t> uint_fast64_m;
  typedef Mask<std:: int_fast32_t>  int_fast32_m;
  typedef Mask<std::uint_fast32_t> uint_fast32_m;
  typedef Mask<std:: int_fast16_t>  int_fast16_m;
  typedef Mask<std::uint_fast16_t> uint_fast16_m;
  typedef Mask<std::  int_fast8_t>   int_fast8_m;
  typedef Mask<std:: uint_fast8_t>  uint_fast8_m;

#if defined INT64_MAX && defined UINT64_MAX
  typedef Vector<std:: int64_t>  int64_v;
  typedef Vector<std::uint64_t> uint64_v;
  typedef Mask<std:: int64_t>  int64_m;
  typedef Mask<std::uint64_t> uint64_m;
#endif
#if defined INT32_MAX && defined UINT32_MAX
  typedef Vector<std:: int32_t>  int32_v;
  typedef Vector<std::uint32_t> uint32_v;
  typedef Mask<std:: int32_t>  int32_m;
  typedef Mask<std::uint32_t> uint32_m;
#endif
#if defined INT16_MAX && defined UINT16_MAX
  typedef Vector<std:: int16_t>  int16_v;
  typedef Vector<std::uint16_t> uint16_v;
  typedef Mask<std:: int16_t>  int16_m;
  typedef Mask<std::uint16_t> uint16_m;
#endif
#if defined INT8_MAX && defined UINT8_MAX
  typedef Vector<std:: int8_t>  int8_v;
  typedef Vector<std::uint8_t> uint8_v;
  typedef Mask<std:: int8_t>  int8_m;
  typedef Mask<std::uint8_t> uint8_m;
#endif

  namespace {
    static_assert(double_v::Size == Vc_DOUBLE_V_SIZE, "Vc_DOUBLE_V_SIZE macro defined to an incorrect value");
    static_assert(float_v::Size  == Vc_FLOAT_V_SIZE , "Vc_FLOAT_V_SIZE macro defined to an incorrect value ");
    static_assert(int_v::Size    == Vc_INT_V_SIZE   , "Vc_INT_V_SIZE macro defined to an incorrect value   ");
    static_assert(uint_v::Size   == Vc_UINT_V_SIZE  , "Vc_UINT_V_SIZE macro defined to an incorrect value  ");
    static_assert(short_v::Size  == Vc_SHORT_V_SIZE , "Vc_SHORT_V_SIZE macro defined to an incorrect value ");
    static_assert(ushort_v::Size == Vc_USHORT_V_SIZE, "Vc_USHORT_V_SIZE macro defined to an incorrect value");
  }
}


// finally define the non-member operators
#include "common/operators.h"

#include "common/simdarray.h"
// XXX See bottom of common/simdmaskarray.h:
//#include "common/simd_cast_caller.tcc"

#include "common/alignedbase.h"
namespace Vc_VERSIONED_NAMESPACE {
/**
 * \ingroup Vectors
 *
 * Specifies the most conservative memory alignment necessary for Vector<T> objects with
 * default VectorAbi. Use this value e.g. with an \c alignas expression or when allocating
 * aligned memory dynamically (\ref Vc::malloc).
 *
 * \see Vc::MemoryAlignment
 * \see Vc::VectorAlignedBase
 */
constexpr std::size_t VectorAlignment = alignof(VectorAlignedBase);
/**
 * \ingroup Vectors
 *
 * Specifies the most conservative memory alignment necessary for aligned loads and stores
 * of Vector types. Use this value e.g. with an \c alignas expression or when allocating
 * aligned memory dynamically (\ref Vc::malloc).
 *
 * \see Vc::VectorAlignment
 * \see Vc::Vector<T, Abi>::MemoryAlignment
 */
constexpr std::size_t MemoryAlignment = alignof(MemoryAlignedBase);
} // namespace Vc_VERSIONED_NAMESPACE

#define Vc_VECTOR_DECLARED_ 1

#include "scalar/helperimpl.h"
#include "scalar/math.h"
#include "scalar/simd_cast_caller.tcc"
#if defined(Vc_IMPL_SSE)
# include "sse/helperimpl.h"
# include "sse/math.h"
# include "sse/simd_cast_caller.tcc"
#endif
#if defined(Vc_IMPL_AVX)
# include "avx/helperimpl.h"
# include "avx/math.h"
# include "avx/simd_cast_caller.tcc"
#endif

#include "common/math.h"

#ifdef isfinite
#undef isfinite
#endif
#ifdef isnan
#undef isnan
#endif

#include "common/vectortuple.h"
#include "common/where.h"
#include "common/iif.h"

#ifndef Vc_NO_STD_FUNCTIONS
namespace std
{
  using Vc::min;
  using Vc::max;

  using Vc::abs;
  using Vc::asin;
  using Vc::atan;
  using Vc::atan2;
  using Vc::ceil;
  using Vc::cos;
  using Vc::exp;
  using Vc::fma;
  using Vc::trunc;
  using Vc::floor;
  using Vc::frexp;
  using Vc::ldexp;
  using Vc::log;
  using Vc::log10;
  using Vc::log2;
  using Vc::round;
  using Vc::sin;
  using Vc::sqrt;

  using Vc::isfinite;
  using Vc::isnan;
} // namespace std
#endif

Vc_RESET_DIAGNOSTICS

#endif // VC_VECTOR_H_