22#include <boost/mpl/bool.hpp>
23#include <boost/serialization/is_bitwise_serializable.hpp>
24#include <boost/serialization/nvp.hpp>
25#include <boost/serialization/serialization.hpp>
48 std::is_trivially_copyable_v<T> or
49 boost::serialization::is_bitwise_serializable<T>::value> {};
55 std::bool_constant<std::is_trivially_copyable_v<T>
or
56 boost::serialization::is_bitwise_serializable<T>::value>;
60using use_serialize = std::bool_constant<not use_memcpy<T>::value
and
63template <
class Derived>
class BasicMemcpyArchive {
71 explicit BasicMemcpyArchive(std::span<char> buf)
72 : buf(buf), insert(buf.data()) {}
75 auto get_library_version()
const {
return std::size_t{4}; }
77 auto bytes_processed()
const {
78 return static_cast<std::size_t
>(insert - buf.data());
81 void skip(std::size_t
bytes) {
87 void read(
void *data, std::size_t
bytes) {
90 std::memcpy(data, insert,
bytes);
94 void write(
const void *data, std::size_t
bytes) {
97 std::memcpy(insert, data,
bytes);
102 template <
typename T>
103 requires use_memcpy<T>::value
104 void operator>>(T &value) {
105 read(&value,
sizeof(T));
108 template <
typename T>
109 requires use_memcpy<T>::value
110 void operator<<(T
const &value) {
111 write(&value,
sizeof(T));
115 template <
class T>
void process(T &value) {
117 boost::serialization::serialize_adl(*
static_cast<Derived *
>(
this), value,
128 requires detail::use_serialize<T>::value
129 void operator>>(T &value) {
134 requires detail::use_serialize<T>::value
135 void operator<<(T &value) {
139 template <
class T>
void operator<<(
const boost::serialization::nvp<T> &
nvp) {
140 operator<<(
nvp.const_value());
143 template <
class T>
void operator>>(
const boost::serialization::nvp<T> &
nvp) {
144 operator>>(
nvp.value());
152 template <
class T>
static constexpr std::size_t packing_size() {
169 using base_type = detail::BasicMemcpyArchive<MemcpyIArchive>;
187 using base_type::packing_size;
188 using base_type::operator>>;
203 using base_type = detail::BasicMemcpyArchive<MemcpyOArchive>;
221 using base_type::packing_size;
222 using base_type::operator<<;
Archive that deserializes from a buffer via memcpy.
boost::mpl::true_ is_loading
MemcpyIArchive & operator&(T &value)
std::size_t bytes_read() const
Number of bytes read from the buffer.
MemcpyIArchive(std::span< char > buf)
boost::mpl::false_ is_saving
Archive that serializes to a buffer via memcpy.
boost::mpl::false_ is_loading
MemcpyOArchive(std::span< char > buf)
std::size_t bytes_written() const
Number of bytes written to the buffer.
MemcpyOArchive & operator&(T &value)
boost::mpl::true_ is_saving
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
static std::basic_ostream< char > & operator<<(std::basic_ostream< char > &os, const dim3 &dim)
Type trait to indicate that a type is serializable with a static size, e.g.