Arcane  v3.16.0.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
MpiDatatype.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/* MpiAdapter.cc (C) 2000-2025 */
9/* */
10/* Gestionnaire de parallélisme utilisant MPI. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arccore/base/TraceInfo.h"
15#include "arccore/base/String.h"
16#include "arccore/base/FatalErrorException.h"
17
18#include "arccore/message_passing_mpi/MpiDatatype.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane::MessagePassing::Mpi
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29MpiDatatype::
30MpiDatatype(MPI_Datatype datatype)
31: m_datatype(datatype)
32, m_reduce_operator(new BuiltInMpiReduceOperator())
33, m_is_built_in(true)
34{
35}
36
37MpiDatatype::
38MpiDatatype(MPI_Datatype datatype,bool is_built_in,IMpiReduceOperator* reduce_operator)
39: m_datatype(datatype)
40, m_reduce_operator(reduce_operator)
41, m_is_built_in(is_built_in)
42{
43}
44
45/*---------------------------------------------------------------------------*/
46/*---------------------------------------------------------------------------*/
47
48MpiDatatype::
49~MpiDatatype()
50{
51 if (!m_is_built_in){
52 if (m_datatype!=MPI_DATATYPE_NULL)
53 MPI_Type_free(&m_datatype);
54 }
55 m_datatype = MPI_DATATYPE_NULL;
56 delete m_reduce_operator;
57}
58
59/*---------------------------------------------------------------------------*/
60/*---------------------------------------------------------------------------*/
61
62/*---------------------------------------------------------------------------*/
63/*---------------------------------------------------------------------------*/
64
65MPI_Op BuiltInMpiReduceOperator::
66reduceOperator(eReduceType rt)
67{
68 // TODO: a fusionner avec reduceOperator de StdMpiReduceOperator.
69 MPI_Op op = MPI_OP_NULL;
70 switch(rt){
71 case ReduceMax: op = MPI_MAX; break;
72 case ReduceMin: op = MPI_MIN; break;
73 case ReduceSum: op = MPI_SUM; break;
74 }
75 if (op==MPI_OP_NULL)
76 ARCCORE_FATAL("Reduce operation unknown or not implemented");
77 return op;
78}
79
80/*---------------------------------------------------------------------------*/
81/*---------------------------------------------------------------------------*/
82
83template class StdMpiReduceOperator<float>;
84template class StdMpiReduceOperator<double>;
85template class StdMpiReduceOperator<long double>;
86
87/*---------------------------------------------------------------------------*/
88/*---------------------------------------------------------------------------*/
89
90}
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
@ ReduceSum
Somme des valeurs.
@ ReduceMin
Minimum des valeurs.
@ ReduceMax
Maximum des valeurs.