Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MpiMultiMachineShMemWinBaseInternal.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* MpiMultiMachineShMemWinBaseInternal.h (C) 2000-2026 */
9/* */
10/* Class allowing the creation of memory windows for a compute node. */
11/* The segments of these windows are not contiguous in memory and can */
12/* be resized. A process can possess multiple segments. */
13/*---------------------------------------------------------------------------*/
14#ifndef ARCCORE_MESSAGEPASSINGMPI_INTERNAL_MPIMULTIMACHINESHMEMWINBASEINTERNAL_H
15#define ARCCORE_MESSAGEPASSINGMPI_INTERNAL_MPIMULTIMACHINESHMEMWINBASEINTERNAL_H
16/*---------------------------------------------------------------------------*/
17/*---------------------------------------------------------------------------*/
18
19#include "arccore/collections/Array.h"
20
21#include "arccore/message_passing_mpi/MessagePassingMpiGlobal.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane::MessagePassing::Mpi
27{
28
50class ARCCORE_MESSAGEPASSINGMPI_EXPORT MpiMultiMachineShMemWinBaseInternal
51{
52
53 public:
54
55 explicit MpiMultiMachineShMemWinBaseInternal(SmallSpan<Int64> sizeof_segments, Int32 nb_segments_per_proc, Int32 sizeof_type, const MPI_Comm& comm_machine, Int32 comm_machine_rank, Int32 comm_machine_size, ConstArrayView<Int32> machine_ranks);
56
58
59 public:
60
68 Int32 sizeofOneElem() const;
69
79
84 void barrier() const;
85
95
106 Span<std::byte> segmentView(Int32 rank, Int32 num_seg);
107
117
129
148 void requestAdd(Int32 num_seg, Span<const std::byte> elem);
149
158 void executeAdd();
159
183 void requestAddToAnotherSegment(Int32 thread, Int32 rank, Int32 num_seg, Span<const std::byte> elem);
184
195
226 void requestReserve(Int32 num_seg, Int64 new_capacity);
227
236 void executeReserve();
237
262 void requestResize(Int32 num_seg, Int64 new_size);
263
272 void executeResize();
273
283 void executeShrink();
284
285 private:
286
292 void _requestRealloc(Int32 owner_pos_segment, Int64 new_capacity) const;
293
298 void _requestRealloc(Int32 owner_pos_segment) const;
299 void _executeRealloc();
300 void _realloc();
301
302 Int32 _worldToMachine(Int32 world) const;
303 Int32 _machineToWorld(Int32 machine) const;
304
305 private:
306
317
327
335
351
352 MPI_Comm m_comm_machine;
353 Int32 m_comm_machine_size = 0;
354 Int32 m_comm_machine_rank = 0;
355
356 Int32 m_sizeof_type = 0;
357 Int32 m_nb_segments_per_proc = 0;
358
359 ConstArrayView<Int32> m_machine_ranks;
360
365 bool m_add_requested = false;
366
371 bool m_resize_requested = false;
372};
373
374/*---------------------------------------------------------------------------*/
375/*---------------------------------------------------------------------------*/
376
377} // namespace Arcane::MessagePassing::Mpi
378
379/*---------------------------------------------------------------------------*/
380/*---------------------------------------------------------------------------*/
381
382#endif
Constant view of an array of type T.
void requestAdd(Int32 num_seg, Span< const std::byte > elem)
Method to request the addition of elements into one of our segments.
Span< const std::byte > segmentConstView(Int32 num_seg) const
Method to get a constant view of one of our segments.
void executeShrink()
Method to reduce the reserved memory space for the segments to the minimum necessary.
void requestReserve(Int32 num_seg, Int64 new_capacity)
Method to request the reservation of memory space for one of our segments.
void requestAddToAnotherSegment(Int32 thread, Int32 rank, Int32 num_seg, Span< const std::byte > elem)
Method to request the addition of elements into one of the segments of the window.
void _requestRealloc(Int32 owner_pos_segment, Int64 new_capacity) const
Method to request a reallocation.
MpiMultiMachineShMemWinBaseInternal(SmallSpan< Int64 > sizeof_segments, Int32 nb_segments_per_proc, Int32 sizeof_type, const MPI_Comm &comm_machine, Int32 comm_machine_rank, Int32 comm_machine_size, ConstArrayView< Int32 > machine_ranks)
sizeof_segments should not be preserved!
void requestResize(Int32 num_seg, Int64 new_size)
Method to request the resizing of one of our segments.
void barrier() const
Method to wait until all processes on the node call this method to continue execution.
void executeAddToAnotherSegment()
Method to execute the addition requests in the segments of other processes.
Int32 sizeofOneElem() const
Method to get the size of an element in the window.
Span< std::byte > segmentView(Int32 num_seg)
Method to get a view of one of our segments.
ConstArrayView< Int32 > machineRanks() const
Method to get the ranks that own a segment in the window.
View of an array of elements of type T.
Definition Span.h:805
View of an array of elements of type T.
Definition Span.h:635
1D data vector with value semantics (STL style).
std::int64_t Int64
Signed integer type of 64 bits.
std::int32_t Int32
Signed integer type of 32 bits.