Arcane  v3.16.7.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
MpiMachineMemoryWindowBaseInternalCreator.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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/* MpiMachineMemoryWindowBaseInternalCreator.cc (C) 2000-2025 */
9/* */
10/* Classe permettant de créer des objets de type */
11/* MpiMachineMemoryWindowBaseInternal. */
12/*---------------------------------------------------------------------------*/
13
14#include "arccore/message_passing_mpi/internal/MpiMachineMemoryWindowBaseInternalCreator.h"
15
16#include "arccore/base/FatalErrorException.h"
17#include "arccore/message_passing_mpi/internal/MpiMachineMemoryWindowBaseInternal.h"
18#include "arccore/message_passing_mpi/internal/MpiDynamicMachineMemoryWindowBaseInternal.h"
19#include "arccore/message_passing_mpi/internal/MpiDynamicMultiMachineMemoryWindowBaseInternal.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane::MessagePassing::Mpi
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30MpiMachineMemoryWindowBaseInternalCreator::
31MpiMachineMemoryWindowBaseInternalCreator(const MPI_Comm& comm_machine, Int32 comm_machine_rank, Int32 comm_machine_size, const MPI_Comm& comm_world, Int32 comm_world_size)
32: m_comm_machine(comm_machine)
33, m_comm_machine_rank(comm_machine_rank)
34, m_comm_machine_size(comm_machine_size)
35{
36 UniqueArray<Int32> global_ranks(comm_world_size);
37 UniqueArray<Int32> machine_ranks(comm_world_size);
38
39 for (Int32 i = 0; i < comm_world_size; ++i) {
40 global_ranks[i] = i;
41 }
42 MPI_Group comm_world_group;
43 MPI_Comm_group(comm_world, &comm_world_group);
44
45 MPI_Group machine_comm_group;
46 MPI_Comm_group(m_comm_machine, &machine_comm_group);
47
48 MPI_Group_translate_ranks(comm_world_group, comm_world_size, global_ranks.data(), machine_comm_group, machine_ranks.data());
49
50 m_machine_ranks.resize(m_comm_machine_size);
51
52 Int32 iter = 0;
53 for (Int32 i = 0; i < comm_world_size; ++i) {
54 if (machine_ranks[i] != MPI_UNDEFINED) {
55 m_machine_ranks[iter++] = i;
56 }
57 }
58 if (iter != m_comm_machine_size) {
59 ARCCORE_FATAL("Error in machine_ranks creation");
60 }
61}
62
63/*---------------------------------------------------------------------------*/
64/*---------------------------------------------------------------------------*/
65
66MpiMachineMemoryWindowBaseInternal* MpiMachineMemoryWindowBaseInternalCreator::
67createWindow(Int64 sizeof_segment, Int32 sizeof_type) const
68{
69 return new MpiMachineMemoryWindowBaseInternal(sizeof_segment, sizeof_type, m_comm_machine, m_comm_machine_rank, m_comm_machine_size, m_machine_ranks);
70}
71
72/*---------------------------------------------------------------------------*/
73/*---------------------------------------------------------------------------*/
74
75MpiDynamicMachineMemoryWindowBaseInternal* MpiMachineMemoryWindowBaseInternalCreator::
76createDynamicWindow(Int64 sizeof_segment, Int32 sizeof_type) const
77{
78 return new MpiDynamicMachineMemoryWindowBaseInternal(sizeof_segment, sizeof_type, m_comm_machine, m_comm_machine_rank, m_comm_machine_size, m_machine_ranks);
79}
80
81/*---------------------------------------------------------------------------*/
82/*---------------------------------------------------------------------------*/
83
84MpiDynamicMultiMachineMemoryWindowBaseInternal* MpiMachineMemoryWindowBaseInternalCreator::
85createDynamicMultiWindow(SmallSpan<Int64> sizeof_segments, Int32 nb_segments_per_proc, Int32 sizeof_type) const
86{
87 return new MpiDynamicMultiMachineMemoryWindowBaseInternal(sizeof_segments, nb_segments_per_proc, sizeof_type, m_comm_machine, m_comm_machine_rank, m_comm_machine_size, m_machine_ranks);
88}
89
90/*---------------------------------------------------------------------------*/
91/*---------------------------------------------------------------------------*/
92
93ConstArrayView<Int32> MpiMachineMemoryWindowBaseInternalCreator::
94machineRanks() const
95{
96 return m_machine_ranks;
97}
98
99/*---------------------------------------------------------------------------*/
100/*---------------------------------------------------------------------------*/
101
102} // namespace Arcane::MessagePassing::Mpi
103
104/*---------------------------------------------------------------------------*/
105/*---------------------------------------------------------------------------*/
std::int32_t Int32
Type entier signé sur 32 bits.