Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MpiMachineShMemWinBaseInternal.cc
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/* MpiMachineShMemWinBaseInternal.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#include "arccore/message_passing_mpi/internal/MpiMachineShMemWinBaseInternal.h"
15
16#include "arccore/base/FatalErrorException.h"
17/*---------------------------------------------------------------------------*/
18/*---------------------------------------------------------------------------*/
19
20namespace Arcane::MessagePassing::Mpi
21{
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26MpiMachineShMemWinBaseInternal::
27MpiMachineShMemWinBaseInternal(Int64 sizeof_segment, Int32 sizeof_type, const MPI_Comm& comm_machine, Int32 comm_machine_rank, Int32 comm_machine_size, ConstArrayView<Int32> machine_ranks)
28: m_win_need_resize()
29, m_win_actual_sizeof()
30, m_win_target_segments()
31, m_comm_machine(comm_machine)
32, m_comm_machine_size(comm_machine_size)
33, m_comm_machine_rank(comm_machine_rank)
34, m_sizeof_type(sizeof_type)
35, m_machine_ranks(machine_ranks)
36{
37 if (m_sizeof_type <= 0) {
38 ARCCORE_FATAL("Invalid sizeof_type");
39 }
40 if (sizeof_segment < 0 || sizeof_segment % m_sizeof_type != 0) {
41 ARCCORE_FATAL("Invalid initial sizeof_segment");
42 }
43 m_all_mpi_win.resize(m_comm_machine_size);
44
45 MPI_Info win_info_true;
46 MPI_Info_create(&win_info_true);
47 MPI_Info_set(win_info_true, "alloc_shared_noncontig", "true");
48
49 MPI_Info win_info_false;
50 MPI_Info_create(&win_info_false);
51 MPI_Info_set(win_info_false, "alloc_shared_noncontig", "false");
52
53 {
54 for (Integer i = 0; i < m_comm_machine_size; ++i) {
55 Int64 size_seg = 0;
56 if (m_comm_machine_rank == i) {
57 if (sizeof_segment == 0)
58 size_seg = m_sizeof_type;
59 else
60 size_seg = sizeof_segment;
61 }
62
63 std::byte* ptr_seg = nullptr;
64 int error = MPI_Win_allocate_shared(size_seg, m_sizeof_type, win_info_true, m_comm_machine, &ptr_seg, &m_all_mpi_win[i]);
65
66 if (error != MPI_SUCCESS) {
67 ARCCORE_FATAL("Error with MPI_Win_allocate_shared() call");
68 }
69 }
70 {
71 MPI_Aint size_seg;
72 int size_type;
73 std::byte* ptr_seg = nullptr;
74 int error = MPI_Win_shared_query(m_all_mpi_win[m_comm_machine_rank], m_comm_machine_rank, &size_seg, &size_type, &ptr_seg);
75
76 if (error != MPI_SUCCESS) {
77 ARCCORE_FATAL("Error with MPI_Win_shared_query() call");
78 }
79
80 // Note: The user requests a minimum number of reserved elements.
81 // But MPI reserves the size it wants (effect of alloc_shared_noncontig=true).
82 // We are just sure that the size it reserved is greater than or equal to sizeof_segment.
83 m_reserved_part_span = Span<std::byte>{ ptr_seg, size_seg };
84 }
85 }
86
87 {
88 Int64* ptr_seg = nullptr;
89 Int64* ptr_win = nullptr;
90 {
91 int error = MPI_Win_allocate_shared(sizeof(Int64), sizeof(Int64), win_info_false, m_comm_machine, &ptr_seg, &m_win_need_resize);
92
93 if (error != MPI_SUCCESS) {
94 ARCCORE_FATAL("Error with MPI_Win_allocate_shared() call");
95 }
96 }
97 {
98 MPI_Aint size_seg;
99 int size_type;
100 int error = MPI_Win_shared_query(m_win_need_resize, 0, &size_seg, &size_type, &ptr_win);
101
102 if (error != MPI_SUCCESS) {
103 ARCCORE_FATAL("Error with MPI_Win_shared_query() call");
104 }
105
106 m_need_resize = Span<Int64>{ ptr_win, m_comm_machine_size };
107 m_need_resize[m_comm_machine_rank] = -1;
108 }
109 if (ptr_win + m_comm_machine_rank != ptr_seg) {
110 ARCCORE_FATAL("m_win_need_resize is noncontig");
111 }
112 }
113
114 {
115 Int64* ptr_seg = nullptr;
116 Int64* ptr_win = nullptr;
117 {
118 int error = MPI_Win_allocate_shared(sizeof(Int64), sizeof(Int64), win_info_false, m_comm_machine, &ptr_seg, &m_win_actual_sizeof);
119
120 if (error != MPI_SUCCESS) {
121 ARCCORE_FATAL("Error with MPI_Win_allocate_shared() call");
122 }
123 }
124 {
125 MPI_Aint size_seg;
126 int size_type;
127 int error = MPI_Win_shared_query(m_win_actual_sizeof, 0, &size_seg, &size_type, &ptr_win);
128
129 if (error != MPI_SUCCESS) {
130 ARCCORE_FATAL("Error with MPI_Win_shared_query() call");
131 }
132
133 m_sizeof_used_part = Span<Int64>{ ptr_win, m_comm_machine_size };
134 m_sizeof_used_part[m_comm_machine_rank] = sizeof_segment;
135 }
136 if (ptr_win + m_comm_machine_rank != ptr_seg) {
137 ARCCORE_FATAL("m_win_actual_sizeof is noncontig");
138 }
139 }
140
141 {
142 Int32* ptr_seg = nullptr;
143 Int32* ptr_win = nullptr;
144 {
145 int error = MPI_Win_allocate_shared(sizeof(Int32), sizeof(Int32), win_info_false, m_comm_machine, &ptr_seg, &m_win_target_segments);
146
147 if (error != MPI_SUCCESS) {
148 ARCCORE_FATAL("Error with MPI_Win_allocate_shared() call");
149 }
150 }
151 {
152 MPI_Aint size_seg;
153 int size_type;
154 int error = MPI_Win_shared_query(m_win_target_segments, 0, &size_seg, &size_type, &ptr_win);
155
156 if (error != MPI_SUCCESS) {
157 ARCCORE_FATAL("Error with MPI_Win_shared_query() call");
158 }
159
160 m_target_segments = Span<Int32>{ ptr_win, m_comm_machine_size };
161 m_target_segments[m_comm_machine_rank] = -1;
162 }
163 if (ptr_win + m_comm_machine_rank != ptr_seg) {
164 ARCCORE_FATAL("m_win_owner_segments is noncontig");
165 }
166 }
167
168 MPI_Info_free(&win_info_false);
169 MPI_Info_free(&win_info_true);
170
171 MPI_Barrier(m_comm_machine);
172}
173
174/*---------------------------------------------------------------------------*/
175/*---------------------------------------------------------------------------*/
176
177MpiMachineShMemWinBaseInternal::
178~MpiMachineShMemWinBaseInternal()
179{
180 for (Integer i = 0; i < m_comm_machine_size; ++i) {
181 MPI_Win_free(&m_all_mpi_win[i]);
182 }
183 MPI_Win_free(&m_win_need_resize);
184 MPI_Win_free(&m_win_actual_sizeof);
185 MPI_Win_free(&m_win_target_segments);
186}
187
188/*---------------------------------------------------------------------------*/
189/*---------------------------------------------------------------------------*/
190
191Int32 MpiMachineShMemWinBaseInternal::
192sizeofOneElem() const
193{
194 return m_sizeof_type;
195}
196
197/*---------------------------------------------------------------------------*/
198/*---------------------------------------------------------------------------*/
199
200ConstArrayView<Int32> MpiMachineShMemWinBaseInternal::
201machineRanks() const
202{
203 return m_machine_ranks;
204}
205
206/*---------------------------------------------------------------------------*/
207/*---------------------------------------------------------------------------*/
208
209void MpiMachineShMemWinBaseInternal::
210barrier() const
211{
212 MPI_Barrier(m_comm_machine);
213}
214
215/*---------------------------------------------------------------------------*/
216/*---------------------------------------------------------------------------*/
217
218Span<std::byte> MpiMachineShMemWinBaseInternal::
219segmentView()
220{
221 return m_reserved_part_span.subSpan(0, m_sizeof_used_part[m_comm_machine_rank]);
222}
223
224/*---------------------------------------------------------------------------*/
225/*---------------------------------------------------------------------------*/
226
227Span<std::byte> MpiMachineShMemWinBaseInternal::
228segmentView(Int32 rank)
229{
230 const Int32 machine_rank = _worldToMachine(rank);
231
232 MPI_Aint size_seg;
233 int size_type;
234 std::byte* ptr_seg = nullptr;
235 int error = MPI_Win_shared_query(m_all_mpi_win[machine_rank], machine_rank, &size_seg, &size_type, &ptr_seg);
236
237 if (error != MPI_SUCCESS) {
238 ARCCORE_FATAL("Error with MPI_Win_shared_query() call");
239 }
240
241 return Span<std::byte>{ ptr_seg, m_sizeof_used_part[machine_rank] };
242}
243
244/*---------------------------------------------------------------------------*/
245/*---------------------------------------------------------------------------*/
246
247Span<const std::byte> MpiMachineShMemWinBaseInternal::
248segmentConstView() const
249{
250 return m_reserved_part_span.subSpan(0, m_sizeof_used_part[m_comm_machine_rank]);
251}
252
253/*---------------------------------------------------------------------------*/
254/*---------------------------------------------------------------------------*/
255
256Span<const std::byte> MpiMachineShMemWinBaseInternal::
257segmentConstView(Int32 rank) const
258{
259 const Int32 machine_rank = _worldToMachine(rank);
260
261 MPI_Aint size_seg;
262 int size_type;
263 std::byte* ptr_seg = nullptr;
264 int error = MPI_Win_shared_query(m_all_mpi_win[machine_rank], machine_rank, &size_seg, &size_type, &ptr_seg);
265
266 if (error != MPI_SUCCESS) {
267 ARCCORE_FATAL("Error with MPI_Win_shared_query() call");
268 }
269
270 return Span<const std::byte>{ ptr_seg, m_sizeof_used_part[machine_rank] };
271}
272
273/*---------------------------------------------------------------------------*/
274/*---------------------------------------------------------------------------*/
275
276void MpiMachineShMemWinBaseInternal::
277add(Span<const std::byte> elem)
278{
279 if (elem.size() % m_sizeof_type) {
280 ARCCORE_FATAL("Sizeof elem not valid");
281 }
282
283 const Int64 actual_sizeof_win = m_sizeof_used_part[m_comm_machine_rank];
284 const Int64 future_sizeof_win = actual_sizeof_win + elem.size();
285 const Int64 old_reserved = m_reserved_part_span.size();
286
287 if (future_sizeof_win > old_reserved) {
288 _reallocBarrier(future_sizeof_win);
289 if (m_reserved_part_span.size() < future_sizeof_win) {
290 ARCCORE_FATAL("Bad realloc -- Old size : {0} -- New size : {1} -- Needed size : {2}", old_reserved, m_reserved_part_span.size(), future_sizeof_win);
291 }
292 }
293 else {
294 _reallocBarrier();
295 }
296
297 for (Int64 pos_win = actual_sizeof_win, pos_elem = 0; pos_win < future_sizeof_win; ++pos_win, ++pos_elem) {
298 m_reserved_part_span[pos_win] = elem[pos_elem];
299 }
300 m_sizeof_used_part[m_comm_machine_rank] = future_sizeof_win;
301
302 // Barrier because others may use the segment size
303 // (m_sizeof_used_part) that we possess (segmentView(Int32 rank) for
304 // example).
305 MPI_Barrier(m_comm_machine);
306}
307
308/*---------------------------------------------------------------------------*/
309/*---------------------------------------------------------------------------*/
310
311void MpiMachineShMemWinBaseInternal::
312add()
313{
314 _reallocBarrier();
315 MPI_Barrier(m_comm_machine);
316}
317
318/*---------------------------------------------------------------------------*/
319/*---------------------------------------------------------------------------*/
320
321void MpiMachineShMemWinBaseInternal::
322addToAnotherSegment(Int32 rank, Span<const std::byte> elem)
323{
324 if (elem.size() % m_sizeof_type) {
325 ARCCORE_FATAL("Sizeof elem not valid");
326 }
327
328 const Int32 machine_rank = _worldToMachine(rank);
329
330 m_target_segments[m_comm_machine_rank] = machine_rank;
331 MPI_Barrier(m_comm_machine);
332
333 // We must know if someone will add elements to our segment
334 // to be able to update the view.
335 bool is_my_seg_edited = false;
336 {
337 bool is_found = false;
338 for (const Int32 rank_asked : m_target_segments) {
339 if (rank_asked == machine_rank) {
340 if (!is_found) {
341 is_found = true;
342 }
343 else {
344 ARCCORE_FATAL("Two subdomains ask same rank for addToAnotherSegment()");
345 }
346 }
347 if (rank_asked == m_comm_machine_rank) {
348 is_my_seg_edited = true;
349 }
350 }
351 }
352
353 Span<std::byte> rank_reserved_part_span;
354 {
355 MPI_Aint size_seg;
356 std::byte* ptr_seg = nullptr;
357 int size_type;
358 int error = MPI_Win_shared_query(m_all_mpi_win[machine_rank], machine_rank, &size_seg, &size_type, &ptr_seg);
359
360 if (error != MPI_SUCCESS) {
361 ARCCORE_FATAL("Error with MPI_Win_shared_query() call");
362 }
363 rank_reserved_part_span = Span<std::byte>{ ptr_seg, size_seg };
364 }
365
366 const Int64 actual_sizeof_win = m_sizeof_used_part[machine_rank];
367 const Int64 future_sizeof_win = actual_sizeof_win + elem.size();
368 const Int64 old_reserved = rank_reserved_part_span.size();
369
370 if (future_sizeof_win > old_reserved) {
371 _reallocBarrier(machine_rank, future_sizeof_win);
372
373 {
374 MPI_Aint size_seg;
375 std::byte* ptr_seg = nullptr;
376 int size_type;
377 int error = MPI_Win_shared_query(m_all_mpi_win[machine_rank], machine_rank, &size_seg, &size_type, &ptr_seg);
378
379 if (error != MPI_SUCCESS) {
380 ARCCORE_FATAL("Error with MPI_Win_shared_query() call");
381 }
382 rank_reserved_part_span = Span<std::byte>{ ptr_seg, size_seg };
383 }
384
385 if (rank_reserved_part_span.size() < future_sizeof_win) {
386 ARCCORE_FATAL("Bad realloc -- Old size : {0} -- New size : {1} -- Needed size : {2}", old_reserved, rank_reserved_part_span.size(), future_sizeof_win);
387 }
388 }
389 else {
390 _reallocBarrier();
391 }
392
393 for (Int64 pos_win = actual_sizeof_win, pos_elem = 0; pos_win < future_sizeof_win; ++pos_win, ++pos_elem) {
394 rank_reserved_part_span[pos_win] = elem[pos_elem];
395 }
396 m_sizeof_used_part[machine_rank] = future_sizeof_win;
397
398 // Barrier because others might use the segment size
399 // (m_sizeof_used_part) that we possess (segmentView(Int32 machine_rank) for
400 // example).
401 MPI_Barrier(m_comm_machine);
402 m_target_segments[m_comm_machine_rank] = -1;
403
404 // We update our view.
405 if (is_my_seg_edited) {
406 MPI_Aint size_seg;
407 std::byte* ptr_seg = nullptr;
408 int size_type;
409 int error = MPI_Win_shared_query(m_all_mpi_win[m_comm_machine_rank], m_comm_machine_rank, &size_seg, &size_type, &ptr_seg);
410
411 if (error != MPI_SUCCESS) {
412 ARCCORE_FATAL("Error with MPI_Win_shared_query() call");
413 }
414 m_reserved_part_span = Span<std::byte>{ ptr_seg, size_seg };
415 }
416}
417
418/*---------------------------------------------------------------------------*/
419/*---------------------------------------------------------------------------*/
420
421void MpiMachineShMemWinBaseInternal::
422addToAnotherSegment()
423{
424 // Even if we don't add anything, another process might add
425 // elements to our segment.
426 MPI_Barrier(m_comm_machine);
427
428 bool is_my_seg_edited = false;
429 for (const Int32 rank : m_target_segments) {
430 if (rank == m_comm_machine_rank) {
431 is_my_seg_edited = true;
432 break;
433 }
434 }
435
436 _reallocBarrier();
437 MPI_Barrier(m_comm_machine);
438
439 if (is_my_seg_edited) {
440 MPI_Aint size_seg;
441 std::byte* ptr_seg = nullptr;
442 int size_type;
443 int error = MPI_Win_shared_query(m_all_mpi_win[m_comm_machine_rank], m_comm_machine_rank, &size_seg, &size_type, &ptr_seg);
444
445 if (error != MPI_SUCCESS) {
446 ARCCORE_FATAL("Error with MPI_Win_shared_query() call");
447 }
448 m_reserved_part_span = Span<std::byte>{ ptr_seg, size_seg };
449 }
450}
451
452/*---------------------------------------------------------------------------*/
453/*---------------------------------------------------------------------------*/
454
455void MpiMachineShMemWinBaseInternal::
456reserve(Int64 new_capacity)
457{
458 if (new_capacity <= m_reserved_part_span.size()) {
459 _reallocBarrier();
460 }
461 else {
462 _reallocBarrier(new_capacity);
463 }
464}
465
466/*---------------------------------------------------------------------------*/
467/*---------------------------------------------------------------------------*/
468
469void MpiMachineShMemWinBaseInternal::
470reserve()
471{
472 _reallocBarrier();
473}
474
475/*---------------------------------------------------------------------------*/
476/*---------------------------------------------------------------------------*/
477
478void MpiMachineShMemWinBaseInternal::
479resize(Int64 new_size)
480{
481 if (new_size == -1) {
482 _reallocBarrier();
483 MPI_Barrier(m_comm_machine);
484 return;
485 }
486
487 if (new_size < 0 || new_size % m_sizeof_type) {
488 ARCCORE_FATAL("new_size not valid");
489 }
490
491 Int64 old_reserved = m_reserved_part_span.size();
492
493 if (new_size > old_reserved) {
494 _reallocBarrier(new_size);
495 if (m_reserved_part_span.size() < new_size) {
496 ARCCORE_FATAL("Bad realloc -- Old size : {0} -- New size : {1} -- Needed size : {2}", old_reserved, m_reserved_part_span.size(), new_size);
497 }
498 }
499 else {
500 _reallocBarrier();
501 }
502 m_sizeof_used_part[m_comm_machine_rank] = new_size;
503
504 // Barrier because others might use the segment size
505 // (m_sizeof_used_part) that we possess (segmentView(Int32 rank) for
506 // example).
507 MPI_Barrier(m_comm_machine);
508}
509
510/*---------------------------------------------------------------------------*/
511/*---------------------------------------------------------------------------*/
512
513void MpiMachineShMemWinBaseInternal::
514resize()
515{
516 _reallocBarrier();
517 MPI_Barrier(m_comm_machine);
518}
519
520/*---------------------------------------------------------------------------*/
521/*---------------------------------------------------------------------------*/
522
523void MpiMachineShMemWinBaseInternal::
524shrink()
525{
526 if (m_reserved_part_span.size() == m_sizeof_used_part[m_comm_machine_rank]) {
527 _reallocBarrier();
528 }
529 else {
530 _reallocBarrier(m_sizeof_used_part[m_comm_machine_rank]);
531 }
532}
533
534/*---------------------------------------------------------------------------*/
535/*---------------------------------------------------------------------------*/
536
537void MpiMachineShMemWinBaseInternal::
538_reallocBarrier(Int64 new_sizeof)
539{
540 m_need_resize[m_comm_machine_rank] = new_sizeof;
541
542 // Important barrier because everyone must know that we must
543 // resize the segment that we possess.
544 MPI_Barrier(m_comm_machine);
545
546 _reallocCollective();
547
548 // No need for a barrier because MPI_Win_allocate_shared() from
549 // _reallocCollective() is blocking.
550 m_need_resize[m_comm_machine_rank] = -1;
551
552 // Important barrier in the case where an MPI_Win_shared_query() from
553 // _reallocCollective() would last too long (another process could
554 // call this method and set m_need_resize[m_comm_machine_rank] to
555 // true => deadlock in _reallocCollective() on MPI_Win_allocate_shared()
556 // because of the continue).
557 MPI_Barrier(m_comm_machine);
558}
559
560/*---------------------------------------------------------------------------*/
561/*---------------------------------------------------------------------------*/
562
563void MpiMachineShMemWinBaseInternal::
564_reallocBarrier(Int32 machine_rank, Int64 new_sizeof)
565{
566 m_need_resize[machine_rank] = new_sizeof;
567
568 // Important barrier because everyone must know that we must
569 // resize the segment that we possess.
570 MPI_Barrier(m_comm_machine);
571
572 _reallocCollective();
573
574 // No need for a barrier because MPI_Win_allocate_shared() from
575 // _reallocCollective() is blocking.
576 m_need_resize[machine_rank] = -1;
577
578 // Important barrier in the case where an MPI_Win_shared_query() from
579 // _reallocCollective() would last too long (another process could
580 // call this method and set m_need_resize[machine_rank] to
581 // true => deadlock in _reallocCollective() on MPI_Win_allocate_shared()
582 // because of the continue).
583 MPI_Barrier(m_comm_machine);
584}
585
586/*---------------------------------------------------------------------------*/
587/*---------------------------------------------------------------------------*/
588
589void MpiMachineShMemWinBaseInternal::
590_reallocBarrier()
591{
592 MPI_Barrier(m_comm_machine);
593 _reallocCollective();
594 MPI_Barrier(m_comm_machine);
595}
596
597/*---------------------------------------------------------------------------*/
598/*---------------------------------------------------------------------------*/
599
600void MpiMachineShMemWinBaseInternal::
601_reallocCollective()
602{
603 MPI_Info win_info;
604 MPI_Info_create(&win_info);
605 MPI_Info_set(win_info, "alloc_shared_noncontig", "true");
606
607 for (Integer i = 0; i < m_comm_machine_size; ++i) {
608 if (m_need_resize[i] == -1)
609 continue;
610
611 ARCCORE_ASSERT(m_need_resize[i] >= 0, ("New size must be >= 0"));
612 ARCCORE_ASSERT(m_need_resize[i] % m_sizeof_type == 0, ("New size must be % sizeof type"));
613
614 const Int64 size_seg = (m_comm_machine_rank == i ? (m_need_resize[i] == 0 ? m_sizeof_type : m_need_resize[i]) : 0);
615
616 MPI_Win old_win = m_all_mpi_win[i];
617
618 std::byte* ptr_seg = nullptr;
619
620 // If size_seg == 0 then ptr_seg == nullptr.
621 int error = MPI_Win_allocate_shared(size_seg, m_sizeof_type, win_info, m_comm_machine, &ptr_seg, &m_all_mpi_win[i]);
622 if (error != MPI_SUCCESS) {
623 MPI_Info_free(&win_info);
624 ARCCORE_FATAL("Error with MPI_Win_allocate_shared() call");
625 }
626
627 if (m_comm_machine_rank == i) {
628
629 MPI_Aint mpi_reserved_size_seg;
630 int size_type;
631
632 // Here, ptr_seg is never == nullptr since we always create a segment of at least
633 // m_sizeof_type size.
634 error = MPI_Win_shared_query(m_all_mpi_win[m_comm_machine_rank], m_comm_machine_rank, &mpi_reserved_size_seg, &size_type, &ptr_seg);
635 if (error != MPI_SUCCESS || ptr_seg == nullptr) {
636 MPI_Win_free(&old_win);
637 MPI_Info_free(&win_info);
638 ARCCORE_FATAL("Error with MPI_Win_shared_query() call");
639 }
640
641 const Int64 min_size = std::min(m_need_resize[i], m_sizeof_used_part[m_comm_machine_rank]);
642 memcpy(ptr_seg, m_reserved_part_span.data(), min_size);
643
644 m_reserved_part_span = Span<std::byte>{ ptr_seg, mpi_reserved_size_seg };
645 }
646 MPI_Win_free(&old_win);
647 }
648 MPI_Info_free(&win_info);
649}
650
651/*---------------------------------------------------------------------------*/
652/*---------------------------------------------------------------------------*/
653
654Int32 MpiMachineShMemWinBaseInternal::
655_worldToMachine(Int32 world) const
656{
657 for (Int32 i = 0; i < m_comm_machine_size; ++i) {
658 if (m_machine_ranks[i] == world) {
659 return i;
660 }
661 }
662 ARCCORE_FATAL("Rank is not in machine");
663}
664
665/*---------------------------------------------------------------------------*/
666/*---------------------------------------------------------------------------*/
667
668Int32 MpiMachineShMemWinBaseInternal::
669_machineToWorld(Int32 machine) const
670{
671 return m_machine_ranks[machine];
672}
673
674/*---------------------------------------------------------------------------*/
675/*---------------------------------------------------------------------------*/
676
677} // namespace Arcane::MessagePassing::Mpi
678
679/*---------------------------------------------------------------------------*/
680/*---------------------------------------------------------------------------*/
#define ARCCORE_FATAL(...)
Macro throwing a FatalErrorException.
Constant view of an array of type T.
Span< Int64 > m_sizeof_used_part
Global view on contiguous window with the size of the primary windows.
constexpr __host__ __device__ SizeType size() const noexcept
Returns the size of the array.
Definition Span.h:327
View of an array of elements of type T.
Definition Span.h:635
std::int64_t Int64
Signed integer type of 64 bits.
std::int32_t Int32
Signed integer type of 32 bits.