12#ifndef ARCCORE_MESSAGEPASSINGMPI_MPIDATATYPE_H 
   13#define ARCCORE_MESSAGEPASSINGMPI_MPIDATATYPE_H 
   17#include "arccore/message_passing_mpi/MessagePassingMpiGlobal.h" 
   20#include "arccore/base/FatalErrorException.h" 
   27namespace Arcane::MessagePassing::Mpi
 
   55template<
typename RealType>
 
   56class StdMpiReduceOperator
 
   60  StdMpiReduceOperator(
bool is_commutative);
 
   64  MPI_Op m_min_operator;
 
   65  MPI_Op m_max_operator;
 
   66  MPI_Op m_sum_operator;
 
   68  static void ARCCORE_MPIOP_CALL _MinOperator(
void* a,
void* b,
int* len,MPI_Datatype* type);
 
   69  static void ARCCORE_MPIOP_CALL _MaxOperator(
void* a,
void* b,
int* len,MPI_Datatype* type);
 
   70  static void ARCCORE_MPIOP_CALL _SumOperator(
void* a,
void* b,
int* len,MPI_Datatype* type);
 
   71  void _create(
bool is_commutative);
 
 
   75template<
typename RealType> 
inline 
   79  m_min_operator = MPI_OP_NULL;
 
   80  m_max_operator = MPI_OP_NULL;
 
   81  m_sum_operator = MPI_OP_NULL;
 
   82  _create(is_commutative);
 
   85template<
typename RealType> 
inline 
   86void ARCCORE_MPIOP_CALL StdMpiReduceOperator<RealType>::
 
   87_MinOperator(
void* a,
void* b,
int* len,MPI_Datatype* type)
 
   90  RealType* ra = (RealType*)a;
 
   91  RealType* rb = (RealType*)b;
 
   96    rb[i] = std::min(va,vb);
 
  100template<
typename RealType> 
inline 
  101void ARCCORE_MPIOP_CALL StdMpiReduceOperator<RealType>::
 
  102_MaxOperator(
void* a,
void* b,
int* len,MPI_Datatype* type)
 
  104  ARCCORE_UNUSED(type);
 
  105  RealType* ra = (RealType*)a;
 
  106  RealType* rb = (RealType*)b;
 
  111    rb[i] = std::max(va,vb);
 
  115template<
typename RealType> 
inline 
  117_SumOperator(
void* a,
void* b,
int* len,MPI_Datatype* type)
 
  119  ARCCORE_UNUSED(type);
 
  120  RealType* ra = (RealType*)a;
 
  121  RealType* rb = (RealType*)b;
 
  130template<
typename RealType> 
inline 
  134  int commutative = (is_commutative) ? 1 : 0;
 
  135  MPI_Op_create(_MinOperator,commutative,&m_min_operator);
 
  136  MPI_Op_create(_MaxOperator,commutative,&m_max_operator);
 
  137  MPI_Op_create(_SumOperator,commutative,&m_sum_operator);
 
  140template<
typename RealType> 
inline 
  144  if (m_min_operator!=MPI_OP_NULL){
 
  145    MPI_Op_free(&m_min_operator);
 
  146    m_min_operator = MPI_OP_NULL;
 
  148  if (m_max_operator!=MPI_OP_NULL){
 
  149    MPI_Op_free(&m_max_operator);
 
  150    m_max_operator = MPI_OP_NULL;
 
  152  if (m_sum_operator!=MPI_OP_NULL){
 
  153    MPI_Op_free(&m_sum_operator);
 
  154    m_sum_operator = MPI_OP_NULL;
 
  161template<
typename RealType> 
inline 
  165  MPI_Op op = MPI_OP_NULL;
 
  167  case ReduceMax: op = m_max_operator; 
break;
 
  168  case ReduceMin: op = m_min_operator; 
break;
 
  169  case ReduceSum: op = m_sum_operator; 
break;
 
  172    ARCCORE_FATAL(
"Reduce operation unknown or not implemented");
 
  182class ARCCORE_MESSAGEPASSINGMPI_EXPORT MpiDatatype
 
  186  MpiDatatype(MPI_Datatype datatype);
 
  187  MpiDatatype(MPI_Datatype datatype,
bool is_built_in,
IMpiReduceOperator* reduce_operator);
 
  194    return m_reduce_operator->reduceOperator(reduce_type);
 
  196  MPI_Datatype datatype()
 const { 
return m_datatype; }
 
  204  MPI_Datatype m_datatype;
 
 
Opérateur de réduction interne MPI (MPI_MAX, MPI_MIN, MPI_SUM)
Opérateurs de réduction pour les types complexes (Real2, Real3, Real2x2 et Real3x3)
Opérateurs de réduction pour les types classiques.
Integer len(const char *s)
Retourne la longueur de la chaîne s.
eReduceType
Types des réductions supportées.
@ ReduceSum
Somme des valeurs.
@ ReduceMin
Minimum des valeurs.
@ ReduceMax
Maximum des valeurs.
Int32 Integer
Type représentant un entier.