Teuchos - Trilinos Tools Package
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
comm
src
Teuchos_MpiReductionOpSetter.hpp
Go to the documentation of this file.
1
// @HEADER
2
// *****************************************************************************
3
// Teuchos: Common Tools Package
4
//
5
// Copyright 2004 NTESS and the Teuchos contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#ifndef TEUCHOS_MPI_REDUCTION_OP_SETTER_HPP
11
#define TEUCHOS_MPI_REDUCTION_OP_SETTER_HPP
12
20
21
#include <
Teuchos_ConfigDefs.hpp
>
22
23
#ifdef HAVE_MPI
24
#include "Teuchos_ReductionOp.hpp"
25
#include <mpi.h>
26
27
namespace
Teuchos
{
28
namespace
Details {
29
37
class
TEUCHOSCOMM_LIB_DLL_EXPORT MpiReductionOpBase :
38
virtual
public
Describable {
39
public
:
40
virtual
void
41
reduce
(
void
* invec,
void
* inoutvec,
42
int
* len, MPI_Datatype* datatype)
const
= 0;
43
};
44
51
template
<
typename
OrdinalType>
52
class
MpiReductionOp :
public
MpiReductionOpBase {
53
public
:
54
MpiReductionOp (
const
ValueTypeReductionOp<OrdinalType,char>& reductOp)
55
: reductOp_ (reductOp)
56
{}
57
58
void
59
reduce
(
void
* invec,
void
* inoutvec,
int
* len, MPI_Datatype* datatype)
const
60
{
61
#ifdef TEUCHOS_DEBUG
62
TEUCHOS_TEST_FOR_EXCEPT
(!len);
63
TEUCHOS_TEST_FOR_EXCEPT
(!datatype);
64
#endif
65
// mfh 23 Nov 2014: Ross made the unfortunate decision initially
66
// to mash everything into MPI_CHAR. This means that we have to
67
// do a lot of type casting here. Of course, most implementations
68
// of ValueTypeReductionOp will immediately cast back from char*
69
// to the actual type of interest.
70
int
sz;
71
MPI_Type_size (*datatype, &sz);
72
(void) datatype;
73
reductOp_.reduce ((*len) * sz,
reinterpret_cast<
char
*
>
(invec),
74
reinterpret_cast<
char
*
>
(inoutvec));
75
}
76
77
private
:
78
const
ValueTypeReductionOp<OrdinalType, char>& reductOp_;
79
// Not defined and not to be called
80
MpiReductionOp ();
81
MpiReductionOp (
const
MpiReductionOp&);
82
MpiReductionOp& operator= (
const
MpiReductionOp&);
83
};
84
93
TEUCHOSCOMM_LIB_DLL_EXPORT MPI_Op setMpiReductionOp (
const
MpiReductionOpBase& reductOp);
94
95
}
// namespace Details
96
}
// namespace Teuchos
97
98
#endif
// HAVE_MPI
99
100
#endif
// TEUCHOS_MPI_REDUCTION_OP_SETTER_HPP
Teuchos_ConfigDefs.hpp
Teuchos header file which uses auto-configuration information to include necessary C++ headers.
Teuchos::Comm::reduce
void reduce(const Packet sendBuf[], Packet recvBuf[], const Ordinal count, const EReductionType reductType, const Ordinal root, const Comm< Ordinal > &comm)
Wrapper for MPI_Reduce; reduction to one process, using a built-in reduction operator selected by enu...
Definition
Teuchos_CommHelpers.hpp:1403
TEUCHOS_TEST_FOR_EXCEPT
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
This macro is designed to be a short version of TEUCHOS_TEST_FOR_EXCEPTION() that is easier to call.
Definition
Teuchos_TestForException.hpp:285
Teuchos
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
Generated by
1.17.0