Arcane  v3.14.10.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-2022 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-2018 */
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 Arccore
24{
25namespace MessagePassing
26{
27namespace Mpi
28{
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33MpiDatatype::
34MpiDatatype(MPI_Datatype datatype)
35: m_datatype(datatype)
36, m_reduce_operator(new BuiltInMpiReduceOperator())
37, m_is_built_in(true)
38{
39}
40
41MpiDatatype::
42MpiDatatype(MPI_Datatype datatype,bool is_built_in,IMpiReduceOperator* reduce_operator)
43: m_datatype(datatype)
44, m_reduce_operator(reduce_operator)
45, m_is_built_in(is_built_in)
46{
47}
48
49/*---------------------------------------------------------------------------*/
50/*---------------------------------------------------------------------------*/
51
52MpiDatatype::
53~MpiDatatype()
54{
55 if (!m_is_built_in){
56 if (m_datatype!=MPI_DATATYPE_NULL)
57 MPI_Type_free(&m_datatype);
58 }
59 m_datatype = MPI_DATATYPE_NULL;
60 delete m_reduce_operator;
61}
62
63/*---------------------------------------------------------------------------*/
64/*---------------------------------------------------------------------------*/
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
68
69MPI_Op BuiltInMpiReduceOperator::
70reduceOperator(eReduceType rt)
71{
72 // TODO: a fusionner avec reduceOperator de StdMpiReduceOperator.
73 MPI_Op op = MPI_OP_NULL;
74 switch(rt){
75 case ReduceMax: op = MPI_MAX; break;
76 case ReduceMin: op = MPI_MIN; break;
77 case ReduceSum: op = MPI_SUM; break;
78 }
79 if (op==MPI_OP_NULL)
80 ARCCORE_FATAL("Reduce operation unknown or not implemented");
81 return op;
82}
83
84/*---------------------------------------------------------------------------*/
85/*---------------------------------------------------------------------------*/
86
87template class StdMpiReduceOperator<float>;
88template class StdMpiReduceOperator<double>;
89template class StdMpiReduceOperator<long double>;
90
91/*---------------------------------------------------------------------------*/
92/*---------------------------------------------------------------------------*/
93
94} // End namespace Mpi
95} // End namespace MessagePassing
96} // End namespace Arccore
97
98/*---------------------------------------------------------------------------*/
99/*---------------------------------------------------------------------------*/
@ ReduceMin
Minimum des valeurs.
@ ReduceSum
Somme des valeurs.
@ ReduceMax
Maximum des valeurs.
Espace de nom de Arccore.
Definition ArcaneTypes.h:24