Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
AlephKernel.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2023 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/* AlephKernel.h (C) 2000-2023 */
9/* */
10/* */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_ALEPH_KERNEL_H
13#define ARCANE_ALEPH_KERNEL_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/TraceAccessor.h"
18#include "arcane/utils/Array.h"
19#include "arcane/utils/FatalErrorException.h"
20#include "arcane/utils/Ref.h"
21#include "arcane/utils/CommandLineArguments.h"
22
23#include "arcane/core/IParallelMng.h"
24
25#include "arcane/aleph/AlephGlobal.h"
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30namespace Arcane
31{
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
37{
38 public:
39
40 Integer m_nb_iteration;
41 Real m_residual_norm[4];
42};
43
44/*---------------------------------------------------------------------------*/
45/*---------------------------------------------------------------------------*/
56{
57 public:
58
60
61 public:
62
63 bool hasValues() const { return m_has_values; }
64 void setCommandLineArguments(const CommandLineArguments& v)
65 {
66 m_arguments = v;
67 m_has_values = true;
68 }
69 const CommandLineArguments& commandLineArguments() const { return m_arguments; }
70
71 private:
72
73 bool m_has_values = false;
74 CommandLineArguments m_arguments;
75};
76
77/*---------------------------------------------------------------------------*/
78/*---------------------------------------------------------------------------*/
79
80class ARCANE_ALEPH_EXPORT AlephKernelArguments
81: public TraceAccessor
82{
83 public:
84
89 IAlephTopology* topology)
91 , m_x_vector(x_vector)
92 , m_b_vector(b_vector)
93 , m_tmp_vector(tmp_vector)
94 , m_topology_implementation(topology)
95 {} // m_params sera initialisé via le postSolver
96
98 {
99 debug() << "\33[1;5;31m[~AlephKernelArguments]"
100 << "\33[0m";
101 };
102
103 public:
104
105 AlephVector* m_x_vector;
106 AlephVector* m_b_vector;
107 AlephVector* m_tmp_vector;
108 IAlephTopology* m_topology_implementation;
109 AlephParams* m_params = nullptr;
110};
111
112/*---------------------------------------------------------------------------*/
113/*---------------------------------------------------------------------------*/
114
115class ARCANE_ALEPH_EXPORT AlephKernel
116: public TraceAccessor
117{
118 public:
119
120 static constexpr int SOLVER_HYPRE = 2;
121 static constexpr int SOLVER_TRILINOS = 3;
122 static constexpr int SOLVER_CUDA = 4;
123 static constexpr int SOLVER_PETSC = 5;
124
125 public:
126
127 AlephKernel(IParallelMng*, Integer, IAlephFactory*, Integer = 0, Integer = 0, bool = false);
128 AlephKernel(ITraceMng*, ISubDomain*, IAlephFactory*, Integer = 0, Integer = 0, bool = false);
129 AlephKernel(ISubDomain*, Integer alephUnderlyingSolver = 0, Integer alephNumberOfCores = 0);
130 ~AlephKernel(void);
131
132 public:
133
134 void setup(void);
135 void initialize(Integer, Integer);
136 void break_and_return(void);
137 AlephVector* createSolverVector(void);
138 AlephMatrix* createSolverMatrix(void);
139 void postSolver(AlephParams*, AlephMatrix*, AlephVector*, AlephVector*);
140 void workSolver(void);
141 AlephVector* syncSolver(Integer, Integer&, Real*);
142
143 public:
144
145 IAlephFactory* factory() { return m_factory; }
146 AlephTopology* topology() { return m_topology; }
147 AlephOrdering* ordering() { return m_ordering; }
148 AlephIndexing* indexing() { return m_indexing; }
149 Integer rank() { return m_rank; }
150 Integer size() { return m_size; }
151 ISubDomain* subDomain();
152 bool isParallel() { return m_isParallel; }
153 bool isInitialized() { return m_has_been_initialized; }
154 bool thereIsOthers() { return m_there_are_idles; }
155 bool isAnOther() { return m_i_am_an_other; }
156 IParallelMng* parallel() { return m_parallel; }
157 IParallelMng* world() { return m_world_parallel; }
158 Integer underlyingSolver() { return m_underlying_solver; }
159 bool isCellOrdering() { return m_reorder; }
160 Integer index() { return m_solver_index; }
161 bool configured() { return m_configured; }
162 void mapranks(Array<Integer>&);
163 bool hitranks(Integer, ArrayView<Integer>);
164 Integer nbRanksPerSolver() { return m_solver_size; }
165 ArrayView<Integer> solverRanks(Integer i) { return m_solver_ranks.at(i).view(); }
166 IParallelMng* subParallelMng(Integer i) { return m_sub_parallel_mng_queue.at(i).get(); }
167 IAlephTopology* getTopologyImplementation(Integer i)
168 {
169 return m_arguments_queue.at(i)->m_topology_implementation;
170 }
171 AlephKernelSolverInitializeArguments& solverInitializeArgs() { return m_solver_initialize_args; }
172
173 private:
174
175 Ref<IParallelMng> _createUnderlyingParallelMng(Integer);
176
177 private:
178
179 ISubDomain* m_sub_domain = nullptr;
180 bool m_isParallel;
181 Integer m_rank;
182 Integer m_size;
183 Integer m_world_size;
184 bool m_there_are_idles;
185 bool m_i_am_an_other;
186 IParallelMng* m_parallel;
187 IParallelMng* m_world_parallel;
188
189 private:
190
191 bool m_configured = false;
192 IAlephFactory* m_factory = nullptr;
193 AlephTopology* m_topology = nullptr;
194 AlephOrdering* m_ordering = nullptr;
195 AlephIndexing* m_indexing = nullptr;
196 Integer m_aleph_vector_idx;
197 const Integer m_underlying_solver;
198 const bool m_reorder;
199 Integer m_solver_index;
200 Integer m_solver_size;
201 bool m_solved;
202 bool m_has_been_initialized;
203 AlephKernelSolverInitializeArguments m_solver_initialize_args;
204
205 private:
206
207 UniqueArray<SharedArray<Integer>> m_solver_ranks;
208 UniqueArray<Ref<IParallelMng>> m_sub_parallel_mng_queue;
209 UniqueArray<AlephMatrix*> m_matrix_queue;
210 UniqueArray<AlephKernelArguments*> m_arguments_queue;
211 UniqueArray<AlephKernelResults*> m_results_queue;
212};
213
214/*---------------------------------------------------------------------------*/
215/*---------------------------------------------------------------------------*/
216
217} // namespace Arcane
218
219/*---------------------------------------------------------------------------*/
220/*---------------------------------------------------------------------------*/
221
222#endif
Gestionaire d'indexing.
Informations pour initialiser le solveur linéaire utilisé.
Definition AlephKernel.h:56
Matrice d'un système linéaire.
Definition AlephMatrix.h:33
Gestionnaire de reordering.
Paramètres d'un système linéraire.
Definition AlephParams.h:34
Informations sur l'environnement parallèle.
Vecteur d'un système linéaire.
Definition AlephVector.h:33
Arguments de la ligne de commande.
Interface du gestionnaire de parallélisme pour un sous-domaine.
Interface du gestionnaire d'un sous-domaine.
Definition ISubDomain.h:74
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Interface du gestionnaire de traces.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-