Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MachineShMemWin.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/* MachineShMemWin.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. */
13/*---------------------------------------------------------------------------*/
14#ifndef ARCANE_CORE_MACHINESHMEMWIN_H
15#define ARCANE_CORE_MACHINESHMEMWIN_H
16/*---------------------------------------------------------------------------*/
17/*---------------------------------------------------------------------------*/
18
19#include "arcane/core/MachineShMemWinBase.h"
21#include "arcane/utils/Ref.h"
22
23#include "arccore/base/Span.h"
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28namespace Arcane
29{
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
45template <class Type>
47{
48
49 public:
50
56 MachineShMemWin(IParallelMng* pm, Int64 nb_elem_segment)
57 : m_impl(pm, nb_elem_segment, static_cast<Int32>(sizeof(Type)))
58 {}
59
65 : m_impl(pm, 0, static_cast<Int32>(sizeof(Type)))
66 {}
67
68 public:
69
79 {
80 return m_impl.machineRanks();
81 }
82
87 void barrier() const
88 {
89 m_impl.barrier();
90 }
91
99 {
100 return asSpan<Type>(m_impl.segmentView());
101 }
102
113 {
114 return asSpan<Type>(m_impl.segmentView(rank));
115 }
116
125 {
126 return asSpan<const Type>(m_impl.segmentConstView());
127 }
128
139 {
140 return asSpan<const Type>(m_impl.segmentConstView(rank));
141 }
142
158 {
159 const Span<const std::byte> span_bytes(reinterpret_cast<const std::byte*>(elem.data()), elem.sizeBytes());
160 m_impl.add(span_bytes);
161 }
162
173 void add()
174 {
175 m_impl.add();
176 }
177
198 {
199 const Span<const std::byte> span_bytes(reinterpret_cast<const std::byte*>(elem.data()), elem.sizeBytes());
200 m_impl.addToAnotherSegment(rank, span_bytes);
201 }
202
214 {
215 m_impl.addToAnotherSegment();
216 }
217
241 void reserve(Int64 new_capacity)
242 {
243 m_impl.reserve(new_capacity);
244 }
245
254 void reserve()
255 {
256 m_impl.reserve();
257 }
258
273 void resize(Int64 new_nb_elem)
274 {
275 m_impl.resize(new_nb_elem);
276 }
277
286 void resize()
287 {
288 m_impl.resize();
289 }
290
297 void shrink()
298 {
299 m_impl.shrink();
300 }
301
302 private:
303
304 MachineShMemWinBase m_impl;
305};
306
307/*---------------------------------------------------------------------------*/
308/*---------------------------------------------------------------------------*/
309
310} // End namespace Arcane
311
312/*---------------------------------------------------------------------------*/
313/*---------------------------------------------------------------------------*/
314
315#endif
Declarations of Arcane's general types.
Types and functions associated with the classes SpanImpl, SmallSpan and Span.
Constant view of an array of type T.
Interface of the parallelism manager for a subdomain.
Class allowing the creation of a shared memory window between the subdomains of the same node.
void resize(Int64 new_nb_elem)
Method to resize our segment.
void shrink()
Method to reduce the reserved memory space for the segments to the minimum necessary.
Span< const Type > segmentConstView(Int32 rank) const
Method to obtain a view of the segment of another sub-domain on the node.
void resize()
Method to be called by the sub-domain(s) that do not wish to resize their segments.
void add()
Method to be called by the sub-domain(s) that do not wish to add elements to their segment.
ConstArrayView< Int32 > machineRanks() const
Method to obtain the ranks that possess a segment in the window.
Span< const Type > segmentConstView() const
Method to obtain a view of our segment.
Span< Type > segmentView(Int32 rank)
Method to obtain a view of the segment of another sub-domain on the node.
Span< Type > segmentView()
Method to obtain a view of our segment.
void addToAnotherSegment(Int32 rank, Span< const Type > elem)
Method to add elements to the segment of another sub-domain.
void add(Span< const Type > elem)
Method to add elements to our segment.
void addToAnotherSegment()
Method to be called by the sub-domain(s) that do not wish to add elements to the segment of another s...
MachineShMemWin(IParallelMng *pm, Int64 nb_elem_segment)
Constructor.
void barrier() const
Method to wait until all processes/threads on the node call this method to continue execution.
void reserve(Int64 new_capacity)
Method to reserve memory space in our segment.
MachineShMemWin(IParallelMng *pm)
Constructor.
void reserve()
Method to be called by the sub-domain(s) that do not wish to reserve more memory for their segments.
constexpr __host__ __device__ pointer data() const noexcept
Pointer to the start of the view.
Definition Span.h:539
constexpr __host__ __device__ SizeType sizeBytes() const noexcept
Returns the size of the array in bytes.
Definition Span.h:329
View of an array of elements of type T.
Definition Span.h:635
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
Span< DataType > asSpan(Span< std::byte, Extent > bytes)
Converts a Span<std::byte> into a Span<DataType>.
Definition Span.h:1126
std::int32_t Int32
Signed integer type of 32 bits.
Type
Type of JSON value.
Definition rapidjson.h:730