Skip to content

Commit a479c04

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

File tree

66 files changed

+1380
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1380
-0
lines changed

packages/tpetra/core/example/advanced/Benchmarks/blockCrsMatrixMatVec.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ void localApplyBlockNoTrans(Tpetra::BlockCrsMatrix<Scalar, LO, GO, Node>& A,
4444
typedef Tpetra::BlockCrsMatrix<Scalar, LO, GO, Node>
4545
block_crs_matrix_type;
4646
typedef typename block_crs_matrix_type::impl_scalar_type IST;
47+
#if KOKKOS_VERSION > 40799
48+
typedef KokkosKernels::ArithTraits<IST> KAT;
49+
#else
4750
typedef Kokkos::ArithTraits<IST> KAT;
51+
#endif
4852
typedef typename block_crs_matrix_type::little_vec_type little_vec_type;
4953
typedef typename block_crs_matrix_type::little_block_type little_blk_type;
5054

@@ -449,7 +453,11 @@ getTpetraBlockCrsMatrix(Teuchos::FancyOStream& out,
449453
using Teuchos::rcp;
450454
typedef Tpetra::BlockCrsMatrix<> matrix_type;
451455
typedef matrix_type::impl_scalar_type SC;
456+
#if KOKKOS_VERSION > 40799
457+
typedef KokkosKernels::ArithTraits<SC> KAT;
458+
#else
452459
typedef Kokkos::ArithTraits<SC> KAT;
460+
#endif
453461
typedef Tpetra::Map<>::local_ordinal_type LO;
454462

455463
// mfh 02 Jun 2016: Prefer Kokkos::Serial to the host_mirror_type as the

packages/tpetra/core/inout/Tpetra_Details_CooMatrix.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,13 +621,21 @@ class CooMatrix : public ::Tpetra::DistObject<char, LO, GO, NT> {
621621
void
622622
buildCrs(::Kokkos::View<OffsetType*, device_type>& rowOffsets,
623623
::Kokkos::View<GO*, device_type>& gblColInds,
624+
#if KOKKOS_VERSION > 40799
625+
::Kokkos::View<typename ::KokkosKernels::ArithTraits<SC>::val_type*, device_type>& vals) {
626+
#else
624627
::Kokkos::View<typename ::Kokkos::ArithTraits<SC>::val_type*, device_type>& vals) {
628+
#endif
625629
static_assert(std::is_integral<OffsetType>::value,
626630
"OffsetType must be a built-in integer type.");
627631
using ::Kokkos::create_mirror_view;
628632
using ::Kokkos::deep_copy;
629633
using ::Kokkos::View;
634+
#if KOKKOS_VERSION > 40799
635+
typedef typename ::KokkosKernels::ArithTraits<SC>::val_type ISC;
636+
#else
630637
typedef typename ::Kokkos::ArithTraits<SC>::val_type ISC;
638+
#endif
631639

632640
const std::size_t numEnt = this->getLclNumEntries();
633641

packages/tpetra/core/inout/Tpetra_Details_ReadTriples.hpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121

2222
#include "TpetraCore_config.h"
2323
#include "Tpetra_Details_PackTriples.hpp"
24+
#if KOKKOS_VERSION > 40799
25+
#include "KokkosKernels_ArithTraits.hpp"
26+
#else
2427
#include "Kokkos_ArithTraits.hpp"
28+
#endif
2529
#include "Teuchos_MatrixMarket_generic.hpp"
2630
#include "Teuchos_CommHelpers.hpp"
2731
#include <iostream>
@@ -133,7 +137,11 @@ bool readComplexData(std::istream& istr,
133137
/// \tparam isComplex Whether SC is a complex-valued type.
134138
template <class SC,
135139
class GO,
140+
#if KOKKOS_VERSION > 40799
141+
const bool isComplex = ::KokkosKernels::ArithTraits<SC>::is_complex>
142+
#else
136143
const bool isComplex = ::Kokkos::ArithTraits<SC>::is_complex>
144+
#endif
137145
struct ReadLine {
138146
/// \brief Take a line from the Matrix Market file or input stream,
139147
/// and process the sparse matrix entry in that line.
@@ -201,7 +209,11 @@ struct ReadLine<SC, GO, true> {
201209
std::ostream* errStrm = NULL,
202210
const bool debug = false) {
203211
using ::Teuchos::MatrixMarket::checkCommentLine;
212+
#if KOKKOS_VERSION > 40799
213+
typedef typename ::KokkosKernels::ArithTraits<SC>::mag_type real_type;
214+
#else
204215
typedef typename ::Kokkos::ArithTraits<SC>::mag_type real_type;
216+
#endif
205217
using std::endl;
206218

207219
GO rowInd, colInd;
@@ -530,7 +542,11 @@ int readAndSendOneBatchOfTriples(std::istream& inputStream,
530542
using ::Tpetra::Details::packTriples;
531543
using ::Tpetra::Details::packTriplesCount;
532544

545+
#if KOKKOS_VERSION > 40799
546+
using ::KokkosKernels::ArithTraits;
547+
#else
533548
using ::Kokkos::ArithTraits;
549+
#endif
534550
// constexpr int sizeTag = 42 + (ArithTraits<SC>::is_complex ? 100 : 0);
535551
// constexpr int msgTag = 43 + (ArithTraits<SC>::is_complex ? 100 : 0);
536552
constexpr int sizeTag = 42;
@@ -764,7 +780,11 @@ int recvOneBatchOfTriples(std::vector<GO>& rowInds,
764780
const bool tolerant = false,
765781
std::ostream* errStrm = NULL,
766782
const bool debug = false) {
783+
#if KOKKOS_VERSION > 40799
784+
using ::KokkosKernels::ArithTraits;
785+
#else
767786
using ::Kokkos::ArithTraits;
787+
#endif
768788
using ::Tpetra::Details::unpackTriples;
769789
using ::Tpetra::Details::unpackTriplesCount;
770790

@@ -886,7 +906,11 @@ int readAndDealOutTriples(std::istream& inputStream, // only valid on Proc 0
886906
const bool tolerant = false,
887907
std::ostream* errStrm = NULL,
888908
const bool debug = false) {
909+
#if KOKKOS_VERSION > 40799
910+
using KokkosKernels::ArithTraits;
911+
#else
889912
using Kokkos::ArithTraits;
913+
#endif
890914
using std::endl;
891915
using std::size_t;
892916

packages/tpetra/core/src/Tpetra_BlockCrsMatrix_Helpers_def.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,16 @@ unfillFormerBlockCrs(const Tpetra::CrsMatrix<Scalar, LO, GO, Node> &pointMatrix)
814814
using dev_row_view_t = typename crs_t::local_graph_device_type::row_map_type::non_const_type;
815815
using dev_col_view_t = typename crs_t::local_graph_device_type::entries_type::non_const_type;
816816
using dev_val_view_t = typename crs_t::local_matrix_device_type::values_type::non_const_type;
817+
#if KOKKOS_VERSION > 40799
818+
using impl_scalar_t = typename KokkosKernels::ArithTraits<Scalar>::val_type;
819+
#else
817820
using impl_scalar_t = typename Kokkos::ArithTraits<Scalar>::val_type;
821+
#endif
822+
#if KOKKOS_VERSION > 40799
823+
using STS = KokkosKernels::ArithTraits<impl_scalar_t>;
824+
#else
818825
using STS = Kokkos::ArithTraits<impl_scalar_t>;
826+
#endif
819827
using Ordinal = typename dev_row_view_t::non_const_value_type;
820828
using execution_space = typename Node::execution_space;
821829
using range_type = Kokkos::RangePolicy<execution_space, size_t>;

packages/tpetra/core/src/Tpetra_BlockMultiVector_def.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,11 @@ struct BlockWiseMultiply {
528528

529529
KOKKOS_INLINE_FUNCTION
530530
void operator()(const Size k) const {
531+
#if KOKKOS_VERSION > 40799
532+
const auto zero = KokkosKernels::ArithTraits<Scalar>::zero();
533+
#else
531534
const auto zero = Kokkos::ArithTraits<Scalar>::zero();
535+
#endif
532536
auto D_curBlk = Kokkos::subview(D_, k, Kokkos::ALL(), Kokkos::ALL());
533537
const auto num_vecs = X_.extent(1);
534538
for (Size i = 0; i < num_vecs; ++i) {
@@ -606,7 +610,11 @@ class BlockJacobiUpdate {
606610
using Kokkos::ALL;
607611
using Kokkos::subview;
608612
typedef Kokkos::pair<LO, LO> range_type;
613+
#if KOKKOS_VERSION > 40799
614+
typedef KokkosKernels::ArithTraits<Scalar> KAT;
615+
#else
609616
typedef Kokkos::ArithTraits<Scalar> KAT;
617+
#endif
610618

611619
// We only have to implement the alpha != 0 case.
612620

packages/tpetra/core/src/Tpetra_BlockView.hpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
/// Tpetra::BlockCrsMatrix.
2020

2121
#include "TpetraCore_config.h"
22+
#if KOKKOS_VERSION > 40799
23+
#include "KokkosKernels_ArithTraits.hpp"
24+
#else
2225
#include "Kokkos_ArithTraits.hpp"
26+
#endif
2327
#include "Kokkos_Complex.hpp"
2428

2529
namespace Tpetra {
@@ -64,7 +68,11 @@ struct AbsMax<ViewType1, ViewType2, 2> {
6468
typedef typename std::decay<decltype(X(0, 0))>::type STX;
6569
static_assert(std::is_same<STX, STY>::value,
6670
"AbsMax: The type of each entry of X and Y must be the same.");
71+
#if KOKKOS_VERSION > 40799
72+
typedef KokkosKernels::ArithTraits<STY> KAT;
73+
#else
6774
typedef Kokkos::ArithTraits<STY> KAT;
75+
#endif
6876

6977
const int numCols = Y.extent(1);
7078
const int numRows = Y.extent(0);
@@ -102,7 +110,11 @@ struct AbsMax<ViewType1, ViewType2, 1> {
102110
typedef typename std::remove_const<typename std::remove_reference<decltype(X(0))>::type>::type STX;
103111
static_assert(std::is_same<STX, STY>::value,
104112
"AbsMax: The type of each entry of X and Y must be the same.");
113+
#if KOKKOS_VERSION > 40799
114+
typedef KokkosKernels::ArithTraits<STY> KAT;
115+
#else
105116
typedef Kokkos::ArithTraits<STY> KAT;
117+
#endif
106118

107119
const int numRows = Y.extent(0);
108120
for (int i = 0; i < numRows; ++i) {
@@ -288,12 +300,20 @@ struct AXPY<CoefficientType, ViewType1, ViewType2, IndexType, false, 1> {
288300
run(const CoefficientType& alpha,
289301
const ViewType1& x,
290302
const ViewType2& y) {
303+
#if KOKKOS_VERSION > 40799
304+
using KokkosKernels::ArithTraits;
305+
#else
291306
using Kokkos::ArithTraits;
307+
#endif
292308
static_assert(static_cast<int>(ViewType1::rank) == static_cast<int>(ViewType2::rank),
293309
"AXPY: x and y must have the same rank.");
294310

295311
const IndexType numRows = static_cast<IndexType>(y.extent(0));
312+
#if KOKKOS_VERSION > 40799
313+
if (alpha !Kernels= ArithTraits<CoefficientType>::zero()) {
314+
#else
296315
if (alpha != ArithTraits<CoefficientType>::zero()) {
316+
#endif
297317
/// general case
298318
for (IndexType i = 0; i < numRows; ++i)
299319
y(i) += alpha * x(i);
@@ -313,13 +333,21 @@ struct AXPY<CoefficientType, ViewType1, ViewType2, IndexType, false, 2> {
313333
run(const CoefficientType& alpha,
314334
const ViewType1& X,
315335
const ViewType2& Y) {
336+
#if KOKKOS_VERSION > 40799
337+
using KokkosKernels::ArithTraits;
338+
#else
316339
using Kokkos::ArithTraits;
340+
#endif
317341
static_assert(static_cast<int>(ViewType1::rank) == static_cast<int>(ViewType2::rank),
318342
"AXPY: X and Y must have the same rank.");
319343
const IndexType numRows = static_cast<IndexType>(Y.extent(0));
320344
const IndexType numCols = static_cast<IndexType>(Y.extent(1));
321345

346+
#if KOKKOS_VERSION > 40799
347+
if (alpha !Kernels= ArithTraits<CoefficientType>::zero()) {
348+
#else
322349
if (alpha != ArithTraits<CoefficientType>::zero()) {
350+
#endif
323351
for (IndexType j = 0; j < numCols; ++j)
324352
for (IndexType i = 0; i < numRows; ++i)
325353
Y(i, j) += alpha * X(i, j);
@@ -338,11 +366,19 @@ struct AXPY<CoefficientType, ViewType1, ViewType2, IndexType, true, rank> {
338366
run(const CoefficientType& alpha,
339367
const ViewType1& x,
340368
const ViewType2& y) {
369+
#if KOKKOS_VERSION > 40799
370+
using KokkosKernels::ArithTraits;
371+
#else
341372
using Kokkos::ArithTraits;
373+
#endif
342374
static_assert(static_cast<int>(ViewType1::rank) == static_cast<int>(ViewType2::rank),
343375
"AXPY: x and y must have the same rank.");
344376

377+
#if KOKKOS_VERSION > 40799
378+
if (alpha !Kernels= ArithTraits<CoefficientType>::zero()) {
379+
#else
345380
if (alpha != ArithTraits<CoefficientType>::zero()) {
381+
#endif
346382
using x_value_type = typename std::decay<decltype(*x.data())>::type;
347383
using y_value_type = typename std::decay<decltype(*y.data())>::type;
348384
const IndexType span = static_cast<IndexType>(y.span());
@@ -677,7 +713,11 @@ GEMM(const char transA[],
677713
static_assert(ViewType3::rank == 2, "GEMM: C must have rank 2 (be a matrix).");
678714

679715
typedef typename std::remove_reference<decltype(A(0, 0))>::type Scalar;
716+
#if KOKKOS_VERSION > 40799
717+
typedef KokkosKernels::ArithTraits<Scalar> STS;
718+
#else
680719
typedef Kokkos::ArithTraits<Scalar> STS;
720+
#endif
681721
const Scalar ZERO = STS::zero();
682722
const Scalar ONE = STS::one();
683723

@@ -804,7 +844,11 @@ GETF2(const LittleBlockType& A, const LittleVectorType& ipiv, int& info) {
804844
static_assert(!std::is_const<std::remove_reference<decltype(ipiv(0))>>::value,
805845
"GETF2: ipiv must not be a const View (or LittleBlock).");
806846
static_assert(LittleBlockType::rank == 2, "GETF2: A must have rank 2 (be a matrix).");
847+
#if KOKKOS_VERSION > 40799
848+
typedef KokkosKernels::ArithTraits<Scalar> STS;
849+
#else
807850
typedef Kokkos::ArithTraits<Scalar> STS;
851+
#endif
808852
const Scalar ZERO = STS::zero();
809853

810854
const IndexType numRows = static_cast<IndexType>(A.extent(0));
@@ -901,7 +945,11 @@ struct GETRS<LittleBlockType, LittleIntVectorType, LittleScalarVectorType, 1> {
901945
static_assert(LittleIntVectorType::rank == 1, "GETRS: ipiv must have rank 1.");
902946
static_assert(LittleScalarVectorType::rank == 1, "GETRS: For this specialization, B must have rank 1.");
903947

948+
#if KOKKOS_VERSION > 40799
949+
typedef KokkosKernels::ArithTraits<Scalar> STS;
950+
#else
904951
typedef Kokkos::ArithTraits<Scalar> STS;
952+
#endif
905953
const Scalar ZERO = STS::zero();
906954
const IndexType numRows = static_cast<IndexType>(A.extent(0));
907955
const IndexType numCols = static_cast<IndexType>(A.extent(1));
@@ -1059,7 +1107,11 @@ GETRI(const LittleBlockType& A,
10591107
static_assert(!std::is_const<std::remove_reference<decltype(work(0))>>::value,
10601108
"GETRI: work must not be a const View (or LittleBlock).");
10611109
static_assert(LittleBlockType::rank == 2, "GETRI: A must have rank 2 (be a matrix).");
1110+
#if KOKKOS_VERSION > 40799
1111+
typedef KokkosKernels::ArithTraits<Scalar> STS;
1112+
#else
10621113
typedef Kokkos::ArithTraits<Scalar> STS;
1114+
#endif
10631115
const Scalar ZERO = STS::zero();
10641116
const Scalar ONE = STS::one();
10651117

packages/tpetra/core/src/Tpetra_CrsGraphTransposer_def.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ struct SortedNumericIndicesOnlyFunctor {
7878
, Ccolinds(Ccolinds_) {}
7979

8080
KOKKOS_INLINE_FUNCTION void operator()(const ordinal_type i) const {
81+
#if KOKKOS_VERSION > 40799
82+
const ordinal_type ORDINAL_MAX = KokkosKernels::ArithTraits<ordinal_type>::max();
83+
#else
8184
const ordinal_type ORDINAL_MAX = Kokkos::ArithTraits<ordinal_type>::max();
85+
#endif
8286

8387
// count the union of nonzeros in Arow and Brow
8488
size_type ai = 0;

packages/tpetra/core/src/Tpetra_CrsMatrix_decl.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,11 @@ class CrsMatrix : public RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>,
453453
/// This is usually the same as the type of the magnitude
454454
/// (absolute value) of <tt>Scalar</tt>, but may differ for
455455
/// certain <tt>Scalar</tt> types.
456+
#if KOKKOS_VERSION > 40799
457+
using mag_type = typename KokkosKernels::ArithTraits<impl_scalar_type>::mag_type;
458+
#else
456459
using mag_type = typename Kokkos::ArithTraits<impl_scalar_type>::mag_type;
460+
#endif
457461

458462
//! The CrsGraph specialization suitable for this CrsMatrix specialization.
459463
using crs_graph_type = CrsGraph<LocalOrdinal, GlobalOrdinal, Node>;
@@ -3695,8 +3699,16 @@ class CrsMatrix : public RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>,
36953699
protected:
36963700
// useful typedefs
36973701
typedef Teuchos::OrdinalTraits<LocalOrdinal> OTL;
3702+
#if KOKKOS_VERSION > 40799
3703+
typedef KokkosKernels::ArithTraits<impl_scalar_type> STS;
3704+
#else
36983705
typedef Kokkos::ArithTraits<impl_scalar_type> STS;
3706+
#endif
3707+
#if KOKKOS_VERSION > 40799
3708+
typedef KokkosKernels::ArithTraits<mag_type> STM;
3709+
#else
36993710
typedef Kokkos::ArithTraits<mag_type> STM;
3711+
#endif
37003712
typedef MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> MV;
37013713
typedef Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> V;
37023714
typedef crs_graph_type Graph;

packages/tpetra/core/src/Tpetra_Details_EquilibrationInfo.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
/// \brief Declaration of Tpetra::Details::EquilibrationInfo
1515

1616
#include "TpetraCore_config.h"
17+
#if KOKKOS_VERSION > 40799
18+
#include "KokkosKernels_ArithTraits.hpp"
19+
#else
1720
#include "Kokkos_ArithTraits.hpp"
21+
#endif
1822
#include "Kokkos_Core.hpp"
1923

2024
namespace Tpetra {
@@ -45,8 +49,16 @@ namespace Details {
4549
/// over an MPI communicator.
4650
template <class ScalarType, class DeviceType>
4751
struct EquilibrationInfo {
52+
#if KOKKOS_VERSION > 40799
53+
using val_type = typename KokkosKernels::ArithTraits<ScalarType>::val_type;
54+
#else
4855
using val_type = typename Kokkos::ArithTraits<ScalarType>::val_type;
56+
#endif
57+
#if KOKKOS_VERSION > 40799
58+
using mag_type = typename KokkosKernels::ArithTraits<val_type>::mag_type;
59+
#else
4960
using mag_type = typename Kokkos::ArithTraits<val_type>::mag_type;
61+
#endif
5062
using device_type = typename DeviceType::device_type;
5163
using host_device_type = typename Kokkos::View<mag_type*, device_type>::host_mirror_type::device_type;
5264
using HostMirror = EquilibrationInfo<val_type, host_device_type>;

0 commit comments

Comments
 (0)