simd.h 15.5 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
 *  This file is part of the MR utility library.
 *
 *  This code is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This code is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this code; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

19
/* Copyright (C) 2019-2020 Max-Planck-Society
20
21
22
23
24
25
26
27
   Author: Martin Reinecke */

#ifndef MRUTIL_SIMD_H
#define MRUTIL_SIMD_H

// only enable SIMD support for gcc>=5.0 and clang>=5.0
#ifndef MRUTIL_NO_SIMD
#define MRUTIL_NO_SIMD
Martin Reinecke's avatar
fixes    
Martin Reinecke committed
28
29
30
31
#if defined(__clang__)
// AppleClang has their own version numbering
#ifdef __apple_build_version__
#  if (__clang_major__ > 9) || (__clang_major__ == 9 && __clang_minor__ >= 1)
32
33
34
35
#     undef MRUTIL_NO_SIMD
#  endif
#elif __clang_major__ >= 5
#  undef MRUTIL_NO_SIMD
36
37
38
39
40
41
42
43
44
45
#endif
#elif defined(__GNUC__)
#if __GNUC__>=5
#undef MRUTIL_NO_SIMD
#endif
#endif
#endif

#include <cstdlib>
#include <cmath>
46
#include <algorithm>
47
#ifndef MRUTIL_NO_SIMD
48
#include <x86intrin.h>
49
#endif
50

