Skip to content

Commit 9cc1e43

Browse files
ndellingwoodeeprude
authored andcommitted
trilinoscouplings: update ArithTraits namespace for KOKKOS_VERSION > 40799
Compatibility update corresponding to kokkos/kokkos-kernels#2771 Signed-off-by: Nathan Ellingwood <ndellin@sandia.gov>
1 parent a479c04 commit 9cc1e43

File tree

5 files changed

+68
-0
lines changed

5 files changed

+68
-0
lines changed

packages/trilinoscouplings/examples/fenl/BelosSolve.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
#define KOKKOS_EXAMPLE_BELOS_SOLVE
1919

2020
// Tpetra
21+
#if KOKKOS_VERSION > 40799
22+
#include "KokkosKernels_ArithTraits.hpp"
23+
#else
2124
#include "Kokkos_ArithTraits.hpp"
25+
#endif
2226
#include "Tpetra_MultiVector.hpp"
2327
#include "Tpetra_CrsMatrix.hpp"
2428

@@ -97,8 +101,16 @@ belos_solve(
97101
const int use_mean_based,
98102
const Teuchos::RCP<Teuchos::ParameterList>& fenlParams,
99103
const unsigned max_iter = 200,
104+
#if KOKKOS_VERSION > 40799
105+
const typename KokkosKernels::ArithTraits<SV>::mag_type tolerance =
106+
#else
100107
const typename Kokkos::ArithTraits<SV>::mag_type tolerance =
108+
#endif
109+
#if KOKKOS_VERSION > 40799
110+
KokkosKernels::ArithTraits<SV>::epsilon())
111+
#else
101112
Kokkos::ArithTraits<SV>::epsilon())
113+
#endif
102114
{
103115
typedef Tpetra::Operator<SM,LO,GO,N> OperatorType;
104116
typedef Tpetra::MultiVector<SV,LO,GO,N> VectorType;
@@ -240,8 +252,16 @@ belos_solve(
240252
const int use_mean_based,
241253
const Teuchos::RCP<Teuchos::ParameterList>& fenlParams,
242254
const unsigned max_iter = 200,
255+
#if KOKKOS_VERSION > 40799
256+
const typename KokkosKernels::ArithTraits<SV>::mag_type tolerance =
257+
#else
243258
const typename Kokkos::ArithTraits<SV>::mag_type tolerance =
259+
#endif
260+
#if KOKKOS_VERSION > 40799
261+
KokkosKernels::ArithTraits<SV>::epsilon())
262+
#else
244263
Kokkos::ArithTraits<SV>::epsilon())
264+
#endif
245265
{
246266
TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error,
247267
"Belos solver requested but not compiled!");

packages/trilinoscouplings/examples/fenl/CGSolve.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
#include <Kokkos_Core.hpp>
2323
#include <KokkosSparse_CrsMatrix.hpp>
2424
#include <Kokkos_Timer.hpp>
25+
#if KOKKOS_VERSION > 40799
26+
#include <KokkosKernels_ArithTraits.hpp>
27+
#else
2528
#include <Kokkos_ArithTraits.hpp>
29+
#endif
2630

