Dune Core Modules (2.8.0)

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,
33 class = std::enable_if_t<std::is_base_of<std::ios_base,
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
Traits for type conversions and type information.
constexpr AutonomousValue< T > autoCopy(T &&v)
Autonomous copy of an expression's value for use in auto type deduction.
Definition: typetraits.hh:642
constexpr std::size_t lanes()
Number of lanes in a SIMD type.
Definition: interface.hh:303
decltype(auto) lane(std::size_t l, V &&v)
Extract an element of a SIMD type.
Definition: interface.hh:322
Dune namespace.
Definition: alignedallocator.hh:11
Utilities for reduction like operations on ranges.
Include file for users of the SIMD abstraction layer.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 22, 23:30, 2024)