dune-common 2.8.0
Loading...
Searching...
No Matches
io.hh
Go to the documentation of this file.
1#ifndef DUNE_COMMON_SIMD_IO_HH
2#define DUNE_COMMON_SIMD_IO_HH
3
14#include <ios>
15#include <type_traits>
16
20
21namespace Dune {
22
23 namespace SimdImpl {
24
25 template<class T>
26 class Inserter {
27 T value_;
28
29 public:
30 Inserter(const T &value) : value_(value) {}
31
32 template<class Stream,
34 Stream>::value> >
35 friend Stream& operator<<(Stream &out, const Inserter &ins)
36 {
37 const char *sep = "<";
38 for(auto l : range(Simd::lanes(ins.value_)))
39 {
40 out << sep << autoCopy(Simd::lane(l, ins.value_));
41 sep = ", ";
42 }
43 out << '>';
44 return out;
45 }
46 };
47
48 template<class V, class = std::enable_if_t<Simd::lanes<V>() != 1> >
49 Inserter<V> io(const V &v)
50 {
51 return { v };
52 }
53
54 template<class V, class = std::enable_if_t<Simd::lanes<V>() == 1> >
55 Simd::Scalar<V> io(const V &v)
56 {
57 return Simd::lane(0, v);
58 }
59
60 }
61
62 namespace Simd {
63
80
87 template<class V>
88 auto vio(const V &v)
89 {
90 return SimdImpl::Inserter<V>{ v };
91 }
92
94
103 template<class V>
104 auto io(const V &v)
105 {
106 return SimdImpl::io(v);
107 }
108
110
112
113 } // namespace Simd
114} // namespace Dune
115
116#endif // DUNE_COMMON_SIMD_IO_HH
Utilities for reduction like operations on ranges.
Traits for type conversions and type information.
static StaticIntegralRange< T, to, from > range(std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
Definition rangeutilities.hh:298
constexpr AutonomousValue< T > autoCopy(T &&v)
Autonomous copy of an expression's value for use in auto type deduction.
Definition typetraits.hh:642
auto io(const V &v)
construct a stream inserter
Definition io.hh:104
auto vio(const V &v)
construct a stream inserter
Definition io.hh:88
constexpr std::size_t lanes()
Number of lanes in a SIMD type.
Definition simd/interface.hh:303
decltype(auto) lane(std::size_t l, V &&v)
Extract an element of a SIMD type.
Definition simd/interface.hh:322
typename Overloads::ScalarType< std::decay_t< V > >::type Scalar
Element type of some SIMD type.
Definition simd/interface.hh:233
Dune namespace.
Definition alignedallocator.hh:11
Inserter< V > io(const V &v)
Definition io.hh:49
Definition io.hh:26
Inserter(const T &value)
Definition io.hh:30
friend Stream & operator<<(Stream &out, const Inserter &ins)
Definition io.hh:35
Include file for users of the SIMD abstraction layer.