/*+ ARES/HADES/BORG Package -- ./libLSS/tools/domains.hpp Copyright (C) 2020 Guilhem Lavaux Copyright (C) 2009-2020 Jens Jasche Additional contributions from: Guilhem Lavaux (2023) +*/ #ifndef __LIBLSS_TOOLS_MPI_DOMAIN_HPP # define __LIBLSS_TOOLS_MPI_DOMAIN_HPP # include # include # include # include "libLSS/mpi/generic_mpi.hpp" # include # include "libLSS/samplers/core/types_samplers.hpp" namespace LibLSS { /** * @brief Specifies the boundary of domains * * @tparam N number of dimensions */ template struct DomainSpec { /** * @brief Type defining an hypercube boundary. * * The hypercube is defined by two corners defined in an N-d space. * Thus we need 2 * Nd elements in that array. */ typedef std::array DomainLimit_t; /** * @brief Boundaries * * A domain is defined by a set of hypercube boundaries. * The assumption is that the hypercubes are disjoint. */ std::vector domains; boost::optional> intersect(DomainSpec const &other) const; }; /** * @brief Hold the complete description of the domain on all nodes. * * Any sane description should cover completely the hypercube domain. * * @tparam N number of dimensions of the hypercube */ template struct CompleteDomainSpec { std::vector> domainOnRank; }; /** * @brief Specific task to exchange data on domains * * @tparam N */ template struct DomainTask { typename DomainSpec::DomainLimit_t slice; int rankIO; bool recv; }; /** * @brief Todo list of tasks to complete to redistribute domain data on nodes * * @tparam N */ template struct DomainTodo { std::list> tasks; }; /** * @brief Array of data for the domain * * @tparam T * @tparam N */ template using Domain = LibLSS::multi_array_ref; /** * @brief Gather the complete domain specification. * * This function gather the description from each tasks about their domain * specification and store the result in `complete`. * @tparam N * @param comm * @param complete * @param inputSpec */ template void computeCompleteDomainSpec( MPI_Communication *comm, CompleteDomainSpec &complete, DomainSpec const &inputSpec); /** * @brief Compute the list of tasks to do to transform from one spec to another * * The algorithm must complete the list of tasks to go from `inputSpec` to `outputSpec` * on each node. Provided the domain does not change the list of tasks must be * invariant w.r.t held data. * * @tparam N * @param comm * @param inputSpec * @param outputSpec * @param todo */ template void mpiDomainComputeTodo( MPI_Communication *comm, CompleteDomainSpec const &inputSpec, CompleteDomainSpec const &outputSpec, DomainTodo &todo); /** * @brief Execute a domain redecomposition * * @tparam T * @tparam N * @param comm * @param inputSpec * @param inputDomain * @param outputSpec * @param outputDomain */ template void mpiDomainRun( MPI_Communication *comm, Domain const &input_domains, Domain &output_domains, DomainTodo const &todo); } // namespace LibLSS #endif // ARES TAG: num_authors = 1 // ARES TAG: name(0) = Guilhem Lavaux // ARES TAG: year(0) = 2020 // ARES TAG: email(0) = guilhem.lavaux@iap.fr