Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ParallelMngInternal.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/* ParallelMngInternal.cc (C) 2000-2026 */
9/* */
10/* Implementation of the internal Arcane part of IParallelMng. */
11/*---------------------------------------------------------------------------*/
12
13#include "arcane/core/internal/ParallelMngInternal.h"
14
16#include "arcane/accelerator/core/RunQueueBuildInfo.h"
17
18#include "arcane/core/ParallelMngDispatcher.h"
19
20#include "arcane/utils/Convert.h"
21#include "arcane/utils/FatalErrorException.h"
22#include "arcane/utils/NotImplementedException.h"
23
24#include "arccore/common/MemoryAllocationOptions.h"
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29namespace Arcane
30{
31
32/*---------------------------------------------------------------------------*/
33/*---------------------------------------------------------------------------*/
34
35ParallelMngInternal::
36ParallelMngInternal(ParallelMngDispatcher* pm)
37: m_parallel_mng(pm)
39, m_queue(makeQueue(m_runner))
40{
41 if (auto v = Convert::Type<Int32>::tryParseFromEnvironment("ARCANE_DISABLE_ACCELERATOR_AWARE_MESSAGE_PASSING", true))
42 m_is_accelerator_aware_disabled = (v.value() != 0);
43}
44
45/*---------------------------------------------------------------------------*/
46/*---------------------------------------------------------------------------*/
47
48Runner ParallelMngInternal::
49runner() const
50{
51 return m_runner;
52}
53
54/*---------------------------------------------------------------------------*/
55/*---------------------------------------------------------------------------*/
56
57RunQueue ParallelMngInternal::
58queue() const
59{
60 return m_queue;
61}
62
63/*---------------------------------------------------------------------------*/
64/*---------------------------------------------------------------------------*/
65
66bool ParallelMngInternal::
67isAcceleratorAware() const
68{
69 if (m_is_accelerator_aware_disabled)
70 return false;
71 if (m_queue.isNull())
72 return false;
73 if (!m_queue.isAcceleratorPolicy())
74 return false;
75 return m_parallel_mng->_isAcceleratorAware();
76}
77
78/*---------------------------------------------------------------------------*/
79/*---------------------------------------------------------------------------*/
80
81void ParallelMngInternal::
82setDefaultRunner(const Runner& runner)
83{
84 if (!m_runner.isInitialized())
85 ARCANE_FATAL("Can not set an unitialized Runner");
86
87 // Be careful to delete the reference on the RunQueue
88 // before destroying the Runner because if there are no other
89 // references on m_runner it will be destroyed with m_queue
90 // and the latter will have a destroyed m_runner.
91 m_queue = RunQueue{};
92 m_runner = runner;
93 Accelerator::RunQueueBuildInfo build_info(-5);
94 m_queue = makeQueue(m_runner, build_info);
95 m_queue.setAsync(true);
96}
97
98/*---------------------------------------------------------------------------*/
99/*---------------------------------------------------------------------------*/
100
101Int32 ParallelMngInternal::
102masterParallelIORank() const
103{
104 return m_parallel_mng->masterIORank();
105}
106
107/*---------------------------------------------------------------------------*/
108/*---------------------------------------------------------------------------*/
109
110Int32 ParallelMngInternal::
111nbSendersToMasterParallelIO() const
112{
113 return m_parallel_mng->commSize();
114}
115
116/*---------------------------------------------------------------------------*/
117/*---------------------------------------------------------------------------*/
118
119Ref<IParallelMng> ParallelMngInternal::
120createSubParallelMngRef(Int32 color, Int32 key)
121{
122 return m_parallel_mng->_createSubParallelMngRef(color, key);
123}
124
125/*---------------------------------------------------------------------------*/
126/*---------------------------------------------------------------------------*/
127
128void ParallelMngInternal::
129initializeWindowCreator()
130{
131 ARCANE_THROW(NotImplementedException, "MachineWindow is not available in your ParallelMng");
132}
133
134/*---------------------------------------------------------------------------*/
135/*---------------------------------------------------------------------------*/
136
137bool ParallelMngInternal::
138isMachineShMemWinAvailable()
139{
140 return false;
141}
142
143/*---------------------------------------------------------------------------*/
144/*---------------------------------------------------------------------------*/
145
147createContigMachineShMemWinBase([[maybe_unused]] Int64 sizeof_segment,
148 [[maybe_unused]] Int32 sizeof_type)
149{
150 ARCANE_THROW(NotImplementedException, "MachineWindow is not available in your ParallelMng");
151}
152
153/*---------------------------------------------------------------------------*/
154/*---------------------------------------------------------------------------*/
155
157createMachineShMemWinBase([[maybe_unused]] Int64 sizeof_segment,
158 [[maybe_unused]] Int32 sizeof_type)
159{
160 ARCANE_THROW(NotImplementedException, "MachineWindow is not available in your ParallelMng");
161}
162
163/*---------------------------------------------------------------------------*/
164/*---------------------------------------------------------------------------*/
165
166MemoryAllocationOptions ParallelMngInternal::
167machineShMemWinMemoryAllocator()
168{
169 ARCANE_THROW(NotImplementedException, "MachineWindow is not available in your ParallelMng");
170}
171
172/*---------------------------------------------------------------------------*/
173/*---------------------------------------------------------------------------*/
174
175ConstArrayView<Int32> ParallelMngInternal::
176machineRanks()
177{
178 ARCANE_THROW(NotImplementedException, "MachineWindow is not available in your ParallelMng");
179}
180
181/*---------------------------------------------------------------------------*/
182/*---------------------------------------------------------------------------*/
183
184void ParallelMngInternal::
185machineBarrier()
186{
187 ARCANE_THROW(NotImplementedException, "MachineWindow is not available in your ParallelMng");
188}
189
190/*---------------------------------------------------------------------------*/
191/*---------------------------------------------------------------------------*/
192
193} // namespace Arcane
194
195/*---------------------------------------------------------------------------*/
196/*---------------------------------------------------------------------------*/
#define ARCANE_THROW(exception_class,...)
Macro for throwing an exception with formatting.
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Constant view of an array of type T.
Redirects the message management of sub-domains according to the argument type.
Reference to an instance.
RunQueue makeQueue(const Runner &runner)
Creates a queue associated with runner.
eExecutionPolicy
Execution policy for a Runner.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
std::int32_t Int32
Signed integer type of 32 bits.