Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_EReductionType.cpp
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
12
13namespace Teuchos {
14
15#ifdef HAVE_TEUCHOS_MPI
16namespace Details {
17
18MPI_Op
19getMpiOpForEReductionType (const enum EReductionType reductionType)
20{
21 switch (reductionType) {
22 case REDUCE_SUM: return MPI_SUM;
23 case REDUCE_MIN: return MPI_MIN;
24 case REDUCE_MAX: return MPI_MAX;
25 case REDUCE_AND: return MPI_LAND; // logical AND, not bitwise AND
26 case REDUCE_BOR: return MPI_BOR; // bitwise OR
27 default:
28 TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,
29 "The given EReductionType value is invalid.");
30 }
31}
32
33} // namespace Details
34#endif // HAVE_TEUCHOS_MPI
35
36const char*
37toString (const EReductionType reductType)
38{
39 switch (reductType) {
40 case REDUCE_SUM: return "REDUCE_SUM";
41 case REDUCE_MIN: return "REDUCE_MIN";
42 case REDUCE_MAX: return "REDUCE_MAX";
43 case REDUCE_AND: return "REDUCE_AND";
44 case REDUCE_BOR: return "REDUCE_BOR";
45 default:
47 (true, std::invalid_argument, "Teuchos::toString(EReductionType): "
48 "Invalid EReductionType value " << reductType << ". Valid values "
49 "are REDUCE_SUM = " << REDUCE_SUM << ", REDUCE_MIN = " << REDUCE_MIN
50 << ", REDUCE_MAX = " << REDUCE_MIN << ", REDUCE_AND = " << REDUCE_AND
51 << ", and REDUCE_BOR = " << REDUCE_BOR
52 << ".");
53 }
54}
55
56} // namespace Teuchos
Declaration of Teuchos::EReductionType enum, and related functions.
Standard test and throw macros.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
Namespace of implementation details.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
@ REDUCE_AND
Logical AND.
@ REDUCE_BOR
Bitwise OR.