15#include "arcane/core/internal/GatherGroup.h"
17#include "arcane/utils/FatalErrorException.h"
18#include "arcane/utils/Array2.h"
20#include "arcane/core/IParallelMng.h"
21#include "arcane/core/internal/IParallelMngInternal.h"
49~GatherGroup() =
default;
79 const Int32 writer = m_gather_group_info->m_writer;
88 const Int32 nb_sender = m_gather_group_info->m_nb_sender_to_writer;
95 for (
Int32 i = 0; i < nb_sender - 1; ++i) {
96 const Int32 rank = i + writer + 1;
97 const Int64 sizeof_recved = nb_elem_recved[i] * sizeof_elem;
100 requests[i] = pm->
recv(recv_elem, rank,
false);
102 old_size += sizeof_recved;
115 m_gather_group_info = gather_group_info;
126: m_parallel_mng(parallel_mng)
127, m_use_collective_io(use_collective_io)
134~GatherGroupInfo() =
default;
144 m_is_computed =
true;
146 if (m_use_collective_io) {
147 m_writer = m_parallel_mng->_internalApi()->masterParallelIORank();
148 m_nb_sender_to_writer = m_parallel_mng->_internalApi()->nbSendersToMasterParallelIO();
151 m_writer = m_parallel_mng->masterIORank();
152 m_nb_sender_to_writer = m_parallel_mng->commSize();
156 if ((m_parallel_mng->commSize() == 1) || (!m_parallel_mng->isThreadImplementation() && m_use_collective_io)) {
157 m_nb_elem_output = nb_elem_in;
158 m_nb_writer_global = m_parallel_mng->commSize();
162 if (m_writer != m_parallel_mng->commRank()) {
163 m_parallel_mng->send({ 1, &nb_elem_in }, m_writer);
164 m_nb_elem_output = 0;
167 m_nb_elem_recv.resizeNoInit(m_nb_sender_to_writer - 1);
171 for (
Int32 i = 0; i < m_nb_sender_to_writer - 1; ++i) {
172 const Int32 rank = i + m_writer + 1;
173 requests[i] = m_parallel_mng->recv({ 1, &m_nb_elem_recv[i] }, rank,
false);
175 m_parallel_mng->waitAllRequests(requests);
178 m_nb_elem_output = nb_elem_in;
179 for (
const Int32 size : m_nb_elem_recv) {
180 m_nb_elem_output += size;
193 return m_nb_elem_recv.smallSpan();
#define ARCANE_FATAL_IF(const,...)
Macro throwing a FatalErrorException if cond is true.
#define ARCANE_CHECK_POINTER(ptr)
Macro returning the pointer ptr if it is not null or throwing an exception if it is null.
Modifiable view of an array of type T.
Class allowing the calculation and storage of grouping information.
void computeSize(Int32 nb_elem_in) override
Method allowing the calculation of grouping information.
GatherGroupInfo(IParallelMng *parallel_mng, bool use_collective_io)
Constructor.
SmallSpan< Int32 > nbElemRecvGatherToMasterIO() override
Method allowing knowledge of the number of elements that each third-party subdomain will send to us.
bool isComputed() override
Method allowing determination of whether the method computeSize() has already been called.
GatherGroup()
Constructor. For the object to be usable, it is necessary to call setGatherGroupInfo().
bool isNeedGather() override
Method allowing determination of whether the grouping needs to be performed or if the data can be wri...
void gatherToMasterIO(Int64 sizeof_elem, Span< const Byte > in, Span< Byte > out) override
Method allowing the grouping of data from multiple subdomains onto one or more subdomains.
void setGatherGroupInfo(GatherGroupInfo *gather_group_info)
Method allowing the definition of grouping information.
Interface of the parallelism manager for a subdomain.
virtual bool isThreadImplementation() const =0
Indicates if the implementation uses threads.
virtual Int32 commRank() const =0
Rank of this instance in the communicator.
virtual void recv(ArrayView< char > values, Int32 rank)=0
virtual Int32 commSize() const =0
Number of instances in the communicator.
virtual void waitAllRequests(ArrayView< Request > rvalues)=0
Blocks while waiting for the rvalues requests to complete.
View of an array of elements of type T.
__host__ __device__ void copy(const U ©_array)
Copies the array copy_array into the instance.
constexpr ConstArrayView< value_type > constSmallView() const
Constant view of this view.
constexpr __host__ __device__ SizeType size() const noexcept
Returns the size of the array.
View of an array of elements of type T.
constexpr __host__ __device__ Span< T, DynExtent > subSpan(Int64 abegin, Int64 asize) const
Sub-view starting from element abegin and containing asize elements.
1D data vector with value semantics (STL style).
@ ReduceSum
Sum of values.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
std::int32_t Int32
Signed integer type of 32 bits.