25#include <boost/mpi/collectives/gather.hpp>
26#include <boost/mpi/collectives/scatter.hpp>
27#include <boost/mpi/communicator.hpp>
28#include <boost/multi_array.hpp>
29#include <boost/serialization/vector.hpp>
44template <
class>
struct is_optional_type :
public std::false_type {};
46struct is_optional_type<
std::
optional<T>> :
public std::true_type {};
48template <
class ArrayView,
typename T>
50 using array_type = boost::multi_array<T, 4>;
56 for (
typename array_type::index i = 0; i !=
dim_i; ++i) {
57 for (
typename array_type::index
j = 0;
j !=
dim_j; ++
j) {
58 for (
typename array_type::index k = 0; k !=
dim_k; ++k) {
59 for (
typename array_type::index t = 0; t !=
dim_t; ++t) {
68template <
class FieldSerializer,
class ArrayView,
typename T>
71 using array_type = boost::multi_array<T, 4>;
72 out.reserve(
view.num_elements());
77 for (
typename array_type::index i = 0; i !=
dim_i; ++i) {
78 for (
typename array_type::index
j = 0;
j !=
dim_j; ++
j) {
79 for (
typename array_type::index k = 0; k !=
dim_k; ++k) {
80 for (
typename array_type::index t = 0; t !=
dim_t; ++t) {
81 if constexpr (std::is_floating_point_v<T>) {
84 if (
view[i][
j][k][t]) {
87 out.emplace_back(std::nullopt);
110template <
class FieldSerializer>
111template <
class LatticeModel,
typename T>
117 auto const &comm = context()->get_comm();
123 1, std::multiplies<>());
128 if (comm.rank() == 0) {
130 using index_range = boost::multi_array_types::index_range;
131 using array_type = boost::multi_array<T, 4>;
132 array_type array(boost::extents[dims[0]][dims[1]][dims[2]][
data_size]);
134 for (std::size_t rank = 0; rank <
nodes_values.size(); ++rank) {
145 typename array_type::template array_view<4>::type
view =
153 std::vector<int> shape = {m_shape.begin(), m_shape.end()};
157 auto const variant = FieldSerializer::serialize(
out);
163template <
class FieldSerializer>
164template <
class LatticeModel,
typename T>
178 1, std::multiplies<>());
181 if (comm.rank() == 0) {
184 using index_range = boost::multi_array_types::index_range;
185 using array_type = boost::multi_array<T, 4>;
186 array_type array(boost::extents[dims[0]][dims[1]][dims[2]][
data_size]);
188 detail::unflatten_grid(array,
values);
199 typename array_type::template array_view<4>::type
view =
Vector implementation and trait types for boost qvm interoperability.
virtual boost::mpi::communicator const & get_comm() const =0
Context * context() const
Responsible context.
Variant gather_3d(std::vector< int > const &data_dims, LatticeModel const &lattice_model, std::vector< T >(LatticeModel::*getter)(Utils::Vector3i const &, Utils::Vector3i const &) const, double units_conversion=1.) const
static DEVICE_QUALIFIER constexpr Vector< T, N > broadcast(typename Base::value_type const &value) noexcept
Create a vector that has all entries set to the same value.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
auto gather_slices_topology(boost::mpi::communicator const &comm, Utils::Vector3i const &local_lower_corner, Utils::Vector3i const &local_upper_corner)
make_recursive_variant< ObjectRef > Variant
Possible types for parameters.
Recursive variant implementation.