19#ifndef SRC_UTILS_INCLUDE_UTILS_ARRAY_HPP
20#define SRC_UTILS_INCLUDE_UTILS_ARRAY_HPP
32#include <boost/serialization/access.hpp>
43template <
typename T, std::
size_t N>
struct Storage {
47 friend boost::serialization::access;
48 template <
typename Archive>
49 void serialize(Archive &ar,
const unsigned int ) {
54template <
typename T>
struct Storage<T, 0> {};
56struct ArrayFormatterStream {
58 char const *separator;
59 ArrayFormatterStream(std::ostream &s,
char const *sep)
60 :
stream(s), separator(sep) {}
63struct ArrayFormatter {
64 char const *separator;
65 friend ArrayFormatterStream operator<<(std::ostream &os,
66 ArrayFormatter
const &fmt) {
67 return {os, fmt.separator};
73template <
typename T, std::
size_t N>
struct Array {
88 DEVICE_THROW(std::out_of_range(
"Array access out of bounds."));
95 DEVICE_THROW(std::out_of_range(
"Array access out of bounds."));
117 return *(
cend() - 1);
173 static constexpr detail::ArrayFormatter
formatter(
char const *sep =
" ") {
178 friend boost::serialization::access;
179 template <
typename Archive>
180 void serialize(Archive &ar,
const unsigned int ) {
184 static std::ostream &format(std::ostream &out, Array
const &a,
185 char const *
const sep) {
189 for (
auto it = std::next(a.begin()); it != a.end(); ++it)
196 return format(out, a,
", ");
199 friend std::ostream &
operator<<(detail::ArrayFormatterStream
const &fmt,
201 return format(fmt.stream, a, fmt.separator);
205template <std::
size_t I,
class T, std::
size_t N>
210template <
class T, std::
size_t N>
213template <std::
size_t I,
class T, std::
size_t N>
#define UTILS_ARRAY_BOOST_MPI_T(Container, N)
Mark array types as MPI data types.
#define UTILS_ARRAY_BOOST_BIT_S(Container, N)
Mark array types as MPI bitwise serializable.
#define UTILS_ARRAY_BOOST_CLASS(Container, N, ImplementationLevel)
Redefinition of BOOST_CLASS_IMPLEMENTATION for array types.
#define UTILS_ARRAY_BOOST_TRACK(Container, N, TrackingLevel)
Redefinition of BOOST_CLASS_TRACKING for array types.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
auto get(Array< T, N > const &a) -> std::enable_if_t<(I< N), const T & >
void serialize(Archive &ar, std::tuple< T... > &pack, unsigned int const)
Serialize std::tuple.
DEVICE_QUALIFIER constexpr reference at(size_type i)
static constexpr detail::ArrayFormatter formatter(char const *sep=" ")
DEVICE_QUALIFIER constexpr bool empty() const noexcept
DEVICE_QUALIFIER constexpr reference back()
DEVICE_QUALIFIER constexpr pointer data() noexcept
DEVICE_QUALIFIER constexpr const_reference front() const
DEVICE_QUALIFIER constexpr const_reference at(size_type i) const
DEVICE_QUALIFIER constexpr size_type max_size() const noexcept
DEVICE_QUALIFIER constexpr iterator begin() noexcept
DEVICE_QUALIFIER constexpr const_pointer data() const noexcept
DEVICE_QUALIFIER constexpr const_iterator cbegin() const noexcept
const value_type & const_reference
detail::Storage< T, N > m_storage
friend std::ostream & operator<<(std::ostream &out, Array const &a)
DEVICE_QUALIFIER constexpr const_iterator cend() const noexcept
static DEVICE_QUALIFIER constexpr Array< T, N > broadcast(const value_type &value)
DEVICE_QUALIFIER constexpr size_type size() const noexcept
DEVICE_QUALIFIER constexpr reference front()
const value_type * const_pointer
DEVICE_QUALIFIER constexpr const_reference back() const
DEVICE_QUALIFIER constexpr reference operator[](size_type i)
friend std::ostream & operator<<(detail::ArrayFormatterStream const &fmt, Array const &a)
DEVICE_QUALIFIER constexpr iterator end() noexcept
DEVICE_QUALIFIER void fill(const value_type &value)
const value_type * const_iterator
DEVICE_QUALIFIER constexpr const_iterator begin() const noexcept
DEVICE_QUALIFIER constexpr const_reference operator[](size_type i) const
DEVICE_QUALIFIER constexpr const_iterator end() const noexcept
std::ptrdiff_t difference_type