Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_EReductionType.cpp
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 
12 
13 namespace Teuchos {
14 
15 #ifdef HAVE_TEUCHOS_MPI
16 namespace Details {
17 
18 MPI_Op
19 getMpiOpForEReductionType (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 
36 const char*
37 toString (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
EReductionType
Predefined reduction operations that Teuchos::Comm understands.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
std::string toString(const HashSet< Key > &h)
Declaration of Teuchos::EReductionType enum, and related functions.
Standard test and throw macros.