diff --git a/src/batched/dense/impl/KokkosBatched_Dot_Internal.hpp b/src/batched/dense/impl/KokkosBatched_Dot_Internal.hpp index 642a3fed6c..2f8662d00f 100644 --- a/src/batched/dense/impl/KokkosBatched_Dot_Internal.hpp +++ b/src/batched/dense/impl/KokkosBatched_Dot_Internal.hpp @@ -34,11 +34,13 @@ struct SerialDotInternal { // j \in [0,n), i \in [0,m) // C(j) = conj(A(:,j))*B(:,j) template - KOKKOS_FORCEINLINE_FUNCTION static int invoke( - const int m, const int n, const ValueType *__restrict__ A, const int as0, - const int as1, const ValueType *__restrict__ B, const int bs0, - const int bs1, - /* */ MagnitudeType *__restrict__ C, const int cs) { + KOKKOS_INLINE_FUNCTION static int invoke(const int m, const int n, + const ValueType *__restrict__ A, + const int as0, const int as1, + const ValueType *__restrict__ B, + const int bs0, const int bs1, + /* */ MagnitudeType *__restrict__ C, + const int cs) { for (int j = 0; j < n; ++j) invoke(m, A + j * as1, as0, B + j * bs1, bs0, C + j * cs); return 0; diff --git a/src/batched/sparse/KokkosBatched_CG.hpp b/src/batched/sparse/KokkosBatched_CG.hpp index caf7b94089..6333ad690f 100644 --- a/src/batched/sparse/KokkosBatched_CG.hpp +++ b/src/batched/sparse/KokkosBatched_CG.hpp @@ -49,14 +49,14 @@ /// \brief Batched CG: Selective Interface /// -/// \tparam OperatorType: The type of the opertator of the system +/// \tparam OperatorType: The type of the operator of the system /// \tparam VectorViewType: Input type for the right-hand side and the solution, /// needs to be a 2D view /// /// \param member [in]: TeamPolicy member /// \param A [in]: batched operator (can be a batched matrix or a (left or right /// or both) preconditioned batched matrix) \param B [in]: right-hand side, a -/// rank 2 view \param X [in/out]: initial guess and solutin, a rank 2 view +/// rank 2 view \param X [in/out]: initial guess and solution, a rank 2 view /// \param handle [in]: a handle which provides different information such as /// the tolerance or the maximal number of iterations of the solver. diff --git a/src/batched/sparse/KokkosBatched_CrsMatrix.hpp b/src/batched/sparse/KokkosBatched_CrsMatrix.hpp index f4bda1aa9e..5448c4684c 100644 --- a/src/batched/sparse/KokkosBatched_CrsMatrix.hpp +++ b/src/batched/sparse/KokkosBatched_CrsMatrix.hpp @@ -64,6 +64,8 @@ class CrsMatrix { IntViewType row_ptr; IntViewType colIndices; int n_operators; + int n_rows; + int n_colums; public: KOKKOS_INLINE_FUNCTION @@ -71,11 +73,15 @@ class CrsMatrix { const IntViewType &_colIndices) : values(_values), row_ptr(_row_ptr), colIndices(_colIndices) { n_operators = _values.extent(0); + n_rows = _row_ptr.extent(0) - 1; + n_colums = n_rows; } + KOKKOS_INLINE_FUNCTION ~CrsMatrix() {} - /// \brief apply + /// \brief apply version that uses constant coefficients alpha and beta + /// /// y_l <- alpha * A_l * x_l + beta * y_l for all l = 1, ..., N /// where: /// * N is the number of matrices, @@ -115,7 +121,7 @@ class CrsMatrix { member, alpha, values, row_ptr, colIndices, X, beta, Y); } - /// \brief apply + /// \brief apply version that uses variable coefficient alpha and no beta /// y_l <- alpha_l * A_l * x_l for all l = 1, ..., N /// where: /// * N is the number of matrices, @@ -147,7 +153,7 @@ class CrsMatrix { Y); } - /// \brief apply + /// \brief apply version that uses variable coefficients alpha and beta /// y_l <- alpha_l * A_l * x_l + beta_l * y_l for all l = 1, ..., N /// where: /// * N is the number of matrices, diff --git a/src/batched/sparse/KokkosBatched_GMRES.hpp b/src/batched/sparse/KokkosBatched_GMRES.hpp index 907a7c6e17..6231c7676a 100644 --- a/src/batched/sparse/KokkosBatched_GMRES.hpp +++ b/src/batched/sparse/KokkosBatched_GMRES.hpp @@ -49,14 +49,14 @@ /// \brief Batched GMRES: Selective Interface /// -/// \tparam OperatorType: The type of the opertator of the system +/// \tparam OperatorType: The type of the operator of the system /// \tparam VectorViewType: Input type for the right-hand side and the solution, /// needs to be a 2D view /// /// \param member [in]: TeamPolicy member /// \param A [in]: batched operator (can be a batched matrix or a (left or right /// or both) preconditioned batched matrix) \param B [in]: right-hand side, a -/// rank 2 view \param X [in/out]: initial guess and solutin, a rank 2 view +/// rank 2 view \param X [in/out]: initial guess and solution, a rank 2 view /// \param handle [in]: a handle which provides different information such as /// the tolerance or the maximal number of iterations of the solver. diff --git a/src/batched/sparse/impl/KokkosBatched_CG_TeamVector_Impl.hpp b/src/batched/sparse/impl/KokkosBatched_CG_TeamVector_Impl.hpp index b1356ec8f9..960780b54d 100644 --- a/src/batched/sparse/impl/KokkosBatched_CG_TeamVector_Impl.hpp +++ b/src/batched/sparse/impl/KokkosBatched_CG_TeamVector_Impl.hpp @@ -70,9 +70,6 @@ struct TeamVectorCG { typedef int OrdinalType; typedef typename Kokkos::Details::ArithTraits< typename VectorViewType::non_const_value_type>::mag_type MagnitudeType; - typedef Kokkos::View - NormViewType; const size_t maximum_iteration = handle->get_max_iteration(); const MagnitudeType tolerance = handle->get_tolerance(); @@ -104,9 +101,6 @@ struct TeamVectorCG { // Deep copy of b into r_0: TeamVectorCopy::invoke(member, _B, R); - Kokkos::parallel_for(Kokkos::TeamVectorRange(member, 0, numMatrices), - [&](const OrdinalType& i) { mask(i) = 1.; }); - // r_0 := b - A x_0 member.team_barrier(); A.template apply::invoke(member, R, R, sqr_norm_0); member.team_barrier(); + Kokkos::parallel_for(Kokkos::TeamVectorRange(member, 0, numMatrices), + [&](const OrdinalType& i) { + mask(i) = + sqr_norm_0(i) > tolerance * tolerance ? 1. : 0; + }); + TeamVectorCopy1D::invoke(member, sqr_norm_0, sqr_norm_j); int status = 1; diff --git a/src/batched/sparse/impl/KokkosBatched_CG_Team_Impl.hpp b/src/batched/sparse/impl/KokkosBatched_CG_Team_Impl.hpp index a78dc84132..4444562750 100644 --- a/src/batched/sparse/impl/KokkosBatched_CG_Team_Impl.hpp +++ b/src/batched/sparse/impl/KokkosBatched_CG_Team_Impl.hpp @@ -69,11 +69,8 @@ struct TeamCG { typedef int OrdinalType; typedef typename Kokkos::Details::ArithTraits< typename VectorViewType::non_const_value_type>::mag_type MagnitudeType; - typedef Kokkos::View - NormViewType; - int maximum_iteration = handle->get_max_iteration(); + size_t maximum_iteration = handle->get_max_iteration(); const MagnitudeType tolerance = handle->get_tolerance(); using ScratchPadNormViewType = Kokkos::View< @@ -103,9 +100,6 @@ struct TeamCG { // Deep copy of b into r_0: TeamCopy::invoke(member, _B, R); - Kokkos::parallel_for(Kokkos::TeamThreadRange(member, 0, numMatrices), - [&](const OrdinalType& i) { mask(i) = 1.; }); - // r_0 := b - A x_0 member.team_barrier(); A.template apply::invoke(member, R, R, sqr_norm_0); member.team_barrier(); + Kokkos::parallel_for(Kokkos::TeamThreadRange(member, 0, numMatrices), + [&](const OrdinalType& i) { + mask(i) = + sqr_norm_0(i) > tolerance * tolerance ? 1. : 0; + }); + TeamCopy1D::invoke(member, sqr_norm_0, sqr_norm_j); int status = 1; diff --git a/src/batched/sparse/impl/KokkosBatched_GMRES_TeamVector_Impl.hpp b/src/batched/sparse/impl/KokkosBatched_GMRES_TeamVector_Impl.hpp index 58a1ef8119..85bcfa50ab 100644 --- a/src/batched/sparse/impl/KokkosBatched_GMRES_TeamVector_Impl.hpp +++ b/src/batched/sparse/impl/KokkosBatched_GMRES_TeamVector_Impl.hpp @@ -73,12 +73,6 @@ struct TeamVectorGMRES { typedef typename Kokkos::Details::ArithTraits< typename VectorViewType::non_const_value_type>::mag_type MagnitudeType; typedef Kokkos::Details::ArithTraits ATM; - typedef Kokkos::View - NormViewType; - - int maximum_iteration = handle->get_max_iteration(); - const MagnitudeType tolerance = handle->get_tolerance(); using ScratchPadNormViewType = Kokkos::View< MagnitudeType*, @@ -96,6 +90,12 @@ struct TeamVectorGMRES { const OrdinalType numMatrices = _X.extent(0); const OrdinalType numRows = _X.extent(1); + size_t maximum_iteration = handle->get_max_iteration() < numRows + ? handle->get_max_iteration() + : numRows; + const MagnitudeType tolerance = handle->get_tolerance(); + const MagnitudeType max_tolerance = 0.; + ScratchPadMultiVectorViewType V(member.team_scratch(1), numMatrices, maximum_iteration + 1, numRows); ScratchPadMultiVectorViewType H(member.team_scratch(1), numMatrices, @@ -103,7 +103,7 @@ struct TeamVectorGMRES { ScratchPadMultiVectorViewType Givens(member.team_scratch(1), numMatrices, maximum_iteration, 2); ScratchPadVectorViewType G(member.team_scratch(1), numMatrices, - maximum_iteration); + maximum_iteration + 1); ScratchPadVectorViewType W(member.team_scratch(0), numMatrices, numRows); ScratchPadVectorViewType Q(member.team_scratch(0), numMatrices, numRows); @@ -134,8 +134,8 @@ struct TeamVectorGMRES { Kokkos::parallel_for(Kokkos::TeamVectorRange(member, 0, numMatrices), [&](const OrdinalType& i) { beta(i) = ATM::sqrt(beta(i)); - G(i, 0) = beta(i); - tmp(i) = 1. / beta(i); + G(i, 0) = beta(i) > max_tolerance ? beta(i) : 0.; + tmp(i) = beta(i) > max_tolerance ? 1. / beta(i) : 0.; }); Kokkos::parallel_for( @@ -166,21 +166,22 @@ struct TeamVectorGMRES { TeamVectorCopy1D::invoke(member, tmp, Kokkos::subview(H, Kokkos::ALL, i, j)); - Kokkos::parallel_for(Kokkos::TeamVectorRange(member, 0, numMatrices), - [&](const OrdinalType& i) { tmp(i) = -tmp(i); }); + Kokkos::parallel_for( + Kokkos::TeamVectorRange(member, 0, numMatrices), + [&](const OrdinalType& ii) { tmp(ii) = -tmp(ii); }); TeamVectorAxpy::invoke(member, tmp, V_i, W); } TeamVectorDot::invoke(member, W, W, tmp); + member.team_barrier(); Kokkos::parallel_for( Kokkos::TeamVectorRange(member, 0, numMatrices), - [&](const OrdinalType& i) { tmp(i) = ATM::sqrt(tmp(i)); }); + [&](const OrdinalType& i) { + H(i, j + 1, j) = ATM::sqrt(tmp(i)); + tmp(i) = H(i, j + 1, j) > max_tolerance ? 1. / H(i, j + 1, j) : 0.; + }); member.team_barrier(); - TeamVectorCopy1D::invoke(member, tmp, - Kokkos::subview(H, Kokkos::ALL, j + 1, j)); - Kokkos::parallel_for(Kokkos::TeamVectorRange(member, 0, numMatrices), - [&](const OrdinalType& i) { tmp(i) = 1. / tmp(i); }); Kokkos::parallel_for( Kokkos::TeamVectorRange(member, 0, numMatrices * numRows), [&](const OrdinalType& iTemp) { @@ -196,38 +197,39 @@ struct TeamVectorGMRES { // Apply the previous Givens rotations: auto H_j = Kokkos::subview(H, l, Kokkos::ALL, j); - for (size_t i = 0; i < j; ++i) { + if (mask(l) == 1.) { + for (size_t i = 0; i < j; ++i) { + auto tmp1 = + Givens(l, i, 0) * H_j(i) + Givens(l, i, 1) * H_j(i + 1); + auto tmp2 = + -Givens(l, i, 1) * H_j(i) + Givens(l, i, 0) * H_j(i + 1); + H_j(i) = tmp1; + H_j(i + 1) = tmp2; + } + + // Compute the new Givens rotation: + Kokkos::pair + G_new; + typename VectorViewType::non_const_value_type alpha; + SerialGivensInternal::invoke(H_j(j), H_j(j + 1), &G_new, &alpha); + + Givens(l, j, 0) = G_new.first; + Givens(l, j, 1) = G_new.second; + + // Apply the new Givens rotation: auto tmp1 = - Givens(l, i, 0) * H_j(i) + Givens(l, i, 1) * H_j(i + 1); + Givens(l, j, 0) * H_j(j) + Givens(l, j, 1) * H_j(j + 1); auto tmp2 = - -Givens(l, i, 1) * H_j(i) + Givens(l, i, 0) * H_j(i + 1); - H_j(i) = tmp1; - H_j(i + 1) = tmp2; - } - - // Compute the new Givens rotation: - Kokkos::pair - G_new; - typename VectorViewType::non_const_value_type alpha; - SerialGivensInternal::invoke(H_j(j), H_j(j + 1), &G_new, &alpha); - - Givens(l, j, 0) = G_new.first; - Givens(l, j, 1) = G_new.second; - - // Apply the new Givens rotation: - auto tmp1 = Givens(l, j, 0) * H_j(j) + Givens(l, j, 1) * H_j(j + 1); - auto tmp2 = - -Givens(l, j, 1) * H_j(j) + Givens(l, j, 0) * H_j(j + 1); - H_j(j) = tmp1; - H_j(j + 1) = tmp2; - - G(l, j + 1) = -Givens(l, j, 1) * G(l, j); - G(l, j) *= Givens(l, j, 0); - - if (mask(l) == 0.) { - H_j(j) = 1.; - G(l, j) = 0.; + -Givens(l, j, 1) * H_j(j) + Givens(l, j, 0) * H_j(j + 1); + H_j(j) = tmp1; + H_j(j + 1) = tmp2; + + G(l, j + 1) = -Givens(l, j, 1) * G(l, j); + G(l, j) *= Givens(l, j, 0); + } else { + H_j(j) = 1.; + G(l, j + 1) = 0.; } if (mask(l) == 1. && std::abs(G(l, j + 1)) / beta(l) < tolerance) { diff --git a/src/batched/sparse/impl/KokkosBatched_GMRES_Team_Impl.hpp b/src/batched/sparse/impl/KokkosBatched_GMRES_Team_Impl.hpp index 9b4c04a57c..c4c39eac69 100644 --- a/src/batched/sparse/impl/KokkosBatched_GMRES_Team_Impl.hpp +++ b/src/batched/sparse/impl/KokkosBatched_GMRES_Team_Impl.hpp @@ -72,12 +72,6 @@ struct TeamGMRES { typedef typename Kokkos::Details::ArithTraits< typename VectorViewType::non_const_value_type>::mag_type MagnitudeType; typedef Kokkos::Details::ArithTraits ATM; - typedef Kokkos::View - NormViewType; - - int maximum_iteration = handle->get_max_iteration(); - const MagnitudeType tolerance = handle->get_tolerance(); using ScratchPadNormViewType = Kokkos::View< MagnitudeType*, @@ -95,6 +89,12 @@ struct TeamGMRES { const OrdinalType numMatrices = _X.extent(0); const OrdinalType numRows = _X.extent(1); + size_t maximum_iteration = handle->get_max_iteration() < numRows + ? handle->get_max_iteration() + : numRows; + const MagnitudeType tolerance = handle->get_tolerance(); + const MagnitudeType max_tolerance = 0.; + ScratchPadMultiVectorViewType V(member.team_scratch(1), numMatrices, maximum_iteration + 1, numRows); ScratchPadMultiVectorViewType H(member.team_scratch(1), numMatrices, @@ -102,7 +102,7 @@ struct TeamGMRES { ScratchPadMultiVectorViewType Givens(member.team_scratch(1), numMatrices, maximum_iteration, 2); ScratchPadVectorViewType G(member.team_scratch(1), numMatrices, - maximum_iteration); + maximum_iteration + 1); ScratchPadVectorViewType W(member.team_scratch(0), numMatrices, numRows); ScratchPadVectorViewType Q(member.team_scratch(0), numMatrices, numRows); @@ -133,8 +133,8 @@ struct TeamGMRES { Kokkos::parallel_for(Kokkos::TeamThreadRange(member, 0, numMatrices), [&](const OrdinalType& i) { beta(i) = ATM::sqrt(beta(i)); - G(i, 0) = beta(i); - tmp(i) = 1. / beta(i); + G(i, 0) = beta(i) > max_tolerance ? beta(i) : 0.; + tmp(i) = beta(i) > max_tolerance ? 1. / beta(i) : 0.; }); Kokkos::parallel_for( @@ -161,22 +161,25 @@ struct TeamGMRES { for (size_t i = 0; i < j + 1; ++i) { auto V_i = Kokkos::subview(V, Kokkos::ALL, i, Kokkos::ALL); TeamDot::invoke(member, W, V_i, tmp); + member.team_barrier(); TeamCopy1D::invoke(member, tmp, Kokkos::subview(H, Kokkos::ALL, i, j)); - Kokkos::parallel_for(Kokkos::TeamThreadRange(member, 0, numMatrices), - [&](const OrdinalType& i) { tmp(i) = -tmp(i); }); + Kokkos::parallel_for( + Kokkos::TeamThreadRange(member, 0, numMatrices), + [&](const OrdinalType& ii) { tmp(ii) = -tmp(ii); }); TeamAxpy::invoke(member, tmp, V_i, W); } TeamDot::invoke(member, W, W, tmp); + member.team_barrier(); Kokkos::parallel_for( Kokkos::TeamThreadRange(member, 0, numMatrices), - [&](const OrdinalType& i) { tmp(i) = ATM::sqrt(tmp(i)); }); - TeamCopy1D::invoke(member, tmp, - Kokkos::subview(H, Kokkos::ALL, j + 1, j)); - Kokkos::parallel_for(Kokkos::TeamThreadRange(member, 0, numMatrices), - [&](const OrdinalType& i) { tmp(i) = 1. / tmp(i); }); + [&](const OrdinalType& i) { + H(i, j + 1, j) = ATM::sqrt(tmp(i)); + tmp(i) = H(i, j + 1, j) > max_tolerance ? 1. / H(i, j + 1, j) : 0.; + }); + member.team_barrier(); Kokkos::parallel_for( Kokkos::TeamThreadRange(member, 0, numMatrices * numRows), [&](const OrdinalType& iTemp) { @@ -192,38 +195,39 @@ struct TeamGMRES { // Apply the previous Givens rotations: auto H_j = Kokkos::subview(H, l, Kokkos::ALL, j); - for (size_t i = 0; i < j; ++i) { + if (mask(l) == 1.) { + for (size_t i = 0; i < j; ++i) { + auto tmp1 = + Givens(l, i, 0) * H_j(i) + Givens(l, i, 1) * H_j(i + 1); + auto tmp2 = + -Givens(l, i, 1) * H_j(i) + Givens(l, i, 0) * H_j(i + 1); + H_j(i) = tmp1; + H_j(i + 1) = tmp2; + } + + // Compute the new Givens rotation: + Kokkos::pair + G_new; + typename VectorViewType::non_const_value_type alpha; + SerialGivensInternal::invoke(H_j(j), H_j(j + 1), &G_new, &alpha); + + Givens(l, j, 0) = G_new.first; + Givens(l, j, 1) = G_new.second; + + // Apply the new Givens rotation: auto tmp1 = - Givens(l, i, 0) * H_j(i) + Givens(l, i, 1) * H_j(i + 1); + Givens(l, j, 0) * H_j(j) + Givens(l, j, 1) * H_j(j + 1); auto tmp2 = - -Givens(l, i, 1) * H_j(i) + Givens(l, i, 0) * H_j(i + 1); - H_j(i) = tmp1; - H_j(i + 1) = tmp2; - } - - // Compute the new Givens rotation: - Kokkos::pair - G_new; - typename VectorViewType::non_const_value_type alpha; - SerialGivensInternal::invoke(H_j(j), H_j(j + 1), &G_new, &alpha); - - Givens(l, j, 0) = G_new.first; - Givens(l, j, 1) = G_new.second; - - // Apply the new Givens rotation: - auto tmp1 = Givens(l, j, 0) * H_j(j) + Givens(l, j, 1) * H_j(j + 1); - auto tmp2 = - -Givens(l, j, 1) * H_j(j) + Givens(l, j, 0) * H_j(j + 1); - H_j(j) = tmp1; - H_j(j + 1) = tmp2; - - G(l, j + 1) = -Givens(l, j, 1) * G(l, j); - G(l, j) *= Givens(l, j, 0); - - if (mask(l) == 0.) { - H_j(j) = 1.; - G(l, j) = 0.; + -Givens(l, j, 1) * H_j(j) + Givens(l, j, 0) * H_j(j + 1); + H_j(j) = tmp1; + H_j(j + 1) = tmp2; + + G(l, j + 1) = -Givens(l, j, 1) * G(l, j); + G(l, j) *= Givens(l, j, 0); + } else { + H_j(j) = 1.; + G(l, j + 1) = 0.; } if (mask(l) == 1. && std::abs(G(l, j + 1)) / beta(l) < tolerance) { diff --git a/test_common/KokkosKernels_TestUtils.hpp b/test_common/KokkosKernels_TestUtils.hpp index d472e2cee9..77464e3147 100644 --- a/test_common/KokkosKernels_TestUtils.hpp +++ b/test_common/KokkosKernels_TestUtils.hpp @@ -243,24 +243,21 @@ struct Functor_BatchedVanillaGEMM { } }; -//Compute C := alpha * AB + beta * C +// Compute C := alpha * AB + beta * C template void vanillaGEMM(typename ViewTypeC::non_const_value_type alpha, const ViewTypeA& A, const ViewTypeB& B, typename ViewTypeC::non_const_value_type beta, const ViewTypeC& C) { using value_type = typename ViewTypeC::non_const_value_type; - using KAT = Kokkos::ArithTraits; - int m = A.extent(0); - int k = A.extent(1); - int n = B.extent(1); - for(int i = 0; i < m; i++) - { - for(int j = 0; j < n; j++) - { + using KAT = Kokkos::ArithTraits; + int m = A.extent(0); + int k = A.extent(1); + int n = B.extent(1); + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { value_type sum = KAT::zero(); - for(int ii = 0; ii < k; ii++) - { + for (int ii = 0; ii < k; ii++) { sum += A(i, ii) * B(ii, j); } C(i, j) = alpha * sum + beta * C(i, j); @@ -323,103 +320,104 @@ class epsilon { using KokkosKernels::Impl::getRandomBounds; - template - crsMat_t symmetrize(crsMat_t A) - { - typedef typename crsMat_t::StaticCrsGraphType graph_t; - typedef typename crsMat_t::values_type::non_const_type scalar_view_t; - typedef typename graph_t::row_map_type::non_const_type lno_view_t; - typedef typename graph_t::entries_type::non_const_type lno_nnz_view_t; - auto host_rowmap = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), A.graph.row_map); - auto host_entries = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), A.graph.entries); - auto host_values = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), A.values); - lno_t numRows = A.numRows(); - //symmetrize as input_mat + input_mat^T, to still have a diagonally dominant matrix - typedef std::map Row; - std::vector symRows(numRows); - for(lno_t r = 0; r < numRows; r++) - { - auto& row = symRows[r]; - for(size_type i = host_rowmap(r); i < host_rowmap(r + 1); i++) - { - lno_t c = host_entries(i); - auto& col = symRows[c]; - auto it = row.find(c); - if(it == row.end()) - row[c] = host_values(i); - else - row[c] += host_values(i); - it = col.find(r); - if(it == col.end()) - col[r] = host_values(i); - else - col[r] += host_values(i); - } - } - //Count entries - Kokkos::View new_host_rowmap("Rowmap", numRows + 1); - size_t accum = 0; - for(lno_t r = 0; r <= numRows; r++) - { - new_host_rowmap(r) = accum; - if(r < numRows) - accum += symRows[r].size(); +template +crsMat_t symmetrize(crsMat_t A) { + typedef typename crsMat_t::StaticCrsGraphType graph_t; + typedef typename crsMat_t::values_type::non_const_type scalar_view_t; + typedef typename graph_t::row_map_type::non_const_type lno_view_t; + typedef typename graph_t::entries_type::non_const_type lno_nnz_view_t; + auto host_rowmap = + Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), A.graph.row_map); + auto host_entries = + Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), A.graph.entries); + auto host_values = + Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), A.values); + lno_t numRows = A.numRows(); + // symmetrize as input_mat + input_mat^T, to still have a diagonally dominant + // matrix + typedef std::map Row; + std::vector symRows(numRows); + for (lno_t r = 0; r < numRows; r++) { + auto& row = symRows[r]; + for (size_type i = host_rowmap(r); i < host_rowmap(r + 1); i++) { + lno_t c = host_entries(i); + auto& col = symRows[c]; + auto it = row.find(c); + if (it == row.end()) + row[c] = host_values(i); + else + row[c] += host_values(i); + it = col.find(r); + if (it == col.end()) + col[r] = host_values(i); + else + col[r] += host_values(i); } - //Allocate new entries/values - Kokkos::View new_host_entries("Entries", accum); - Kokkos::View new_host_values("Values", accum); - for(lno_t r = 0; r < numRows; r++) - { - auto rowIt = symRows[r].begin(); - for(size_type i = new_host_rowmap(r); i < new_host_rowmap(r + 1); i++) - { - new_host_entries(i) = rowIt->first; - new_host_values(i) = rowIt->second; - rowIt++; - } + } + // Count entries + Kokkos::View + new_host_rowmap("Rowmap", numRows + 1); + size_t accum = 0; + for (lno_t r = 0; r <= numRows; r++) { + new_host_rowmap(r) = accum; + if (r < numRows) accum += symRows[r].size(); + } + // Allocate new entries/values + Kokkos::View new_host_entries( + "Entries", accum); + Kokkos::View + new_host_values("Values", accum); + for (lno_t r = 0; r < numRows; r++) { + auto rowIt = symRows[r].begin(); + for (size_type i = new_host_rowmap(r); i < new_host_rowmap(r + 1); i++) { + new_host_entries(i) = rowIt->first; + new_host_values(i) = rowIt->second; + rowIt++; } - lno_view_t new_rowmap("Rowmap", numRows + 1); - lno_nnz_view_t new_entries("Entries", accum); - scalar_view_t new_values("Values", accum); - Kokkos::deep_copy(new_rowmap, new_host_rowmap); - Kokkos::deep_copy(new_entries, new_host_entries); - Kokkos::deep_copy(new_values, new_host_values); - return crsMat_t("SymA", numRows, numRows, accum, new_values, new_rowmap, new_entries); } + lno_view_t new_rowmap("Rowmap", numRows + 1); + lno_nnz_view_t new_entries("Entries", accum); + scalar_view_t new_values("Values", accum); + Kokkos::deep_copy(new_rowmap, new_host_rowmap); + Kokkos::deep_copy(new_entries, new_host_entries); + Kokkos::deep_copy(new_values, new_host_values); + return crsMat_t("SymA", numRows, numRows, accum, new_values, new_rowmap, + new_entries); +} - //create_random_x_vector and create_random_y_vector can be used together to generate a random - //linear system Ax = y. - template - vec_t create_random_x_vector(vec_t& kok_x, double max_value = 10.0) { - typedef typename vec_t::value_type scalar_t; - auto h_x = Kokkos::create_mirror_view (kok_x); - for (size_t j = 0; j < h_x.extent(1); ++j){ - for (size_t i = 0; i < h_x.extent(0); ++i){ - scalar_t r = - static_cast (rand()) / - static_cast (RAND_MAX / max_value); - h_x.access(i, j) = r; - } +// create_random_x_vector and create_random_y_vector can be used together to +// generate a random linear system Ax = y. +template +vec_t create_random_x_vector(vec_t& kok_x, double max_value = 10.0) { + typedef typename vec_t::value_type scalar_t; + auto h_x = Kokkos::create_mirror_view(kok_x); + for (size_t j = 0; j < h_x.extent(1); ++j) { + for (size_t i = 0; i < h_x.extent(0); ++i) { + scalar_t r = static_cast(rand()) / + static_cast(RAND_MAX / max_value); + h_x.access(i, j) = r; } - Kokkos::deep_copy (kok_x, h_x); - return kok_x; } + Kokkos::deep_copy(kok_x, h_x); + return kok_x; +} - template - vector_t create_random_y_vector(crsMat_t crsMat, vector_t x_vector){ - vector_t y_vector (Kokkos::view_alloc(Kokkos::WithoutInitializing, "Y VECTOR"), - crsMat.numRows()); - KokkosSparse::spmv("N", 1, crsMat, x_vector, 0, y_vector); - return y_vector; - } +template +vector_t create_random_y_vector(crsMat_t crsMat, vector_t x_vector) { + vector_t y_vector(Kokkos::view_alloc(Kokkos::WithoutInitializing, "Y VECTOR"), + crsMat.numRows()); + KokkosSparse::spmv("N", 1, crsMat, x_vector, 0, y_vector); + return y_vector; +} - template - vector_t create_random_y_vector_mv(crsMat_t crsMat, vector_t x_vector){ - vector_t y_vector (Kokkos::view_alloc(Kokkos::WithoutInitializing, "Y VECTOR"), - crsMat.numRows(), x_vector.extent(1)); - KokkosSparse::spmv("N", 1, crsMat, x_vector, 0, y_vector); - return y_vector; - } +template +vector_t create_random_y_vector_mv(crsMat_t crsMat, vector_t x_vector) { + vector_t y_vector(Kokkos::view_alloc(Kokkos::WithoutInitializing, "Y VECTOR"), + crsMat.numRows(), x_vector.extent(1)); + KokkosSparse::spmv("N", 1, crsMat, x_vector, 0, y_vector); + return y_vector; +} /// \brief SharedParamTag class used to specify how to invoke templates within /// batched unit tests @@ -433,5 +431,31 @@ struct SharedParamTag { using transB = TB; using batchLayout = BL; }; + +/// \brief value_type_name returns a string with the value type name +template +KOKKOS_INLINE_FUNCTION std::string value_type_name() { + return "::UnknowValueType"; +} + +template <> +KOKKOS_INLINE_FUNCTION std::string value_type_name() { + return "::Float"; +} + +template <> +KOKKOS_INLINE_FUNCTION std::string value_type_name() { + return "::Double"; +} + +template <> +KOKKOS_INLINE_FUNCTION std::string value_type_name>() { + return "::ComplexFloat"; +} + +template <> +KOKKOS_INLINE_FUNCTION std::string value_type_name>() { + return "::ComplexDouble"; +} } // namespace Test #endif diff --git a/unit_test/batched/dense/Test_Batched_SerialAxpy.hpp b/unit_test/batched/dense/Test_Batched_SerialAxpy.hpp index 94f41aca97..0fa1c99935 100644 --- a/unit_test/batched/dense/Test_Batched_SerialAxpy.hpp +++ b/unit_test/batched/dense/Test_Batched_SerialAxpy.hpp @@ -36,18 +36,8 @@ struct Functor_TestBatchedSerialAxpy { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::SerialAxpy"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::RangePolicy policy(0, _X.extent(0)); Kokkos::parallel_for(name.c_str(), policy, *this); @@ -58,6 +48,8 @@ struct Functor_TestBatchedSerialAxpy { template void impl_test_batched_axpy(const int N, const int BlkSize) { typedef typename ViewType::value_type value_type; + typedef typename ViewType::const_value_type const_value_type; + typedef typename alphaViewType::const_value_type alpha_const_value_type; typedef Kokkos::Details::ArithTraits ats; ViewType X0("x0", N, BlkSize), X1("x1", N, BlkSize), Y0("y0", N, BlkSize), @@ -67,9 +59,9 @@ void impl_test_batched_axpy(const int N, const int BlkSize) { Kokkos::Random_XorShift64_Pool random( 13718); - Kokkos::fill_random(X0, random, value_type(1.0)); - Kokkos::fill_random(Y0, random, value_type(1.0)); - Kokkos::fill_random(alpha, random, value_type(1.0)); + Kokkos::fill_random(X0, random, const_value_type(1.0)); + Kokkos::fill_random(Y0, random, const_value_type(1.0)); + Kokkos::fill_random(alpha, random, alpha_const_value_type(1.0)); Kokkos::fence(); diff --git a/unit_test/batched/dense/Test_Batched_SerialGemm.hpp b/unit_test/batched/dense/Test_Batched_SerialGemm.hpp index 37e171d227..6a8be3fc54 100644 --- a/unit_test/batched/dense/Test_Batched_SerialGemm.hpp +++ b/unit_test/batched/dense/Test_Batched_SerialGemm.hpp @@ -48,18 +48,8 @@ struct Functor_TestBatchedSerialGemm { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::SerialGemm"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::RangePolicy policy(0, _c.extent(0)); Kokkos::parallel_for(name.c_str(), policy, *this); diff --git a/unit_test/batched/dense/Test_Batched_SerialGemv.hpp b/unit_test/batched/dense/Test_Batched_SerialGemv.hpp index c9257f3618..eb1d8f285c 100644 --- a/unit_test/batched/dense/Test_Batched_SerialGemv.hpp +++ b/unit_test/batched/dense/Test_Batched_SerialGemv.hpp @@ -47,18 +47,8 @@ struct Functor_TestBatchedSerialGemv { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::SerialGemv"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::RangePolicy policy(0, _c.extent(0)); Kokkos::parallel_for(name.c_str(), policy, *this); diff --git a/unit_test/batched/dense/Test_Batched_SerialInverseLU.hpp b/unit_test/batched/dense/Test_Batched_SerialInverseLU.hpp index 2442e22dea..fd7d0478fc 100644 --- a/unit_test/batched/dense/Test_Batched_SerialInverseLU.hpp +++ b/unit_test/batched/dense/Test_Batched_SerialInverseLU.hpp @@ -54,18 +54,8 @@ struct Functor_BatchedSerialGemm { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::SerialInverseLU"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::RangePolicy policy(0, _c.extent(0)); Kokkos::parallel_for((name + "::GemmFunctor").c_str(), policy, *this); @@ -92,18 +82,8 @@ struct Functor_BatchedSerialLU { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::SerialInverseLU"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::RangePolicy policy(0, _a.extent(0)); Kokkos::parallel_for((name + "::LUFunctor").c_str(), policy, *this); @@ -132,18 +112,8 @@ struct Functor_TestBatchedSerialInverseLU { inline void run() { typedef typename AViewType::value_type value_type; std::string name_region("KokkosBatched::Test::SerialInverseLU"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::RangePolicy policy(0, _a.extent(0)); Kokkos::parallel_for((name + "::InverseLUFunctor").c_str(), policy, *this); diff --git a/unit_test/batched/dense/Test_Batched_SerialLU.hpp b/unit_test/batched/dense/Test_Batched_SerialLU.hpp index b42bb2943a..9bb92340a2 100644 --- a/unit_test/batched/dense/Test_Batched_SerialLU.hpp +++ b/unit_test/batched/dense/Test_Batched_SerialLU.hpp @@ -34,18 +34,8 @@ struct Functor_TestBatchedSerialLU { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::SerialLU"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::RangePolicy policy(0, _a.extent(0)); Kokkos::parallel_for(name.c_str(), policy, *this); diff --git a/unit_test/batched/dense/Test_Batched_SerialMatUtil.hpp b/unit_test/batched/dense/Test_Batched_SerialMatUtil.hpp index 79c9d9b2f7..f9a58f5442 100644 --- a/unit_test/batched/dense/Test_Batched_SerialMatUtil.hpp +++ b/unit_test/batched/dense/Test_Batched_SerialMatUtil.hpp @@ -62,17 +62,7 @@ struct Functor_TestBatchedSerialMatUtil { inline int run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::SerialMatUtil"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); + const std::string name_value_type = Test::value_type_name(); std::string name_work_tag = (std::is_same::value ? "::KokkosBatched" diff --git a/unit_test/batched/dense/Test_Batched_SerialSolveLU.hpp b/unit_test/batched/dense/Test_Batched_SerialSolveLU.hpp index 64362d9140..b6d8e1aecf 100644 --- a/unit_test/batched/dense/Test_Batched_SerialSolveLU.hpp +++ b/unit_test/batched/dense/Test_Batched_SerialSolveLU.hpp @@ -54,18 +54,8 @@ struct Functor_BatchedSerialGemm { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::SerialSolveLU"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::RangePolicy policy(0, _c.extent(0)); Kokkos::parallel_for((name + "::GemmFunctor").c_str(), policy, *this); @@ -92,18 +82,8 @@ struct Functor_BatchedSerialLU { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::SerialSolveLU"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::RangePolicy policy(0, _a.extent(0)); Kokkos::parallel_for((name + "::LUFunctor").c_str(), policy, *this); @@ -132,18 +112,8 @@ struct Functor_TestBatchedSerialSolveLU { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::SerialSolveLU"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::RangePolicy policy(0, _a.extent(0)); Kokkos::parallel_for((name + "::SolveLUFunctor").c_str(), policy, *this); diff --git a/unit_test/batched/dense/Test_Batched_SerialTrmm.hpp b/unit_test/batched/dense/Test_Batched_SerialTrmm.hpp index 227a255707..8df653b48f 100644 --- a/unit_test/batched/dense/Test_Batched_SerialTrmm.hpp +++ b/unit_test/batched/dense/Test_Batched_SerialTrmm.hpp @@ -118,18 +118,8 @@ struct Functor_TestBatchedSerialTrmm { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::SerialTrmm"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::RangePolicy policy(0, _a.extent(0)); Kokkos::parallel_for(name.c_str(), policy, *this); diff --git a/unit_test/batched/dense/Test_Batched_SerialTrsm.hpp b/unit_test/batched/dense/Test_Batched_SerialTrsm.hpp index cbf36c503d..81a0456623 100644 --- a/unit_test/batched/dense/Test_Batched_SerialTrsm.hpp +++ b/unit_test/batched/dense/Test_Batched_SerialTrsm.hpp @@ -47,18 +47,8 @@ struct Functor_TestBatchedSerialTrsm { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::SerialTrsm"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::RangePolicy policy(0, _b.extent(0)); Kokkos::parallel_for(name.c_str(), policy, *this); diff --git a/unit_test/batched/dense/Test_Batched_SerialTrsv.hpp b/unit_test/batched/dense/Test_Batched_SerialTrsv.hpp index f9bcaeb84a..995f33178d 100644 --- a/unit_test/batched/dense/Test_Batched_SerialTrsv.hpp +++ b/unit_test/batched/dense/Test_Batched_SerialTrsv.hpp @@ -46,18 +46,8 @@ struct Functor_TestBatchedSerialTrsv { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::SerialTrsv"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::RangePolicy policy(0, _b.extent(0)); Kokkos::parallel_for(name.c_str(), policy, *this); diff --git a/unit_test/batched/dense/Test_Batched_SerialTrtri.hpp b/unit_test/batched/dense/Test_Batched_SerialTrtri.hpp index 75cb1fe2c8..2af8420be3 100644 --- a/unit_test/batched/dense/Test_Batched_SerialTrtri.hpp +++ b/unit_test/batched/dense/Test_Batched_SerialTrtri.hpp @@ -112,18 +112,8 @@ struct Functor_TestBatchedSerialTrtri { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::SerialTrtri"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::RangePolicy policy(0, _a.extent(0)); Kokkos::parallel_for("Functor_TestBatchedSerialTrtri", policy, *this); diff --git a/unit_test/batched/dense/Test_Batched_TeamAxpy.hpp b/unit_test/batched/dense/Test_Batched_TeamAxpy.hpp index b5ec0539ee..144b1f9390 100644 --- a/unit_test/batched/dense/Test_Batched_TeamAxpy.hpp +++ b/unit_test/batched/dense/Test_Batched_TeamAxpy.hpp @@ -47,18 +47,8 @@ struct Functor_TestBatchedTeamAxpy { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamAxpy"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::TeamPolicy policy(_X.extent(0) / _N_team, Kokkos::AUTO(), Kokkos::AUTO()); @@ -70,6 +60,8 @@ struct Functor_TestBatchedTeamAxpy { template void impl_test_batched_axpy(const int N, const int BlkSize, const int N_team) { typedef typename ViewType::value_type value_type; + typedef typename ViewType::const_value_type const_value_type; + typedef typename alphaViewType::const_value_type alpha_const_value_type; typedef Kokkos::Details::ArithTraits ats; ViewType X0("x0", N, BlkSize), X1("x1", N, BlkSize), Y0("y0", N, BlkSize), @@ -79,9 +71,9 @@ void impl_test_batched_axpy(const int N, const int BlkSize, const int N_team) { Kokkos::Random_XorShift64_Pool random( 13718); - Kokkos::fill_random(X0, random, value_type(1.0)); - Kokkos::fill_random(Y0, random, value_type(1.0)); - Kokkos::fill_random(alpha, random, value_type(1.0)); + Kokkos::fill_random(X0, random, const_value_type(1.0)); + Kokkos::fill_random(Y0, random, const_value_type(1.0)); + Kokkos::fill_random(alpha, random, alpha_const_value_type(1.0)); Kokkos::fence(); diff --git a/unit_test/batched/dense/Test_Batched_TeamGemm.hpp b/unit_test/batched/dense/Test_Batched_TeamGemm.hpp index 6c5356dc7a..00fb2f4d49 100644 --- a/unit_test/batched/dense/Test_Batched_TeamGemm.hpp +++ b/unit_test/batched/dense/Test_Batched_TeamGemm.hpp @@ -54,18 +54,8 @@ struct Functor_TestBatchedTeamGemm { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamGemm"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); const int league_size = _c.extent(0); Kokkos::TeamPolicy policy(league_size, diff --git a/unit_test/batched/dense/Test_Batched_TeamGemv.hpp b/unit_test/batched/dense/Test_Batched_TeamGemv.hpp index 138c591ecc..9f19180a3f 100644 --- a/unit_test/batched/dense/Test_Batched_TeamGemv.hpp +++ b/unit_test/batched/dense/Test_Batched_TeamGemv.hpp @@ -52,18 +52,8 @@ struct Functor_TestBatchedTeamGemv { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::SerialGemm"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); const int league_size = _c.extent(0); Kokkos::TeamPolicy policy(league_size, diff --git a/unit_test/batched/dense/Test_Batched_TeamInverseLU.hpp b/unit_test/batched/dense/Test_Batched_TeamInverseLU.hpp index 5226775c1b..4db8a69155 100644 --- a/unit_test/batched/dense/Test_Batched_TeamInverseLU.hpp +++ b/unit_test/batched/dense/Test_Batched_TeamInverseLU.hpp @@ -62,18 +62,8 @@ struct Functor_BatchedTeamGemm { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamInverseLU"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); const int league_size = _c.extent(0); @@ -107,18 +97,8 @@ struct Functor_BatchedTeamLU { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamInverseLU"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); const int league_size = _a.extent(0); @@ -151,18 +131,8 @@ struct Functor_TestBatchedTeamInverseLU { inline void run() { typedef typename AViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamInverseLU"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); const int league_size = _a.extent(0); diff --git a/unit_test/batched/dense/Test_Batched_TeamLU.hpp b/unit_test/batched/dense/Test_Batched_TeamLU.hpp index d49472f064..ec9ab01a7d 100644 --- a/unit_test/batched/dense/Test_Batched_TeamLU.hpp +++ b/unit_test/batched/dense/Test_Batched_TeamLU.hpp @@ -40,18 +40,8 @@ struct Functor_TestBatchedTeamLU { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamLU"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); const int league_size = _a.extent(0); diff --git a/unit_test/batched/dense/Test_Batched_TeamMatUtil.hpp b/unit_test/batched/dense/Test_Batched_TeamMatUtil.hpp index ff557d5241..16879444f7 100644 --- a/unit_test/batched/dense/Test_Batched_TeamMatUtil.hpp +++ b/unit_test/batched/dense/Test_Batched_TeamMatUtil.hpp @@ -70,17 +70,7 @@ struct Functor_TestBatchedTeamMatUtil { inline int run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::SerialMatUtil"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); + const std::string name_value_type = Test::value_type_name(); std::string name_work_tag = (std::is_same::value ? "::KokkosBatched" diff --git a/unit_test/batched/dense/Test_Batched_TeamSolveLU.hpp b/unit_test/batched/dense/Test_Batched_TeamSolveLU.hpp index 6f31773269..201cc025fc 100644 --- a/unit_test/batched/dense/Test_Batched_TeamSolveLU.hpp +++ b/unit_test/batched/dense/Test_Batched_TeamSolveLU.hpp @@ -62,18 +62,8 @@ struct Functor_BatchedTeamGemm { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamSolveLU"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); const int league_size = _c.extent(0); Kokkos::TeamPolicy policy(league_size, @@ -104,18 +94,8 @@ struct Functor_BatchedTeamLU { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamSolveLU"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); const int league_size = _a.extent(0); Kokkos::TeamPolicy policy(league_size, Kokkos::AUTO); @@ -146,18 +126,8 @@ struct Functor_TestBatchedTeamSolveLU { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamSolveLU"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); const int league_size = _a.extent(0); diff --git a/unit_test/batched/dense/Test_Batched_TeamTrsm.hpp b/unit_test/batched/dense/Test_Batched_TeamTrsm.hpp index eba8fa8ef1..da4b70933a 100644 --- a/unit_test/batched/dense/Test_Batched_TeamTrsm.hpp +++ b/unit_test/batched/dense/Test_Batched_TeamTrsm.hpp @@ -54,18 +54,8 @@ struct Functor_TestBatchedTeamTrsm { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamTrsm"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); const int league_size = _b.extent(0); diff --git a/unit_test/batched/dense/Test_Batched_TeamTrsv.hpp b/unit_test/batched/dense/Test_Batched_TeamTrsv.hpp index b354529e72..c33c939488 100644 --- a/unit_test/batched/dense/Test_Batched_TeamTrsv.hpp +++ b/unit_test/batched/dense/Test_Batched_TeamTrsv.hpp @@ -52,18 +52,8 @@ struct Functor_TestBatchedTeamTrsv { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamTrsv"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); const int league_size = _b.extent(0); diff --git a/unit_test/batched/dense/Test_Batched_TeamVectorAxpy.hpp b/unit_test/batched/dense/Test_Batched_TeamVectorAxpy.hpp index b93cce9c3a..7194757687 100644 --- a/unit_test/batched/dense/Test_Batched_TeamVectorAxpy.hpp +++ b/unit_test/batched/dense/Test_Batched_TeamVectorAxpy.hpp @@ -48,18 +48,8 @@ struct Functor_TestBatchedTeamVectorAxpy { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamVectorAxpy"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::TeamPolicy policy(_X.extent(0) / _N_team, Kokkos::AUTO(), Kokkos::AUTO()); @@ -71,6 +61,8 @@ struct Functor_TestBatchedTeamVectorAxpy { template void impl_test_batched_axpy(const int N, const int BlkSize, const int N_team) { typedef typename ViewType::value_type value_type; + typedef typename ViewType::const_value_type const_value_type; + typedef typename alphaViewType::const_value_type alpha_const_value_type; typedef Kokkos::Details::ArithTraits ats; ViewType X0("x0", N, BlkSize), X1("x1", N, BlkSize), Y0("y0", N, BlkSize), @@ -80,9 +72,9 @@ void impl_test_batched_axpy(const int N, const int BlkSize, const int N_team) { Kokkos::Random_XorShift64_Pool random( 13718); - Kokkos::fill_random(X0, random, value_type(1.0)); - Kokkos::fill_random(Y0, random, value_type(1.0)); - Kokkos::fill_random(alpha, random, value_type(1.0)); + Kokkos::fill_random(X0, random, const_value_type(1.0)); + Kokkos::fill_random(Y0, random, const_value_type(1.0)); + Kokkos::fill_random(alpha, random, alpha_const_value_type(1.0)); Kokkos::fence(); diff --git a/unit_test/batched/dense/Test_Batched_TeamVectorGemm.hpp b/unit_test/batched/dense/Test_Batched_TeamVectorGemm.hpp index 074a1342fa..d104df2b06 100644 --- a/unit_test/batched/dense/Test_Batched_TeamVectorGemm.hpp +++ b/unit_test/batched/dense/Test_Batched_TeamVectorGemm.hpp @@ -49,18 +49,8 @@ struct Functor_TestBatchedTeamVector { inline void run() { typedef typename ViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamVector"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); const int league_size = _c.extent(0); Kokkos::TeamPolicy policy(league_size, diff --git a/unit_test/batched/dense/Test_Batched_TeamVectorQR.hpp b/unit_test/batched/dense/Test_Batched_TeamVectorQR.hpp index a687ffad20..4ae4ee4133 100644 --- a/unit_test/batched/dense/Test_Batched_TeamVectorQR.hpp +++ b/unit_test/batched/dense/Test_Batched_TeamVectorQR.hpp @@ -79,18 +79,8 @@ struct Functor_TestBatchedTeamVectorQR { inline void run() { typedef typename MatrixViewType::non_const_value_type value_type; std::string name_region("KokkosBatched::Test::TeamVectorQR"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); const int league_size = _a.extent(0); diff --git a/unit_test/batched/dense/Test_Batched_TeamVectorQR_WithColumnPivoting.hpp b/unit_test/batched/dense/Test_Batched_TeamVectorQR_WithColumnPivoting.hpp index 61bf8bf7ec..3ae24bda84 100644 --- a/unit_test/batched/dense/Test_Batched_TeamVectorQR_WithColumnPivoting.hpp +++ b/unit_test/batched/dense/Test_Batched_TeamVectorQR_WithColumnPivoting.hpp @@ -89,18 +89,8 @@ struct Functor_TestBatchedTeamVectorQR_WithColumnPivoting { typedef typename MatrixViewType::non_const_value_type value_type; std::string name_region( "KokkosBatched::Test::TeamVectorQR_WithColumnPivoting"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); const int league_size = _a.extent(0); diff --git a/unit_test/batched/dense/Test_Batched_TeamVectorSolveUTV.hpp b/unit_test/batched/dense/Test_Batched_TeamVectorSolveUTV.hpp index 4fe2133982..6610383d12 100644 --- a/unit_test/batched/dense/Test_Batched_TeamVectorSolveUTV.hpp +++ b/unit_test/batched/dense/Test_Batched_TeamVectorSolveUTV.hpp @@ -101,18 +101,8 @@ struct Functor_TestBatchedTeamVectorSolveUTV { inline void run() { typedef typename MatrixViewType::non_const_value_type value_type; std::string name_region("KokkosBatched::Test::TeamVectorSolveUTV"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); const int league_size = _a.extent(0); diff --git a/unit_test/batched/dense/Test_Batched_TeamVectorSolveUTV2.hpp b/unit_test/batched/dense/Test_Batched_TeamVectorSolveUTV2.hpp index 81bba6fe76..77bec61c28 100644 --- a/unit_test/batched/dense/Test_Batched_TeamVectorSolveUTV2.hpp +++ b/unit_test/batched/dense/Test_Batched_TeamVectorSolveUTV2.hpp @@ -105,18 +105,8 @@ struct Functor_TestBatchedTeamVectorSolveUTV2 { inline void run() { typedef typename MatrixViewType::non_const_value_type value_type; std::string name_region("KokkosBatched::Test::TeamVectorSolveUTV"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); const int league_size = _a.extent(0); diff --git a/unit_test/batched/dense/Test_Batched_TeamVectorUTV.hpp b/unit_test/batched/dense/Test_Batched_TeamVectorUTV.hpp index 54512f87d4..0a49db7dce 100644 --- a/unit_test/batched/dense/Test_Batched_TeamVectorUTV.hpp +++ b/unit_test/batched/dense/Test_Batched_TeamVectorUTV.hpp @@ -135,18 +135,8 @@ struct Functor_TestBatchedTeamVectorUTV { inline void run() { typedef typename MatrixViewType::non_const_value_type value_type; std::string name_region("KokkosBatched::Test::TeamVectorUTV"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); const int league_size = _a.extent(0); diff --git a/unit_test/batched/sparse/Test_Batched_SerialSpmv.hpp b/unit_test/batched/sparse/Test_Batched_SerialSpmv.hpp index 0629e292a5..c482f8fdb0 100644 --- a/unit_test/batched/sparse/Test_Batched_SerialSpmv.hpp +++ b/unit_test/batched/sparse/Test_Batched_SerialSpmv.hpp @@ -57,18 +57,8 @@ struct Functor_TestBatchedSerialSpmv { inline void run() { typedef typename ValuesViewType::value_type value_type; std::string name_region("KokkosBatched::Test::SerialSpmv"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::RangePolicy policy(0, _D.extent(0)); Kokkos::parallel_for(name.c_str(), policy, *this); diff --git a/unit_test/batched/sparse/Test_Batched_SparseUtils.hpp b/unit_test/batched/sparse/Test_Batched_SparseUtils.hpp index 40bd993a30..919f34aa91 100644 --- a/unit_test/batched/sparse/Test_Batched_SparseUtils.hpp +++ b/unit_test/batched/sparse/Test_Batched_SparseUtils.hpp @@ -12,8 +12,12 @@ void create_tridiagonal_batched_matrices(const int nnz, const int BlkSize, Kokkos::Random_XorShift64_Pool< typename VectorViewType::device_type::execution_space> random(13718); - Kokkos::fill_random(X, random, typename VectorViewType::value_type(1.0)); - Kokkos::fill_random(B, random, typename VectorViewType::value_type(1.0)); + Kokkos::fill_random( + X, random, + Kokkos::reduction_identity::prod()); + Kokkos::fill_random( + B, random, + Kokkos::reduction_identity::prod()); auto D_host = Kokkos::create_mirror_view(D); auto r_host = Kokkos::create_mirror_view(r); diff --git a/unit_test/batched/sparse/Test_Batched_TeamCG.hpp b/unit_test/batched/sparse/Test_Batched_TeamCG.hpp index a6be2b30a2..2177264489 100644 --- a/unit_test/batched/sparse/Test_Batched_TeamCG.hpp +++ b/unit_test/batched/sparse/Test_Batched_TeamCG.hpp @@ -3,17 +3,9 @@ #include "gtest/gtest.h" #include "Kokkos_Core.hpp" #include "Kokkos_Random.hpp" - -//#include "KokkosBatched_Vector.hpp" - #include "KokkosBatched_CG.hpp" - #include "KokkosKernels_TestUtils.hpp" - -#include "KokkosBatched_CG.hpp" - #include "KokkosBatched_CrsMatrix.hpp" - #include "Test_Batched_SparseUtils.hpp" using namespace KokkosBatched; @@ -68,18 +60,8 @@ struct Functor_TestBatchedTeamCG { inline void run() { typedef typename ValuesViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamCG"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::TeamPolicy policy(_D.extent(0) / _N_team, Kokkos::AUTO(), Kokkos::AUTO()); diff --git a/unit_test/batched/sparse/Test_Batched_TeamGMRES.hpp b/unit_test/batched/sparse/Test_Batched_TeamGMRES.hpp index 544005f01a..11b382c640 100644 --- a/unit_test/batched/sparse/Test_Batched_TeamGMRES.hpp +++ b/unit_test/batched/sparse/Test_Batched_TeamGMRES.hpp @@ -3,17 +3,9 @@ #include "gtest/gtest.h" #include "Kokkos_Core.hpp" #include "Kokkos_Random.hpp" - -//#include "KokkosBatched_Vector.hpp" - #include "KokkosBatched_GMRES.hpp" - #include "KokkosKernels_TestUtils.hpp" - -#include "KokkosBatched_GMRES.hpp" - #include "KokkosBatched_CrsMatrix.hpp" - #include "Test_Batched_SparseUtils.hpp" using namespace KokkosBatched; @@ -68,18 +60,8 @@ struct Functor_TestBatchedTeamGMRES { inline void run() { typedef typename ValuesViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamGMRES"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::TeamPolicy policy(_D.extent(0) / _N_team, Kokkos::AUTO(), Kokkos::AUTO()); @@ -154,9 +136,8 @@ void impl_test_batched_GMRES(const int N, const int BlkSize, const int N_team) { typename ValuesViewType::HostMirror, typename IntView::HostMirror, typename VectorViewType::HostMirror, typename VectorViewType::HostMirror, 1>(-1, D_host, r_host, c_host, X_host, 1, R_host); - KokkosBatched::SerialDot::template invoke< - typename VectorViewType::HostMirror, typename VectorViewType::HostMirror, - typename NormViewType::HostMirror>(R_host, R_host, sqr_norm_0_host); + KokkosBatched::SerialDot::invoke(R_host, R_host, + sqr_norm_0_host); Functor_TestBatchedTeamGMRES(D, r, c, X, B, N_team) .run(); @@ -171,9 +152,8 @@ void impl_test_batched_GMRES(const int N, const int BlkSize, const int N_team) { typename ValuesViewType::HostMirror, typename IntView::HostMirror, typename VectorViewType::HostMirror, typename VectorViewType::HostMirror, 1>(-1, D_host, r_host, c_host, X_host, 1, R_host); - KokkosBatched::SerialDot::template invoke< - typename VectorViewType::HostMirror, typename VectorViewType::HostMirror, - typename NormViewType::HostMirror>(R_host, R_host, sqr_norm_j_host); + KokkosBatched::SerialDot::invoke(R_host, R_host, + sqr_norm_j_host); const MagnitudeType eps = 1.0e5 * ats::epsilon(); diff --git a/unit_test/batched/sparse/Test_Batched_TeamSpmv.hpp b/unit_test/batched/sparse/Test_Batched_TeamSpmv.hpp index ee7d7f46aa..0b0f96e9b1 100644 --- a/unit_test/batched/sparse/Test_Batched_TeamSpmv.hpp +++ b/unit_test/batched/sparse/Test_Batched_TeamSpmv.hpp @@ -81,18 +81,8 @@ struct Functor_TestBatchedTeamSpmv { inline void run() { typedef typename ValuesViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamSpmv"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::TeamPolicy policy( _D.extent(0) / _N_team, Kokkos::AUTO(), Kokkos::AUTO()); diff --git a/unit_test/batched/sparse/Test_Batched_TeamVectorCG.hpp b/unit_test/batched/sparse/Test_Batched_TeamVectorCG.hpp index ddf80ed3ab..0f3b0ca693 100644 --- a/unit_test/batched/sparse/Test_Batched_TeamVectorCG.hpp +++ b/unit_test/batched/sparse/Test_Batched_TeamVectorCG.hpp @@ -3,17 +3,9 @@ #include "gtest/gtest.h" #include "Kokkos_Core.hpp" #include "Kokkos_Random.hpp" - -//#include "KokkosBatched_Vector.hpp" - #include "KokkosBatched_CG.hpp" - #include "KokkosKernels_TestUtils.hpp" - -#include "KokkosBatched_CG.hpp" - #include "KokkosBatched_CrsMatrix.hpp" - #include "Test_Batched_SparseUtils.hpp" using namespace KokkosBatched; @@ -68,18 +60,8 @@ struct Functor_TestBatchedTeamVectorCG { inline void run() { typedef typename ValuesViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamVectorCG"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::TeamPolicy policy(_D.extent(0) / _N_team, Kokkos::AUTO(), Kokkos::AUTO()); diff --git a/unit_test/batched/sparse/Test_Batched_TeamVectorGMRES.hpp b/unit_test/batched/sparse/Test_Batched_TeamVectorGMRES.hpp index 94106278a3..bb6abdc1a9 100644 --- a/unit_test/batched/sparse/Test_Batched_TeamVectorGMRES.hpp +++ b/unit_test/batched/sparse/Test_Batched_TeamVectorGMRES.hpp @@ -3,17 +3,9 @@ #include "gtest/gtest.h" #include "Kokkos_Core.hpp" #include "Kokkos_Random.hpp" - -//#include "KokkosBatched_Vector.hpp" - #include "KokkosBatched_GMRES.hpp" - #include "KokkosKernels_TestUtils.hpp" - -#include "KokkosBatched_GMRES.hpp" - #include "KokkosBatched_CrsMatrix.hpp" - #include "Test_Batched_SparseUtils.hpp" using namespace KokkosBatched; @@ -68,18 +60,8 @@ struct Functor_TestBatchedTeamVectorGMRES { inline void run() { typedef typename ValuesViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamVectorGMRES"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::TeamPolicy policy(_D.extent(0) / _N_team, Kokkos::AUTO(), Kokkos::AUTO()); @@ -154,9 +136,8 @@ void impl_test_batched_GMRES(const int N, const int BlkSize, const int N_team) { typename ValuesViewType::HostMirror, typename IntView::HostMirror, typename VectorViewType::HostMirror, typename VectorViewType::HostMirror, 1>(-1, D_host, r_host, c_host, X_host, 1, R_host); - KokkosBatched::SerialDot::template invoke< - typename VectorViewType::HostMirror, typename VectorViewType::HostMirror, - typename NormViewType::HostMirror>(R_host, R_host, sqr_norm_0_host); + KokkosBatched::SerialDot::invoke(R_host, R_host, + sqr_norm_0_host); Functor_TestBatchedTeamVectorGMRES(D, r, c, X, B, N_team) .run(); @@ -171,9 +152,8 @@ void impl_test_batched_GMRES(const int N, const int BlkSize, const int N_team) { typename ValuesViewType::HostMirror, typename IntView::HostMirror, typename VectorViewType::HostMirror, typename VectorViewType::HostMirror, 1>(-1, D_host, r_host, c_host, X_host, 1, R_host); - KokkosBatched::SerialDot::template invoke< - typename VectorViewType::HostMirror, typename VectorViewType::HostMirror, - typename NormViewType::HostMirror>(R_host, R_host, sqr_norm_j_host); + KokkosBatched::SerialDot::invoke(R_host, R_host, + sqr_norm_j_host); const MagnitudeType eps = 1.0e5 * ats::epsilon(); diff --git a/unit_test/batched/sparse/Test_Batched_TeamVectorSpmv.hpp b/unit_test/batched/sparse/Test_Batched_TeamVectorSpmv.hpp index 7225f2bd0b..205ad6fa73 100644 --- a/unit_test/batched/sparse/Test_Batched_TeamVectorSpmv.hpp +++ b/unit_test/batched/sparse/Test_Batched_TeamVectorSpmv.hpp @@ -81,18 +81,8 @@ struct Functor_TestBatchedTeamVectorSpmv { inline void run() { typedef typename ValuesViewType::value_type value_type; std::string name_region("KokkosBatched::Test::TeamVectorSpmv"); - std::string name_value_type = - (std::is_same::value - ? "::Float" - : std::is_same::value - ? "::Double" - : std::is_same >::value - ? "::ComplexFloat" - : std::is_same >::value - ? "::ComplexDouble" - : "::UnknownValueType"); - std::string name = name_region + name_value_type; + const std::string name_value_type = Test::value_type_name(); + std::string name = name_region + name_value_type; Kokkos::Profiling::pushRegion(name.c_str()); Kokkos::TeamPolicy policy( _D.extent(0) / _N_team, Kokkos::AUTO(), Kokkos::AUTO());