11#include <fmt/format.h>
34 template <
typename Derived>
41 auto op = [B](
auto &
v)
45 self().for_each_device_member(op);
55 self().for_each_device_member(op);
64 auto getB = [&B](
auto &
v)
67 B =
v.ref.father->device();
69 self().for_each_device_member(getB);
71 auto check = [&B](
auto &
v)
75 B ==
v.ref.father->device(),
76 fmt::format(
"member [{}.father] expected to be on device {} but on {}",
82 B ==
v.ref.son->device(),
83 fmt::format(
"member [{}.son] expected to be on device {} but on {}",
88 self().for_each_device_member(check);
97 auto accumulate = [&bytes](
auto &
v)
100 bytes +=
v.ref.father->FullSizeBytes();
102 bytes +=
v.ref.son->FullSizeBytes();
104 self().for_each_device_member(accumulate);
109 Derived &self() {
return static_cast<Derived &
>(*this); }
Device memory abstraction layer with backend-specific storage and factory creation.
Assertion / error-handling macros and supporting helper functions.
#define DNDS_assert_info(expr, info)
Debug-only assertion with an extra std::string info message.
Tiny reflection-style helpers (MemberRef, MemberPtr) and for_each_member_* visitors used by config / ...
CRTP mixin giving a class uniform to_device / to_host / device / getDeviceArrayBytes methods.
DeviceBackend device()
Consistent device backend across all registered pairs.
index getDeviceArrayBytes()
Total footprint of every registered father+son pair in bytes.
void to_host()
Pull every registered pair back to host memory.
void to_device(DeviceBackend B)
Mirror every registered ArrayPair to the given device backend.
the host side operators are provided as implemented
DeviceBackend
Enumerates the backends a DeviceStorage / Array can live on.
@ Unknown
Unset / sentinel.
const char * device_backend_name(DeviceBackend B)
Canonical string name for a DeviceBackend (used in log messages).
int64_t index
Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
Eigen::Matrix< real, 5, 1 > v