Skip to content

Commit 160a8b6

Browse files
ndellingwoodeeprude
authored andcommitted
shylu: 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 a298989 commit 160a8b6

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

packages/shylu/shylu_node/fastilu/src/shylu_fastic.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,16 @@ class FastICPrec
5454

5555
typedef Kokkos::RangePolicy<ExecSpace> RangePolicy;
5656

57+
#if KOKKOS_VERSION > 40799
58+
using STS = KokkosKernels::ArithTraits<Scalar>;
59+
#else
5760
using STS = Kokkos::ArithTraits<Scalar>;
61+
#endif
62+
#if KOKKOS_VERSION > 40799
63+
using RTS = KokkosKernels::ArithTraits<Real>;
64+
#else
5865
using RTS = Kokkos::ArithTraits<Real>;
66+
#endif
5967

6068
private:
6169
double computeTime;

packages/shylu/shylu_node/fastilu/src/shylu_fastildl.hpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,16 @@ class FastILDLPrec
5757

5858
typedef Kokkos::RangePolicy<ExecSpace> RangePolicy;
5959

60+
#if KOKKOS_VERSION > 40799
61+
using STS = KokkosKernels::ArithTraits<Scalar>;
62+
#else
6063
using STS = Kokkos::ArithTraits<Scalar>;
64+
#endif
65+
#if KOKKOS_VERSION > 40799
66+
using RTS = KokkosKernels::ArithTraits<Real>;
67+
#else
6168
using RTS = Kokkos::ArithTraits<Real>;
69+
#endif
6270

6371
private:
6472
double computeTime;
@@ -156,7 +164,11 @@ class FastILDLPrec
156164
blkSzILDL = blkSzILDL_;
157165
blkSz = blkSz_;
158166

167+
#if KOKKOS_VERSION > 40799
168+
const Scalar one = KokkosKernels::ArithTraits<Scalar>::one();
169+
#else
159170
const Scalar one = Kokkos::ArithTraits<Scalar>::one();
171+
#endif
160172
onesVector = ScalarArray("onesVector", nRow_);
161173
Kokkos::deep_copy(onesVector, one);
162174