Martin Reinecke's avatar
Martin Reinecke committed
51
namespace mr {
52
53
54

namespace detail_simd {

Martin Reinecke's avatar
Martin Reinecke committed
55
56
57
58
template<typename T> T myexp(T);// {return -42;}
template<> inline double myexp(double v) {return std::exp(v);}
template<> inline float myexp(float v) {return std::exp(v);}

Martin Reinecke's avatar
Martin Reinecke committed
59
60
61
62
63
64
65
66
67
68
69
template<typename T> constexpr inline bool vectorizable = false;
template<> constexpr inline bool vectorizable<float> = true;
template<> constexpr inline bool vectorizable<double> = true;
template<> constexpr inline bool vectorizable<int8_t> = true;
template<> constexpr inline bool vectorizable<uint8_t> = true;
template<> constexpr inline bool vectorizable<int16_t> = true;
template<> constexpr inline bool vectorizable<uint16_t> = true;
template<> constexpr inline bool vectorizable<int32_t> = true;
template<> constexpr inline bool vectorizable<uint32_t> = true;
template<> constexpr inline bool vectorizable<int64_t> = true;
template<> constexpr inline bool vectorizable<uint64_t> = true;
Martin Reinecke's avatar
Martin Reinecke committed
70
71
72
73

template<typename T, size_t reglen> constexpr size_t vlen
  = vectorizable<T> ? reglen/sizeof(T) : 1;

Martin Reinecke's avatar
Martin Reinecke committed
74
75
76
77
78
79
80
template<typename T, size_t len> class helper_;
template<typename T, size_t len> struct vmask_
  {
  private:
    using hlp = helper_<T, len>;
    using Tm = typename hlp::Tm;
    Tm v;
81

Martin Reinecke's avatar
Martin Reinecke committed
82
83
84
85
86
  public:
    vmask_() = default;
    vmask_(const vmask_ &other) = default;
    vmask_(Tm v_): v(v_) {}
    operator Tm() const  { return v; }
Martin Reinecke's avatar
fixes    
Martin Reinecke committed
87
    size_t bits() const { return hlp::maskbits(v); }
Martin Reinecke's avatar
Martin Reinecke committed
88
89
    vmask_ operator& (const vmask_ &other) const { return hlp::mask_and(v,other.v); }
  };
90

Martin Reinecke's avatar
Martin Reinecke committed
91
template<typename T, size_t len> class vtp
92
  {
Martin Reinecke's avatar
Martin Reinecke committed
93
94
95
  private:
    using hlp = helper_<T, len>;

96
  public:
Martin Reinecke's avatar
Martin Reinecke committed
97
98
99
    using Tv = typename hlp::Tv;
    using Tm = vmask_<T, len>;
    static constexpr size_t size() { return len; }
100

Martin Reinecke's avatar
Martin Reinecke committed
101
102
  private:
    Tv v;
103
104
105

  public:
    vtp () = default;
Martin Reinecke's avatar
Martin Reinecke committed
106
107
    vtp(T other): vtp(hlp::from_scalar(other)) {}
    vtp(const Tv &other) : v(other) {}
108
    vtp(const vtp &other) = default;
Martin Reinecke's avatar
Martin Reinecke committed
109
110
    vtp &operator=(const T &other) { v=hlp::from_scalar(other); return *this; }
    operator Tv() const { return v; }
111
112
113
114
115
116
117
118
119
    vtp operator-() const { return vtp(-v); }
    vtp operator+(vtp other) const { return vtp(v+other.v); }
    vtp operator-(vtp other) const { return vtp(v-other.v); }
    vtp operator*(vtp other) const { return vtp(v*other.v); }
    vtp operator/(vtp other) const { return vtp(v/other.v); }
    vtp &operator+=(vtp other) { v+=other.v; return *this; }
    vtp &operator-=(vtp other) { v-=other.v; return *this; }
    vtp &operator*=(vtp other) { v*=other.v; return *this; }
    vtp &operator/=(vtp other) { v/=other.v; return *this; }
Martin Reinecke's avatar
Martin Reinecke committed
120
    vtp abs() const { return hlp::abs(v); }
Martin Reinecke's avatar
Martin Reinecke committed
121
122
123
124
125
126
127
    template<typename Func> vtp apply(Func func) const
      {
      vtp res;
      for (size_t i=0; i<len; ++i)
        res[i] = func(v[i]);
      return res;
      }
128
    inline vtp sqrt() const
Martin Reinecke's avatar
Martin Reinecke committed
129
      { return hlp::sqrt(v); }
130
    vtp max(const vtp &other) const
Martin Reinecke's avatar
Martin Reinecke committed
131
132
133
134
135
136
137
138
139
      { return hlp::max(v, other.v); }
    Tm operator>(const vtp &other) const
      { return hlp::gt(v, other.v); }
    Tm operator>=(const vtp &other) const
      { return hlp::ge(v, other.v); }
    Tm operator<(const vtp &other) const
      { return hlp::lt(v, other.v); }
    Tm operator!=(const vtp &other) const
      { return hlp::ne(v, other.v); }
140
141
142
143
144
145
146

    class reference
      {
      private:
        vtp &v;
        size_t i;
      public:
Martin Reinecke's avatar
Martin Reinecke committed
147
        reference (vtp<T, len> &v_, size_t i_)
148
149
150
151
152
153
154
155
          : v(v_), i(i_) {}
        reference &operator= (T other)
          { v.v[i] = other; return *this; }
        reference &operator*= (T other)
          { v.v[i] *= other; return *this; }
        operator T() const { return v.v[i]; }
      };

Martin Reinecke's avatar
Martin Reinecke committed
156
157
158
    reference operator[](size_t i) { return reference(*this, i); }
    T operator[](size_t i) const { return v[i]; }

159
160
161
162
    class where_expr
      {
      private:
        vtp &v;
Martin Reinecke's avatar
Martin Reinecke committed
163
164
        Tm m;

165
      public:
Martin Reinecke's avatar
Martin Reinecke committed
166
        where_expr (Tm m_, vtp &v_)
167
168
          : v(v_), m(m_) {}
        where_expr &operator*= (const vtp &other)
Martin Reinecke's avatar
Martin Reinecke committed
169
          { v=hlp::blend(m, v.v*other.v, v.v); return *this; }
170
        where_expr &operator+= (const vtp &other)
Martin Reinecke's avatar
Martin Reinecke committed
171
          { v=hlp::blend(m, v.v+other.v, v.v); return *this; }
172
        where_expr &operator-= (const vtp &other)
Martin Reinecke's avatar
Martin Reinecke committed
173
          { v=hlp::blend(m, v.v-other.v, v.v); return *this; }
174
175
      };
  };
Martin Reinecke's avatar
Martin Reinecke committed
176
177
template<typename T, size_t len> inline vtp<T, len> abs(vtp<T, len> v) { return v.abs(); }
template<typename T, size_t len> typename vtp<T, len>::where_expr where(typename vtp<T, len>::Tm m, vtp<T, len> &v)
178
179
180
181
182
183
184
185
186
187
188
  { return typename vtp<T, len>::where_expr(m, v); }
template<typename T0, typename T, size_t len> vtp<T, len> operator*(T0 a, vtp<T, len> b)
  { return b*a; }
template<typename T, size_t len> vtp<T, len> operator+(T a, vtp<T, len> b)
  { return b+a; }
template<typename T, size_t len> vtp<T, len> operator-(T a, vtp<T, len> b)
  { return vtp<T, len>(a) - b; }
template<typename T, size_t len> vtp<T, len> max(vtp<T, len> a, vtp<T, len> b)
  { return a.max(b); }
template<typename T, size_t len> vtp<T, len> sqrt(vtp<T, len> v)
  { return v.sqrt(); }
Martin Reinecke's avatar
Martin Reinecke committed
189
190
191
192
193
template<typename T, size_t len> inline bool any_of(const vmask_<T, len> &mask)
  { return mask.bits()!=0; }
template<typename T, size_t len> inline bool none_of(const vmask_<T, len> &mask)
  { return mask.bits()==0; }
template<typename T, size_t len> inline bool all_of(const vmask_<T, len> &mask)
Martin Reinecke's avatar
fixes    
Martin Reinecke committed
194
  { return mask.bits()==(size_t(1)<<len)-1; }
195
196
197
198
199
200
201
template<typename Op, typename T, size_t len> T reduce(const vtp<T, len> &v, Op op)
  {
  T res=v[0];
  for (size_t i=1; i<len; ++i)
    res = op(res, v[i]);
  return res;
  }
Martin Reinecke's avatar
Martin Reinecke committed
202
203
template<typename T, size_t len> vtp<T, len> exp(const vtp<T, len> &v)
  { return v.apply(myexp<T>); }
204
205
206
207
template<typename T> class pseudoscalar
  {
  private:
    T v;
Martin Reinecke's avatar
fixes    
Martin Reinecke committed
208

209
210
211
212
213
214
215
216
217
218
219
220
221
  public:
    pseudoscalar() = default;
    pseudoscalar(const pseudoscalar &other) = default;
    pseudoscalar(T v_):v(v_) {}
    pseudoscalar operator-() const { return pseudoscalar(-v); }
    pseudoscalar operator+(pseudoscalar other) const { return pseudoscalar(v+other.v); }
    pseudoscalar operator-(pseudoscalar other) const { return pseudoscalar(v-other.v); }
    pseudoscalar operator*(pseudoscalar other) const { return pseudoscalar(v*other.v); }
    pseudoscalar operator/(pseudoscalar other) const { return pseudoscalar(v/other.v); }
    pseudoscalar &operator+=(pseudoscalar other) { v+=other.v; return *this; }
    pseudoscalar &operator-=(pseudoscalar other) { v-=other.v; return *this; }
    pseudoscalar &operator*=(pseudoscalar other) { v*=other.v; return *this; }
    pseudoscalar &operator/=(pseudoscalar other) { v/=other.v; return *this; }
Martin Reinecke's avatar
fixes    
Martin Reinecke committed
222
223
224

    pseudoscalar abs() const { return std::abs(v); }
    inline pseudoscalar sqrt() const { return std::sqrt(v); }
225
    pseudoscalar max(const pseudoscalar &other) const
Martin Reinecke's avatar
fixes    
Martin Reinecke committed
226
227
228
229
230
231
232
233
234
235
      { return std::max(v, other.v); }

    bool operator>(const pseudoscalar &other) const
      { return v>other.v; }
    bool operator>=(const pseudoscalar &other) const
      { return v>=other.v; }
    bool operator<(const pseudoscalar &other) const
      { return v<other.v; }
    bool operator!=(const pseudoscalar &other) const
      { return v!=other.v; }
236
237
238
    const T &operator[] (size_t /*i*/) const { return v; }
    T &operator[](size_t /*i*/) { return v; }
  };
Martin Reinecke's avatar
Martin Reinecke committed
239
template<typename T> class helper_<T,1>
240
  {
Martin Reinecke's avatar
Martin Reinecke committed
241
242
243
  private:
    static constexpr size_t len = 1;
  public:
244
    using Tv = pseudoscalar<T>;
Martin Reinecke's avatar
Martin Reinecke committed
245
246
247
    using Tm = bool;

    static Tv from_scalar(T v) { return v; }
Martin Reinecke's avatar
fixes    
Martin Reinecke committed
248
249
250
251
    static Tv abs(Tv v) { return v.abs(); }
    static Tv max(Tv v1, Tv v2) { return v1.max(v2); }
    static Tv blend(Tm m, Tv v1, Tv v2) { return m ? v1 : v2; }
    static Tv sqrt(Tv v) { return v.sqrt(); }
Martin Reinecke's avatar
Martin Reinecke committed
252
253
254
255
256
257
258
259
    static Tm gt (Tv v1, Tv v2) { return v1>v2; }
    static Tm ge (Tv v1, Tv v2) { return v1>=v2; }
    static Tm lt (Tv v1, Tv v2) { return v1<v2; }
    static Tm ne (Tv v1, Tv v2) { return v1!=v2; }
    static Tm mask_and (Tm v1, Tm v2) { return v1&&v2; }
    static size_t maskbits(Tm v) { return v; }
  };

260
261
#ifndef MRUTIL_NO_SIMD

Martin Reinecke's avatar
Martin Reinecke committed
262
263
#if defined(__AVX512F__)
template<> class helper_<double,8>
264
  {
Martin Reinecke's avatar
Martin Reinecke committed
265
266
267
268
269
270
271
272
  private:
    using T = double;
    static constexpr size_t len = 8;
  public:
    using Tv = __m512d;
    using Tm = __mmask8;

    static Tv from_scalar(T v) { return _mm512_set1_pd(v); }
Martin Reinecke's avatar
Martin Reinecke committed
273
    static Tv abs(Tv v) { return __m512d(_mm512_andnot_epi64(__m512i(_mm512_set1_pd(-0.)),__m512i(v))); }
Martin Reinecke's avatar
Martin Reinecke committed
274
    static Tv max(Tv v1, Tv v2) { return _mm512_max_pd(v1, v2); }
Martin Reinecke's avatar
fixes    
Martin Reinecke committed
275
    static Tv blend(Tm m, Tv v1, Tv v2) { return _mm512_mask_blend_pd(m, v2, v1); }
Martin Reinecke's avatar
Martin Reinecke committed
276
277
278
279
280
281
282
283
    static Tv sqrt(Tv v) { return _mm512_sqrt_pd(v); }
    static Tm gt (Tv v1, Tv v2) { return _mm512_cmp_pd_mask(v1,v2,_CMP_GT_OQ); }
    static Tm ge (Tv v1, Tv v2) { return _mm512_cmp_pd_mask(v1,v2,_CMP_GE_OQ); }
    static Tm lt (Tv v1, Tv v2) { return _mm512_cmp_pd_mask(v1,v2,_CMP_LT_OQ); }
    static Tm ne (Tv v1, Tv v2) { return _mm512_cmp_pd_mask(v1,v2,_CMP_NEQ_OQ); }
    static Tm mask_and (Tm v1, Tm v2) { return v1&v2; }
    static size_t maskbits(Tm v) { return v; }
  };
Martin Reinecke's avatar
fix    
Martin Reinecke committed
284
template<> class helper_<float,16>
285
  {
Martin Reinecke's avatar
Martin Reinecke committed
286
287
  private:
    using T = float;
Martin Reinecke's avatar
fix    
Martin Reinecke committed
288
    static constexpr size_t len = 16;
Martin Reinecke's avatar
Martin Reinecke committed
289
290
  public:
    using Tv = __m512;
Martin Reinecke's avatar
fixes    
Martin Reinecke committed
291
    using Tm = __mmask16;
Martin Reinecke's avatar
Martin Reinecke committed
292
293

    static Tv from_scalar(T v) { return _mm512_set1_ps(v); }
Martin Reinecke's avatar
Martin Reinecke committed
294
    static Tv abs(Tv v) { return __m512(_mm512_andnot_epi32(__m512i(_mm512_set1_ps(-0.)),__m512i(v))); }
Martin Reinecke's avatar
Martin Reinecke committed
295
    static Tv max(Tv v1, Tv v2) { return _mm512_max_ps(v1, v2); }
Martin Reinecke's avatar
fixes    
Martin Reinecke committed
296
    static Tv blend(Tm m, Tv v1, Tv v2) { return _mm512_mask_blend_ps(m, v2, v1); }
Martin Reinecke's avatar
Martin Reinecke committed
297
298
299
300
301
302
303
304
305
    static Tv sqrt(Tv v) { return _mm512_sqrt_ps(v); }
    static Tm gt (Tv v1, Tv v2) { return _mm512_cmp_ps_mask(v1,v2,_CMP_GT_OQ); }
    static Tm ge (Tv v1, Tv v2) { return _mm512_cmp_ps_mask(v1,v2,_CMP_GE_OQ); }
    static Tm lt (Tv v1, Tv v2) { return _mm512_cmp_ps_mask(v1,v2,_CMP_LT_OQ); }
    static Tm ne (Tv v1, Tv v2) { return _mm512_cmp_ps_mask(v1,v2,_CMP_NEQ_OQ); }
    static Tm mask_and (Tm v1, Tm v2) { return v1&v2; }
    static size_t maskbits(Tm v) { return v; }
  };

Martin Reinecke's avatar
Martin Reinecke committed
306
template<typename T> using native_simd = vtp<T,vlen<T,64>>;
307
#elif defined(__AVX__)
Martin Reinecke's avatar
Martin Reinecke committed
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
template<> class helper_<double,4>
  {
  private:
    using T = double;
    static constexpr size_t len = 4;
  public:
    using Tv = __m256d;
    using Tm = __m256d;

    static Tv from_scalar(T v) { return _mm256_set1_pd(v); }
    static Tv abs(Tv v) { return _mm256_andnot_pd(_mm256_set1_pd(-0.),v); }
    static Tv max(Tv v1, Tv v2) { return _mm256_max_pd(v1, v2); }
    static Tv blend(Tm m, Tv v1, Tv v2) { return _mm256_blendv_pd(v2, v1, m); }
    static Tv sqrt(Tv v) { return _mm256_sqrt_pd(v); }
    static Tm gt (Tv v1, Tv v2) { return _mm256_cmp_pd(v1,v2,_CMP_GT_OQ); }
    static Tm ge (Tv v1, Tv v2) { return _mm256_cmp_pd(v1,v2,_CMP_GE_OQ); }
    static Tm lt (Tv v1, Tv v2) { return _mm256_cmp_pd(v1,v2,_CMP_LT_OQ); }
    static Tm ne (Tv v1, Tv v2) { return _mm256_cmp_pd(v1,v2,_CMP_NEQ_OQ); }
    static Tm mask_and (Tm v1, Tm v2) { return _mm256_and_pd(v1,v2); }
327
    static size_t maskbits(Tm v) { return size_t(_mm256_movemask_pd(v)); }
Martin Reinecke's avatar
Martin Reinecke committed
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
  };
template<> class helper_<float,8>
  {
  private:
    using T = float;
    static constexpr size_t len = 8;
  public:
    using Tv = __m256;
    using Tm = __m256;

    static Tv from_scalar(T v) { return _mm256_set1_ps(v); }
    static Tv abs(Tv v) { return _mm256_andnot_ps(_mm256_set1_ps(-0.),v); }
    static Tv max(Tv v1, Tv v2) { return _mm256_max_ps(v1, v2); }
    static Tv blend(Tm m, Tv v1, Tv v2) { return _mm256_blendv_ps(v2, v1, m); }
    static Tv sqrt(Tv v) { return _mm256_sqrt_ps(v); }
    static Tm gt (Tv v1, Tv v2) { return _mm256_cmp_ps(v1,v2,_CMP_GT_OQ); }
    static Tm ge (Tv v1, Tv v2) { return _mm256_cmp_ps(v1,v2,_CMP_GE_OQ); }
    static Tm lt (Tv v1, Tv v2) { return _mm256_cmp_ps(v1,v2,_CMP_LT_OQ); }
    static Tm ne (Tv v1, Tv v2) { return _mm256_cmp_ps(v1,v2,_CMP_NEQ_OQ); }
    static Tm mask_and (Tm v1, Tm v2) { return _mm256_and_ps(v1,v2); }
348
    static size_t maskbits(Tm v) { return size_t(_mm256_movemask_ps(v)); }
Martin Reinecke's avatar
Martin Reinecke committed
349
350
  };

Martin Reinecke's avatar
Martin Reinecke committed
351
template<typename T> using native_simd = vtp<T,vlen<T,32>>;
Martin Reinecke's avatar
Martin Reinecke committed
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
#elif defined(__SSE2__)
template<> class helper_<double,2>
  {
  private:
    using T = double;
    static constexpr size_t len = 2;
  public:
    using Tv = __m128d;
    using Tm = __m128d;

    static Tv from_scalar(T v) { return _mm_set1_pd(v); }
    static Tv abs(Tv v) { return _mm_andnot_pd(_mm_set1_pd(-0.),v); }
    static Tv max(Tv v1, Tv v2) { return _mm_max_pd(v1, v2); }
    static Tv blend(Tm m, Tv v1, Tv v2)
      {
#if defined(__SSE4_1__)
      return _mm_blendv_pd(v2,v1,m);
#else
      return _mm_or_pd(_mm_and_pd(m,v1),_mm_andnot_pd(m,v2));
371
#endif
Martin Reinecke's avatar
Martin Reinecke committed
372
373
374
375
376
377
378
      }
    static Tv sqrt(Tv v) { return _mm_sqrt_pd(v); }
    static Tm gt (Tv v1, Tv v2) { return _mm_cmpgt_pd(v1,v2); }
    static Tm ge (Tv v1, Tv v2) { return _mm_cmpge_pd(v1,v2); }
    static Tm lt (Tv v1, Tv v2) { return _mm_cmplt_pd(v1,v2); }
    static Tm ne (Tv v1, Tv v2) { return _mm_cmpneq_pd(v1,v2); }
    static Tm mask_and (Tm v1, Tm v2) { return _mm_and_pd(v1,v2); }
379
    static size_t maskbits(Tm v) { return size_t(_mm_movemask_pd(v)); }
Martin Reinecke's avatar
Martin Reinecke committed
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
  };
template<> class helper_<float,4>
  {
  private:
    using T = float;
    static constexpr size_t len = 4;
  public:
    using Tv = __m128;
    using Tm = __m128;

    static Tv from_scalar(T v) { return _mm_set1_ps(v); }
    static Tv abs(Tv v) { return _mm_andnot_ps(_mm_set1_ps(-0.),v); }
    static Tv max(Tv v1, Tv v2) { return _mm_max_ps(v1, v2); }
    static Tv blend(Tm m, Tv v1, Tv v2)
      {
#if defined(__SSE4_1__)
      return _mm_blendv_ps(v2,v1,m);
#else
      return _mm_or_ps(_mm_and_ps(m,v1),_mm_andnot_ps(m,v2));
#endif
      }
    static Tv sqrt(Tv v) { return _mm_sqrt_ps(v); }
    static Tm gt (Tv v1, Tv v2) { return _mm_cmpgt_ps(v1,v2); }
    static Tm ge (Tv v1, Tv v2) { return _mm_cmpge_ps(v1,v2); }
    static Tm lt (Tv v1, Tv v2) { return _mm_cmplt_ps(v1,v2); }
    static Tm ne (Tv v1, Tv v2) { return _mm_cmpneq_ps(v1,v2); }
    static Tm mask_and (Tm v1, Tm v2) { return _mm_and_ps(v1,v2); }
407
    static size_t maskbits(Tm v) { return size_t(_mm_movemask_ps(v)); }
Martin Reinecke's avatar
Martin Reinecke committed
408
  };
409

Martin Reinecke's avatar
Martin Reinecke committed
410
template<typename T> using native_simd = vtp<T,vlen<T,16>>;
Martin Reinecke's avatar
fixes    
Martin Reinecke committed
411
412
#else
template<typename T> using native_simd = vtp<T,1>;
Martin Reinecke's avatar
Martin Reinecke committed
413
#endif
414
415
416
#else
template<typename T> using native_simd = vtp<T,1>;
#endif
Martin Reinecke's avatar
Martin Reinecke committed
417
}
418

419
420
421
422
using detail_simd::native_simd;
using detail_simd::reduce;
using detail_simd::max;
using detail_simd::abs;
Martin Reinecke's avatar
Martin Reinecke committed
423
using detail_simd::exp;
424
425
426
427
428
429
430
using detail_simd::sqrt;
using detail_simd::any_of;
using detail_simd::none_of;
using detail_simd::all_of;
}

#endif