14#include "arcane/utils/ApplicationInfo.h"
15#include "arcane/utils/NullThreadMng.h"
16#include "arcane/utils/ITraceMng.h"
17#include "arcane/utils/PlatformUtils.h"
18#include "arcane/utils/ValueConvert.h"
19#include "arcane/utils/NotImplementedException.h"
20#include "arcane/utils/ArgumentException.h"
21#include "arcane/utils/FatalErrorException.h"
22#include "arcane/utils/CommandLineArguments.h"
24#include "arcane/parallel/IStat.h"
26#include "arccore/message_passing_mpi/internal/MpiAdapter.h"
27#include "arcane/parallel/mpi/MpiParallelMng.h"
28#include "arcane/parallel/mpi/MpiParallelDispatch.h"
29#include "arcane/parallel/mpi/MpiErrorHandler.h"
31#include "arcane/FactoryService.h"
32#include "arcane/IApplication.h"
33#include "arcane/ParallelSuperMngDispatcher.h"
35#include "arcane/impl/SequentialParallelSuperMng.h"
48class MpiParallelSuperMng
49:
public ParallelSuperMngDispatcher
54 ~MpiParallelSuperMng()
override;
57 void build()
override;
97 static void _ErrorHandler(MPI_Comm *,
int *, ...);
105: m_application(sbi.application())
106, m_thread_mng(nullptr)
108, m_is_parallel(false)
111, m_nb_local_sub_domain(1)
112, m_mpi_main_communicator(MPI_COMM_NULL)
113, m_main_communicator(MPI_COMM_NULL)
114, m_machine_communicator(MPI_COMM_NULL)
116, m_datatype_list(nullptr)
126~MpiParallelSuperMng()
131 delete m_datatype_list;
137 catch(
const Exception& ex){
142 m_error_handler.removeHandler();
163void MpiParallelSuperMng::
167 char*** argv =
nullptr;
169 Request::setNullRequest(
Request(0,
nullptr,MPI_REQUEST_NULL));
170 Communicator::setNullCommunicator(
Communicator(MPI_COMM_NULL));
173 argc = app_args.commandLineArgc();
174 argv = app_args.commandLineArgv();
178 int thread_wanted = MPI_THREAD_SERIALIZED;
179 int thread_provided = 0;
182#ifndef ARCANE_USE_MPC
184 MPI_Query_thread(&thread_provided);
186 thread_provided = MPI_THREAD_MULTIPLE;
189 if (thread_provided < thread_wanted) {
192 MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);
194 app->
traceMng()->
info() <<
"WARNING: MPI thread level provided!=wanted ("
195 << thread_provided <<
"!=" << thread_wanted <<
")";
202void MpiParallelSuperMng::
203_ErrorHandler(MPI_Comm* comm,
int* error_code, ...)
207 char error_buf[MPI_MAX_ERROR_STRING+1];
211 MPI_Error_string(e,error_buf,&error_len);
212 error_buf[error_len] =
'\0';
213 error_buf[MPI_MAX_ERROR_STRING] =
'\0';
217 ARCANE_FATAL(
"Error in MPI call code={0} msg={1}",*error_code,error_buf);
239 MPI_Comm mpi_machine_communicator = MPI_COMM_NULL;
240 MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, rank, MPI_INFO_NULL, &mpi_machine_communicator);
244#ifndef ARCANE_USE_MPC
249 tm->
info() <<
"MPI has non blocking collective";
250 tm->
info() <<
"MPI: sizeof(MPI_Count)=" <<
sizeof(MPI_Count);
252 tm->
info() <<
"MPI: init_time (seconds)=" << (end_time-start_time);
258 auto astat = m_stat->toArccoreStat();
261 auto c = createBuiltInDispatcher<Byte>(tm,
nullptr,m_adapter,m_datatype_list);
262 auto i32 = createBuiltInDispatcher<Int32>(tm,
nullptr,m_adapter,m_datatype_list);
263 auto i64 = createBuiltInDispatcher<Int64>(tm,
nullptr,m_adapter,m_datatype_list);
264 auto r = createBuiltInDispatcher<Real>(tm,
nullptr,m_adapter,m_datatype_list);
265 _setDispatchers(c,i32,i64,r);
275 tm->
debug()<<
"[MpiParallelSuperMng::internalCreateWorldParallelMng]";
279 MPI_Comm comm = MPI_COMM_NULL;
282 MPI_Comm machine_comm = MPI_COMM_NULL;
287 MPI_Comm_rank(comm,&rank);
288 MPI_Comm_size(comm,&nb_rank);
290 bool is_parallel = nb_rank > 1;
293 bi.is_parallel = is_parallel;
296 bi.timer_mng =
nullptr;
297 bi.thread_mng = m_thread_mng;
298 bi.mpi_lock =
nullptr;
300 tm->
debug()<<
"[MpiParallelSuperMng::internalCreateWorldParallelMng] pm->build()";
312 m_application->traceMng()->info() <<
"MpiParallelSuperMng: rank " <<
m_rank <<
" calling MPI_Abort";
333class MpiSequentialParallelSuperMng
334:
public SequentialParallelSuperMng
342 ~MpiSequentialParallelSuperMng()
override
#define ARCANE_THROW(exception_class,...)
Macro pour envoyer une exception avec formattage.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
#define ARCANE_SERVICE_INTERFACE(ainterface)
Macro pour déclarer une interface lors de l'enregistrement d'un service.
const CommandLineArguments & commandLineArguments() const
Arguments de la ligne de commande.
Exception lorsqu'un argument est invalide.
Arguments de la ligne de commande.
Interface de l'application.
virtual const ApplicationInfo & applicationInfo() const =0
Informations sur l'exécutable.
virtual ITraceMng * traceMng() const =0
Gestionnaire de traces.
Interface d'un gestionnaire de thread.
Interface du gestionnaire de traces.
virtual TraceMessage info()=0
Flot pour un message d'information.
virtual TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium)=0
Flot pour un message de debug.
Communicateur pour l'échange de message.
void destroy()
Détruit l'instance. Elle ne doit plus être utilisée par la suite.
Gère les MPI_Datatype associées aux types Arcane.
Interface des messages pour le type Type.
bool isParallel() const override
Retourne true si l'exécution est parallèle.
void initialize() override
Initialise l'instance.
Int32 m_rank
Rang MPI dans le communicateur global de ce processus.
Int32 m_nb_local_sub_domain
Nombre de sous-domaines locaux.
Int32 commSize() const override
Retourne le nombre total de process utilisés.
Integer nbLocalSubDomain() override
Nombre de sous-domaines à créér localement.
IThreadMng * threadMng() const override
Gestionnaire de thread.
Int32 commRank() const override
Retourne le numéro du process (compris entre 0 et nbProcess()-1)
MP::Communicator m_machine_communicator
Communicateur MPI Machine.
Integer masterIORank() const override
Rang de l'instance gérant les entrées/sorties (pour laquelle isMasterIO() est vrai)
void barrier() override
Gestionnaire de parallèlisme pour l'ensemble des ressources allouées.
MP::Communicator m_main_communicator
Communicateur MPI.
MPI_Comm m_mpi_main_communicator
Communicateur MPI.
Ref< IParallelMng > internalCreateWorldParallelMng(Int32 local_rank) override
Créé un gestionnaire de parallélisme pour l'ensemble des coeurs alloués.
Int32 traceRank() const override
Rang de cette instance pour les traces.
bool isMasterIO() const override
true si l'instance est un gestionnaire maître des entrées/sorties.
IApplication * application() const override
Retourne le gestionnaire principal.
Int32 m_nb_rank
Nombre de processus MPI dans le communicateur global.
void tryAbort() override
Tente de faire un abort.
bool m_is_parallel
Statistiques.
void build() override
Construit les membres l'instance.
void * getMPICommunicator() override
Adresse du communicateur MPI associé à ce gestionnaire.
Parallel::Communicator communicator() const override
Communicateur MPI associé à ce gestionnaire.
IApplication * m_application
Gestionnaire principal.
void build() override
Construction de niveau build du service.
Gestionnaire de thread en mode mono-thread.
Statistiques sur le parallélisme.
Référence à une instance.
void build() override
Construction de niveau build du service.
IApplication * application() const override
Retourne le gestionnaire principal.
Structure contenant les informations pour créer un service.
#define ARCANE_REGISTER_SERVICE(aclass, a_service_property,...)
Macro pour enregistrer un service.
IStat * createDefaultStat()
Créé une instance par défaut.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Ref< TrueType > createRef(Args &&... args)
Créé une instance de type TrueType avec les arguments Args et retourne une référence dessus.
ARCANE_MPI_EXPORT void arcaneInitializeMPI(int *argc, char ***argv, int wanted_thread_level)
ARCANE_MPI_EXPORT bool arcaneIsAcceleratorAwareMPI()
Indique si le runtime actuel de MPI a le support des accélérateurs.
Int32 Integer
Type représentant un entier.
@ ST_Application
Le service s'utilise au niveau de l'application.
double Real
Type représentant un réel.
ARCANE_MPI_EXPORT void arcaneFinalizeMPI()
std::int32_t Int32
Type entier signé sur 32 bits.
Infos pour construire un MpiParallelMng.