2731
#include <Teuchos_CommHelpers.hpp>
2832
#include <Tpetra_CrsMatrix.hpp>
@@ -88,14 +92,26 @@ template<class CrsMatrix, class Vector>
8892
result_struct cg_solve(
8993
Teuchos::RCP<CrsMatrix> A, Teuchos::RCP<Vector> b, Teuchos::RCP<Vector> x,
9094
int max_iter = 200,
95+
#if KOKKOS_VERSION > 40799
96+
typename KokkosKernels::ArithTraits<typename CrsMatrix::scalar_type>::mag_type tolerance =
97+
#else
9198
typename Kokkos::ArithTraits<typename CrsMatrix::scalar_type>::mag_type tolerance =
99+
#endif
100+
#if KOKKOS_VERSION > 40799
101+
KokkosKernels::ArithTraits<typename CrsMatrix::scalar_type>::epsilon(),
102+
#else
92103
Kokkos::ArithTraits<typename CrsMatrix::scalar_type>::epsilon(),
104+
#endif
93105
int print = 0)
94106
{
95107
Kokkos::Timer total_timer;
96108

97109
typedef typename CrsMatrix::scalar_type ScalarType;
110+
#if KOKKOS_VERSION > 40799
111+
typedef KokkosKernels::ArithTraits<ScalarType> KAT;
112+
#else
98113
typedef Kokkos::ArithTraits<ScalarType> KAT;
114+
#endif
99115
typedef typename KAT::mag_type MagnitudeType;
100116
typedef typename CrsMatrix::local_ordinal_type LocalOrdinalType;
101117
Teuchos::RCP<Vector> r,p,Ap;

packages/trilinoscouplings/examples/fenl/SampleGrouping.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
#include "Teuchos_Comm.hpp"
1717
#include "BoxElemFixture.hpp"
1818
#include "HexElement.hpp"
19+
#if KOKKOS_VERSION > 40799
20+
#include "KokkosKernels_ArithTraits.hpp"
21+
#else
1922
#include "Kokkos_ArithTraits.hpp"
23+
#endif
2024

2125
namespace Kokkos {
2226
namespace Example {
@@ -133,10 +137,18 @@ class MaxAnisotropyGrouping : public virtual SampleGrouping<Scalar> {
133137
Kokkos::deep_copy( rv, hrv );
134138

135139
Ordinal num_elem = m_max_min_functor.m_elem_node_ids.extent(0);
140+
#if KOKKOS_VERSION > 40799
141+
Scalar local_coeff[2] = { 0.0, KokkosKernels::ArithTraits<Scalar>::max() };
142+
#else
136143
Scalar local_coeff[2] = { 0.0, Kokkos::ArithTraits<Scalar>::max() };
144+
#endif
137145
parallel_reduce( num_elem, m_max_min_functor, local_coeff );
138146

147+
#if KOKKOS_VERSION > 40799
148+
Scalar coeff[2] = { 0.0, KokkosKernels::ArithTraits<Scalar>::max() };
149+
#else
139150
Scalar coeff[2] = { 0.0, Kokkos::ArithTraits<Scalar>::max() };
151+
#endif
140152
Teuchos::reduceAll( *m_comm, Teuchos::REDUCE_MAX, 1, &local_coeff[0], &coeff[0] );
141153
Teuchos::reduceAll( *m_comm, Teuchos::REDUCE_MIN, 1, &local_coeff[1], &coeff[1] );
142154

@@ -272,7 +284,11 @@ class MaxAnisotropyGrouping : public virtual SampleGrouping<Scalar> {
272284
// The diffusion coefficient must be positive, so initializing the
273285
// result to zero is safe
274286
dst[0] = 0.0;
287+
#if KOKKOS_VERSION > 40799
288+
dst[1] = KokkosKernels::ArithTraits<Scalar>::max();
289+
#else
275290
dst[1] = Kokkos::ArithTraits<Scalar>::max();
291+
#endif
276292
}
277293

278294
};

packages/trilinoscouplings/examples/fenl/fenl.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434

3535
#include <Kokkos_Core.hpp>
3636
#include <KokkosSparse_CrsMatrix.hpp>
37+
#if KOKKOS_VERSION > 40799
38+
#include <KokkosKernels_ArithTraits.hpp>
39+
#else
3740
#include <Kokkos_ArithTraits.hpp>
41+
#endif
3842

3943
#include <SGPreconditioner.hpp>
4044

packages/trilinoscouplings/examples/fenl/fenl_impl.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
#include <Kokkos_UnorderedMap.hpp>
2525
#include <KokkosSparse_CrsMatrix.hpp>
2626
#include <Kokkos_Timer.hpp>
27+
#if KOKKOS_VERSION > 40799
28+
#include <KokkosKernels_ArithTraits.hpp>
29+
#else
2730
#include <Kokkos_ArithTraits.hpp>
31+
#endif
2832

2933
#include <Teuchos_CommHelpers.hpp>
3034
#include <Teuchos_ParameterList.hpp>
@@ -93,7 +97,11 @@ class Problem {
9397
typedef Device DeviceType;
9498
typedef BoxElemFixture< Device , ElemOrder > FixtureType ;
9599

100+
#if KOKKOS_VERSION > 40799
101+
typedef typename KokkosKernels::ArithTraits<Scalar>::mag_type Magnitude;
102+
#else
96103
typedef typename Kokkos::ArithTraits<Scalar>::mag_type Magnitude;
104+
#endif
97105

98106
typedef Tpetra::KokkosCompat::KokkosDeviceWrapperNode< Device > NodeType;
99107

@@ -712,7 +720,11 @@ Perf fenl(
712720
Teuchos::Array<Scalar>& response_gradient,
713721
const QuadratureData<Device>& qd = QuadratureData<Device>() )
714722
{
723+
#if KOKKOS_VERSION > 40799
724+
typedef typename KokkosKernels::ArithTraits<Scalar>::mag_type Magnitude;
725+
#else
715726
typedef typename Kokkos::ArithTraits<Scalar>::mag_type Magnitude;
727+
#endif
716728

717729
const unsigned newton_iteration_limit =
718730
fenlParams->get("Max Nonlinear Iterations", 10) ;

0 commit comments

Comments
 (0)