Arcane  v3.16.6.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
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane::MessagePassing::Mpi
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28MpiMachineMemoryWindowBaseInternalCreator::
29MpiMachineMemoryWindowBaseInternalCreator(const MPI_Comm& comm_machine, Int32 comm_machine_rank, Int32 comm_machine_size, const MPI_Comm& comm_world, Int32 comm_world_size)
30: m_comm_machine(comm_machine)
31, m_comm_machine_rank(comm_machine_rank)
32, m_comm_machine_size(comm_machine_size)
33{
34 UniqueArray<Int32> global_ranks(comm_world_size);
35 UniqueArray<Int32> machine_ranks(comm_world_size);
36
37 for (Int32 i = 0; i < comm_world_size; ++i) {
38 global_ranks[i] = i;
39 }
40 MPI_Group comm_world_group;
41 MPI_Comm_group(comm_world, &comm_world_group);
42
43 MPI_Group machine_comm_group;
44 MPI_Comm_group(m_comm_machine, &machine_comm_group);
45
46 MPI_Group_translate_ranks(comm_world_group, comm_world_size, global_ranks.data(), machine_comm_group, machine_ranks.data());
47
48 m_machine_ranks.resize(m_comm_machine_size);
49
50 Int32 iter = 0;
51 for (Int32 i = 0; i < comm_world_size; ++i) {
52 if (machine_ranks[i] != MPI_UNDEFINED) {
53 m_machine_ranks[iter++] = i;
54 }
55 }
56 if (iter != m_comm_machine_size) {
57 ARCCORE_FATAL("Error in machine_ranks creation");
58 }
59}
60
61/*---------------------------------------------------------------------------*/
62/*---------------------------------------------------------------------------*/
63
64MpiMachineMemoryWindowBaseInternal* MpiMachineMemoryWindowBaseInternalCreator::
65createWindow(Int64 sizeof_segment, Int32 sizeof_type) const
66{
67 return new MpiMachineMemoryWindowBaseInternal(sizeof_segment, sizeof_type, m_comm_machine, m_comm_machine_rank, m_comm_machine_size, m_machine_ranks);
68}
69
70/*---------------------------------------------------------------------------*/
71/*---------------------------------------------------------------------------*/
72
73ConstArrayView<Int32> MpiMachineMemoryWindowBaseInternalCreator::
74machineRanks() const
75{
76 return m_machine_ranks;
77}
78
79/*---------------------------------------------------------------------------*/
80/*---------------------------------------------------------------------------*/
81
82} // namespace Arcane::MessagePassing::Mpi
83
84/*---------------------------------------------------------------------------*/
85/*---------------------------------------------------------------------------*/
std::int32_t Int32
Type entier signé sur 32 bits.