Loading...
Searching...
No Matches
io.hh
Go to the documentation of this file.
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
#ifndef DUNE_COMMON_SIMD_IO_HH
#define DUNE_COMMON_SIMD_IO_HH
#include <ios>
#include <type_traits>
#include <dune/common/rangeutilities.hh>
#include <dune/common/simd/simd.hh>
#include <dune/common/typetraits.hh>
namespace Dune {
namespace SimdImpl {
template<class T>
class Inserter {
T value_;
public:
Inserter(const T &value) : value_(value) {}
template<class Stream,
class = std::enable_if_t<std::is_base_of<std::ios_base,
Stream>::value> >
friend Stream& operator<<(Stream &out, const Inserter &ins)
{
const char *sep = "<";
for(auto l : range(Simd::lanes(ins.value_)))
{
out << sep << autoCopy(Simd::lane(l, ins.value_));
sep = ", ";
}
out << '>';
return out;
}
};
template<class V, class = std::enable_if_t<Simd::lanes<V>() != 1> >
Inserter<V> io(const V &v)
{
return { v };
}
template<class V, class = std::enable_if_t<Simd::lanes<V>() == 1> >
Simd::Scalar<V> io(const V &v)
{
return Simd::lane(0, v);
}
}
namespace Simd {
template<class V>
auto vio(const V &v)
{
return SimdImpl::Inserter<V>{ v };
}
template<class V>
auto io(const V &v)
{
return SimdImpl::io(v);
}
} // namespace Simd
} // namespace Dune
#endif // DUNE_COMMON_SIMD_IO_HH
typetraits.hh
Traits for type conversions and type information.
rangeutilities.hh
Utilities for reduction like operations on ranges.
Dune::range
static constexpr IntegralRange< std::decay_t< T > > range(T &&from, U &&to) noexcept
free standing function for setting up a range based for loop over an integer range for (auto i: range...
Definition rangeutilities.hh:288
Dune::autoCopy
constexpr AutonomousValue< T > autoCopy(T &&v)
Autonomous copy of an expression's value for use in auto type deduction.
Definition typetraits.hh:650
Dune::Simd::io
auto io(const V &v)
construct a stream inserter
Definition io.hh:106
Dune::Simd::vio
auto vio(const V &v)
construct a stream inserter
Definition io.hh:90
Dune::Simd::Scalar
typename Overloads::ScalarType< std::decay_t< V > >::type Scalar
Element type of some SIMD type.
Definition simd/interface.hh:235
Dune::Simd::lanes
constexpr std::size_t lanes()
Number of lanes in a SIMD type.
Definition simd/interface.hh:305
Dune::Simd::lane
decltype(auto) lane(std::size_t l, V &&v)
Extract an element of a SIMD type.
Definition simd/interface.hh:324
Dune
Dune namespace
Definition alignedallocator.hh:13
Dune::Simd
Namespace for vectorization interface functions used by library developers.
Definition debugalign.hh:518
simd.hh
Include file for users of the SIMD abstraction layer.