From a25b41a29e94c553f20e41034b15c7aac25c1cf3 Mon Sep 17 00:00:00 2001 From: Mark Hoemmen Date: Wed, 2 May 2018 17:36:00 -0600 Subject: [PATCH] TSQR: Fix #2668 --- .../tpetra/tsqr/src/Tsqr_CombineNative.hpp | 143 ++++++++++-------- 1 file changed, 76 insertions(+), 67 deletions(-) diff --git a/packages/tpetra/tsqr/src/Tsqr_CombineNative.hpp b/packages/tpetra/tsqr/src/Tsqr_CombineNative.hpp index f189ec75e08a..2187fa0d0360 100644 --- a/packages/tpetra/tsqr/src/Tsqr_CombineNative.hpp +++ b/packages/tpetra/tsqr/src/Tsqr_CombineNative.hpp @@ -182,10 +182,19 @@ namespace TSQR { template< class Ordinal, class Scalar > class CombineNative< Ordinal, Scalar, false > { + private: + using memory_space = Kokkos::HostSpace; +#ifdef KOKKOS_ENABLE_SERIAL + using execution_space = Kokkos::Serial; +#else // NOT KOKKOS_ENABLE_SERIAL + using execution_space = Kokkos::HostSpace::execution_space; +#endif // KOKKOS_ENABLE_SERIAL + public: typedef Scalar scalar_type; typedef typename Teuchos::ScalarTraits< Scalar >::magnitudeType magnitude_type; typedef Ordinal ordinal_type; + using device_type = Kokkos::Device; private: typedef Teuchos::LAPACK lapack_type; @@ -193,14 +202,14 @@ namespace TSQR { void GER (const magnitude_type alpha, - const Kokkos::View& x, - const Kokkos::View& y, - const Kokkos::View& A) const; + const Kokkos::View& x, + const Kokkos::View& y, + const Kokkos::View& A) const; void LARFG (const Ordinal n, scalar_type* const alpha, - const Kokkos::View& x, + const Kokkos::View& x, scalar_type* const tau) const { constexpr Ordinal incx {1}; @@ -236,38 +245,38 @@ namespace TSQR { void GEMV (const char trans[], const scalar_type alpha, - const Kokkos::View& A, - const Kokkos::View& x, + const Kokkos::View& A, + const Kokkos::View& x, const scalar_type beta, - const Kokkos::View& y) const; + const Kokkos::View& y) const; void - factor_pair (const Kokkos::View& R_top, - const Kokkos::View& R_bot, - const Kokkos::View& tau_view, - const Kokkos::View& work_view) const; + factor_pair (const Kokkos::View& R_top, + const Kokkos::View& R_bot, + const Kokkos::View& tau_view, + const Kokkos::View& work_view) const; void - factor_inner (const Kokkos::View& R_view, - const Kokkos::View& A_view, - const Kokkos::View& tau_view, - const Kokkos::View& work_view) const; + factor_inner (const Kokkos::View& R_view, + const Kokkos::View& A_view, + const Kokkos::View& tau_view, + const Kokkos::View& work_view) const; void apply_pair (const ApplyType& applyType, - const Kokkos::View& R_bot, // ncols_Q - const Kokkos::View& tau_view, - const Kokkos::View& C_top, // ncols_C - const Kokkos::View& C_bot, - const Kokkos::View& work_view) const; + const Kokkos::View& R_bot, // ncols_Q + const Kokkos::View& tau_view, + const Kokkos::View& C_top, // ncols_C + const Kokkos::View& C_bot, + const Kokkos::View& work_view) const; void apply_inner (const ApplyType& applyType, - const Kokkos::View& A, - const Kokkos::View& tau, - const Kokkos::View& C_top, - const Kokkos::View& C_bot, - const Kokkos::View& work) const; + const Kokkos::View& A, + const Kokkos::View& tau, + const Kokkos::View& C_top, + const Kokkos::View& C_bot, + const Kokkos::View& work) const; public: CombineNative () = default; @@ -477,9 +486,9 @@ namespace TSQR { void CombineNative< Ordinal, Scalar, false >:: GER (const magnitude_type alpha, - const Kokkos::View& x, - const Kokkos::View& y, - const Kokkos::View& A) const + const Kokkos::View& x, + const Kokkos::View& y, + const Kokkos::View& A) const { constexpr scalar_type ZERO {0.0}; const Ordinal m = A.dimension_0 (); @@ -506,13 +515,13 @@ namespace TSQR { CombineNative< Ordinal, Scalar, false >:: GEMV (const char trans[], const scalar_type alpha, - const Kokkos::View& A, - const Kokkos::View& x, + const Kokkos::View& A, + const Kokkos::View& x, const scalar_type beta, - const Kokkos::View& y) const + const Kokkos::View& y) const { - using y_vec_type = Kokkos::View; - using x_vec_type = Kokkos::View; + using y_vec_type = Kokkos::View; + using x_vec_type = Kokkos::View; using range_type = std::pair; const Ordinal m = A.dimension_0 (); @@ -528,10 +537,10 @@ namespace TSQR { template< class Ordinal, class Scalar > void CombineNative< Ordinal, Scalar, false >:: - factor_inner (const Kokkos::View& R_view, - const Kokkos::View& A_view, - const Kokkos::View& tau_view, - const Kokkos::View& work_view) const + factor_inner (const Kokkos::View& R_view, + const Kokkos::View& A_view, + const Kokkos::View& tau_view, + const Kokkos::View& work_view) const { using Kokkos::ALL; using Kokkos::subview; @@ -584,9 +593,9 @@ namespace TSQR { using Kokkos::ALL; using Kokkos::subview; using mat_type = - Kokkos::View; + Kokkos::View; using nonconst_vec_type = - Kokkos::View; + Kokkos::View; using range_type = std::pair; mat_type A_full (A, lda, n); @@ -603,16 +612,16 @@ namespace TSQR { void CombineNative< Ordinal, Scalar, false >:: apply_inner (const ApplyType& applyType, - const Kokkos::View& A, - const Kokkos::View& tau, - const Kokkos::View& C_top, - const Kokkos::View& C_bot, - const Kokkos::View& work) const + const Kokkos::View& A, + const Kokkos::View& tau, + const Kokkos::View& C_top, + const Kokkos::View& C_bot, + const Kokkos::View& work) const { using Kokkos::ALL; using Kokkos::subview; using const_vec_type = - Kokkos::View; + Kokkos::View; constexpr scalar_type ZERO {0.0}; const Ordinal m = A.dimension_0 (); @@ -672,13 +681,13 @@ namespace TSQR { using Kokkos::ALL; using Kokkos::subview; using const_mat_type = - Kokkos::View; + Kokkos::View; using nonconst_mat_type = - Kokkos::View; + Kokkos::View; using const_vec_type = - Kokkos::View; + Kokkos::View; using nonconst_vec_type = - Kokkos::View; + Kokkos::View; using range_type = std::pair; const_mat_type A_full (A, lda, ncols_Q); @@ -697,10 +706,10 @@ namespace TSQR { template< class Ordinal, class Scalar > void CombineNative< Ordinal, Scalar, false >:: - factor_pair (const Kokkos::View& R_top, - const Kokkos::View& R_bot, - const Kokkos::View& tau_view, - const Kokkos::View& work_view) const + factor_pair (const Kokkos::View& R_top, + const Kokkos::View& R_bot, + const Kokkos::View& tau_view, + const Kokkos::View& work_view) const { using Kokkos::ALL; using Kokkos::subview; @@ -757,10 +766,10 @@ namespace TSQR { using Kokkos::subview; using range_type = std::pair; - Kokkos::View R_top_full (R_top, ldr_top, n); - Kokkos::View R_bot_full (R_bot, ldr_bot, n); - Kokkos::View tau_view (tau, n); - Kokkos::View work_view (work, n); + Kokkos::View R_top_full (R_top, ldr_top, n); + Kokkos::View R_bot_full (R_bot, ldr_bot, n); + Kokkos::View tau_view (tau, n); + Kokkos::View work_view (work, n); if (ldr_top == n) { if (ldr_bot == n) { @@ -803,13 +812,13 @@ namespace TSQR { using Kokkos::subview; using range_type = std::pair; using const_mat_type = - Kokkos::View; + Kokkos::View; using nonconst_mat_type = - Kokkos::View; + Kokkos::View; using const_vec_type = - Kokkos::View; + Kokkos::View; using nonconst_vec_type = - Kokkos::View; + Kokkos::View; const_mat_type R_bot_full (R_bot, ldr_bot, ncols_Q); nonconst_mat_type C_top_full (C_top, ldc_top, ncols_C); @@ -827,14 +836,14 @@ namespace TSQR { void CombineNative< Ordinal, Scalar, false >:: apply_pair (const ApplyType& applyType, - const Kokkos::View& R_bot, // ncols_Q - const Kokkos::View& tau_view, - const Kokkos::View& C_top, // ncols_C - const Kokkos::View& C_bot, - const Kokkos::View& work_view) const + const Kokkos::View& R_bot, // ncols_Q + const Kokkos::View& tau_view, + const Kokkos::View& C_top, // ncols_C + const Kokkos::View& C_bot, + const Kokkos::View& work_view) const { using const_vec_type = - Kokkos::View; + Kokkos::View; constexpr scalar_type ZERO {0.0}; const Ordinal ncols_C = C_top.dimension_1 (); const Ordinal ncols_Q = R_bot.dimension_1 ();