@@ -618,7 +630,11 @@ class FastILDLPrec
618630
void applyDiagonalScaling()
619631
{
620632
int anext = 0;
633+
#if KOKKOS_VERSION > 40799
634+
const Real one = KokkosKernels::ArithTraits<Real>::one();
635+
#else
621636
const Real one = Kokkos::ArithTraits<Real>::one();
637+
#endif
622638
//First fill Aj and extract the diagonal scaling factors
623639
//Use diag array to store scaling factors since
624640
//it gets set to the correct value by findFactorPattern anyway.
@@ -659,7 +675,11 @@ class FastILDLPrec
659675

660676
void applyManteuffelShift()
661677
{
678+
#if KOKKOS_VERSION > 40799
679+
const Scalar one = KokkosKernels::ArithTraits<Scalar>::one();
680+
#else
662681
const Scalar one = Kokkos::ArithTraits<Scalar>::one();
682+
#endif
663683
//Scalar shift = 0.05;
664684
for (Ordinal i = 0; i < nRows; i++)
665685
{
@@ -759,7 +779,11 @@ class FastILDLPrec
759779

760780
void compute()
761781
{
782+
#if KOKKOS_VERSION > 40799
783+
const Scalar one = KokkosKernels::ArithTraits<Scalar>::one();
784+
#else
762785
const Scalar one = Kokkos::ArithTraits<Scalar>::one();
786+
#endif
763787
if((level > 0) && (guessFlag != 0))
764788
{
765789
initGuessPrec->compute();
@@ -953,8 +977,16 @@ class FastILDLFunctor
953977
KOKKOS_INLINE_FUNCTION
954978
void operator()(const Ordinal blk_index) const
955979
{
980+
#if KOKKOS_VERSION > 40799
981+
const Scalar zero = KokkosKernels::ArithTraits<Scalar>::zero();
982+
#else
956983
const Scalar zero = Kokkos::ArithTraits<Scalar>::zero();
984+
#endif
985+
#if KOKKOS_VERSION > 40799
986+
const Scalar one = KokkosKernels::ArithTraits<Scalar>::one();
987+
#else
957988
const Scalar one = Kokkos::ArithTraits<Scalar>::one();
989+
#endif
958990

959991
Ordinal start = blk_index * blk_size;
960992
Ordinal end = start + blk_size;

packages/shylu/shylu_node/fastilu/src/shylu_fastilu.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ void unfill_crs(View1& row_ptrs, View2& cols, View3& values)
6464
{
6565
using Scalar = typename View3::non_const_value_type;
6666
using Ordinal = typename View1::non_const_value_type;
67+
#if KOKKOS_VERSION > 40799
68+
using STS = KokkosKernels::ArithTraits<Scalar>;
69+
#else
6770
using STS = Kokkos::ArithTraits<Scalar>;
71+
#endif
6872
const Scalar zero = STS::zero();
6973

7074
const auto nrows = row_ptrs.size() - 1;
@@ -262,8 +266,16 @@ class FastILUPrec
262266
typedef typename OrdinalArray::host_mirror_type OrdinalArrayMirror;
263267
typedef typename ScalarArray::host_mirror_type ScalarArrayMirror;
264268

269+
#if KOKKOS_VERSION > 40799
270+
using STS = KokkosKernels::ArithTraits<Scalar>;
271+
#else
265272
using STS = Kokkos::ArithTraits<Scalar>;
273+
#endif
274+
#if KOKKOS_VERSION > 40799
275+
using RTS = KokkosKernels::ArithTraits<Real>;
276+
#else
266277
using RTS = Kokkos::ArithTraits<Real>;
278+
#endif
267279

268280
template <typename T>
269281
struct IdentityFunctor
@@ -2256,7 +2268,11 @@ class FastICFunctor
22562268
typedef Kokkos::View<Ordinal *, ExecSpace> ordinal_array_type;
22572269
typedef Kokkos::View<Scalar *, ExecSpace> scalar_array_type;
22582270

2271+
#if KOKKOS_VERSION > 40799
2272+
using STS = KokkosKernels::ArithTraits<Scalar>;
2273+
#else
22592274
using STS = Kokkos::ArithTraits<Scalar>;
2275+
#endif
22602276

22612277
FastICFunctor (Ordinal nNZ, Ordinal bs, ordinal_array_type Ap, ordinal_array_type Ai,
22622278
ordinal_array_type Aj, scalar_array_type Ax, ordinal_array_type Lp,
@@ -2436,7 +2452,11 @@ class FastILUFunctor
24362452
typedef Kokkos::View<Ordinal *, ExecSpace> ordinal_array_type;
24372453
typedef Kokkos::View<Scalar *, ExecSpace> scalar_array_type;
24382454

2455+
#if KOKKOS_VERSION > 40799
2456+
using STS = KokkosKernels::ArithTraits<Scalar>;
2457+
#else
24392458
using STS = Kokkos::ArithTraits<Scalar>;
2459+
#endif
24402460

24412461
FastILUFunctor (Ordinal nNZ, Ordinal bs,
24422462
ordinal_array_type Ap, ordinal_array_type Ai, ordinal_array_type Aj, scalar_array_type Ax,

packages/shylu/shylu_node/hts/src/shylu_hts_impl_def.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ inline int omp_get_thread_num () { return 0; }
5353
#endif
5454

5555
#ifdef HAVE_SHYLU_NODEHTS_KOKKOSKERNELS
56+
#if KOKKOS_VERSION > 40799
57+
# include <KokkosKernels_ArithTraits.hpp>
58+
#else
5659
# include <Kokkos_ArithTraits.hpp>
5760
#endif
61+
#endif
5862

5963
#include "shylu_hts_impl.hpp"
6064

@@ -1177,7 +1181,11 @@ Int partition_ir (const Int n, const Size* const ir, const Int nparts,
11771181

11781182
template <typename T> inline T& conjugate (T& v) {
11791183
#ifdef HAVE_SHYLU_NODEHTS_KOKKOSKERNELS
1184+
#if KOKKOS_VERSION > 40799
1185+
v = KokkosKernels::ArithTraits<T>::conj(v);
1186+
#else
11801187
v = Kokkos::ArithTraits<T>::conj(v);
1188+
#endif
11811189
#else
11821190
v = T(v.real(), -v.imag());
11831191
#endif

0 commit comments

Comments
 (0)