| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#ifndef SIMD_TESTS_BITS_MAKE_VEC_H_ |
| 19 |
#define SIMD_TESTS_BITS_MAKE_VEC_H_ |
| 20 |
#include <experimental/simd> |
| 21 |
|
| 22 |
template <class M> |
| 23 |
inline M |
| 24 |
make_mask(const std::initializer_list<bool> &init) |
| 25 |
{ |
| 26 |
std::size_t i = 0; |
| 27 |
M r = {}; |
| 28 |
for (;;) |
| 29 |
{ |
| 30 |
for (bool x : init) |
| 31 |
{ |
| 32 |
r[i] = x; |
| 33 |
if (++i == M::size()) |
| 34 |
{ |
| 35 |
return r; |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
template <class M> |
| 42 |
M |
| 43 |
make_alternating_mask() |
| 44 |
{ |
| 45 |
return make_mask<M>({false, true}); |
| 46 |
} |
| 47 |
|
| 48 |
template <class V> |
| 49 |
inline V |
| 50 |
make_vec(const std::initializer_list<typename V::value_type> &init, |
| 51 |
typename V::value_type inc = 0) |
| 52 |
{ |
| 53 |
std::size_t i = 0; |
| 54 |
V r = {}; |
| 55 |
typename V::value_type base = 0; |
| 56 |
for (;;) |
| 57 |
{ |
| 58 |
for (auto x : init) |
| 59 |
{ |
| 60 |
r[i] = base + x; |
| 61 |
if (++i == V::size()) |
| 62 |
{ |
| 63 |
return r; |
| 64 |
} |
| 65 |
} |
| 66 |
base += inc; |
| 67 |
} |
| 68 |
} |
| 69 |
#endif |