From 26060b7e4f071d4774e19bdb5b6bf47fcdbf5fe7 Mon Sep 17 00:00:00 2001 From: Nathan Ellingwood Date: Tue, 12 Mar 2024 14:37:48 -0600 Subject: [PATCH 1/2] stokhos: attempted compatibility update of spmv usage Compatibility update corresponding to kokkos/kokkos-kernels#2126 --- .../pce/linalg/Kokkos_CrsMatrix_UQ_PCE.hpp | 38 ++++++++++++++++--- .../linalg/Kokkos_CrsMatrix_MP_Vector.hpp | 38 ++++++++++++++++--- 2 files changed, 66 insertions(+), 10 deletions(-) diff --git a/packages/stokhos/src/sacado/kokkos/pce/linalg/Kokkos_CrsMatrix_UQ_PCE.hpp b/packages/stokhos/src/sacado/kokkos/pce/linalg/Kokkos_CrsMatrix_UQ_PCE.hpp index 6683ee7689bc..bd951d700755 100644 --- a/packages/stokhos/src/sacado/kokkos/pce/linalg/Kokkos_CrsMatrix_UQ_PCE.hpp +++ b/packages/stokhos/src/sacado/kokkos/pce/linalg/Kokkos_CrsMatrix_UQ_PCE.hpp @@ -1481,20 +1481,33 @@ template < typename std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< InputType, InputP... > >::value && Kokkos::is_view_uq_pce< Kokkos::View< OutputType, OutputP... > >::value +#if KOKKOSKERNELS_VERSION >= 40299 + // TODO what is an alternative compile-time option to determine the rank? + // Is rank appropriate here, or is additional checking based on specialize trait needed? + && (Kokkos::View< OutputType, OutputP... >().rank() == 1) +#endif >::type spmv( #if KOKKOSKERNELS_VERSION >= 40199 const ExecutionSpace& space, #endif +#if KOKKOSKERNELS_VERSION < 40299 KokkosKernels::Experimental::Controls, +#else + KokkosSparse::SPMVHandle, Kokkos::View< OutputType, OutputP... >>* handle, +#endif const char mode[], const AlphaType& a, const MatrixType& A, const Kokkos::View< InputType, InputP... >& x, const BetaType& b, - const Kokkos::View< OutputType, OutputP... >& y, - const RANK_ONE) + const Kokkos::View< OutputType, OutputP... >& y +#if KOKKOSKERNELS_VERSION < 40299 + , const RANK_ONE +#endif + ) { + std::cout << " STOKHOS UQPCE SPMV R1" << std::endl; typedef Kokkos::View< OutputType, OutputP... > OutputVectorType; typedef Kokkos::View< InputType, InputP... > InputVectorType; typedef Stokhos::Multiply >::value && Kokkos::is_view_uq_pce< Kokkos::View< OutputType, OutputP... > >::value +#if KOKKOSKERNELS_VERSION >= 40299 + // TODO what is an alternative compile-time option to determine the rank? + // Is rank appropriate here, or is additional checking based on specialize trait needed? + && (Kokkos::View< OutputType, OutputP... >().rank() == 2) +#endif >::type spmv( #if KOKKOSKERNELS_VERSION >= 40199 const ExecutionSpace& space, #endif +#if KOKKOSKERNELS_VERSION < 40299 KokkosKernels::Experimental::Controls, +#else + KokkosSparse::SPMVHandle, Kokkos::View< OutputType, OutputP... >>* handle, +#endif const char mode[], const AlphaType& a, const MatrixType& A, const Kokkos::View< InputType, InputP... >& x, const BetaType& b, - const Kokkos::View< OutputType, OutputP... >& y, - const RANK_TWO) + const Kokkos::View< OutputType, OutputP... >& y +#if KOKKOSKERNELS_VERSION < 40299 + , const RANK_TWO +#endif + ) { + std::cout << " STOKHOS UQPCE SPMV R2" << std::endl; #if KOKKOSKERNELS_VERSION >= 40199 if(space != ExecutionSpace()) { Kokkos::Impl::raise_error( @@ -1569,7 +1595,9 @@ spmv( if (y.extent(1) == 1) { auto y_1D = subview(y, Kokkos::ALL(), 0); auto x_1D = subview(x, Kokkos::ALL(), 0); -#if KOKKOSKERNELS_VERSION >= 40199 +#if KOKKOSKERNELS_VERSION >= 40299 + spmv(space, handle, mode, a, A, x_1D, b, y_1D); +#elif (KOKKOSKERNELS_VERSION < 40299) && (KOKKOSKERNELS_VERSION >= 40199) spmv(space, KokkosKernels::Experimental::Controls(), mode, a, A, x_1D, b, y_1D, RANK_ONE()); #else spmv(KokkosKernels::Experimental::Controls(), mode, a, A, x_1D, b, y_1D, RANK_ONE()); diff --git a/packages/stokhos/src/sacado/kokkos/vector/linalg/Kokkos_CrsMatrix_MP_Vector.hpp b/packages/stokhos/src/sacado/kokkos/vector/linalg/Kokkos_CrsMatrix_MP_Vector.hpp index e1c828a60740..c276b9d62757 100644 --- a/packages/stokhos/src/sacado/kokkos/vector/linalg/Kokkos_CrsMatrix_MP_Vector.hpp +++ b/packages/stokhos/src/sacado/kokkos/vector/linalg/Kokkos_CrsMatrix_MP_Vector.hpp @@ -543,20 +543,33 @@ template < typename std::enable_if< Kokkos::is_view_mp_vector< Kokkos::View< InputType, InputP... > >::value && Kokkos::is_view_mp_vector< Kokkos::View< OutputType, OutputP... > >::value +#if KOKKOSKERNELS_VERSION >= 40299 + // TODO what is an alternative compile-time option to determine the rank? + // Is rank appropriate here, or is additional checking based on specialize trait needed? + && (Kokkos::View< OutputType, OutputP... >().rank() == 1) +#endif >::type spmv( #if KOKKOSKERNELS_VERSION >= 40199 const ExecutionSpace& space, #endif +#if KOKKOSKERNELS_VERSION < 40299 KokkosKernels::Experimental::Controls, +#else + KokkosSparse::SPMVHandle, Kokkos::View< OutputType, OutputP... >>* handle, +#endif const char mode[], const AlphaType& a, const MatrixType& A, const Kokkos::View< InputType, InputP... >& x, const BetaType& b, - const Kokkos::View< OutputType, OutputP... >& y, - const RANK_ONE) + const Kokkos::View< OutputType, OutputP... >& y +#if KOKKOSKERNELS_VERSION < 40299 + , const RANK_ONE +#endif + ) { + std::cout << " STOKHOS MPVEC SPMV R1" << std::endl; typedef Kokkos::View< OutputType, OutputP... > OutputVectorType; typedef Kokkos::View< InputType, InputP... > InputVectorType; using input_vector_type = const_type_t; @@ -640,20 +653,33 @@ template < typename std::enable_if< Kokkos::is_view_mp_vector< Kokkos::View< InputType, InputP... > >::value && Kokkos::is_view_mp_vector< Kokkos::View< OutputType, OutputP... > >::value +#if KOKKOSKERNELS_VERSION >= 40299 + // TODO what is an alternative compile-time option to determine the rank? + // Is rank appropriate here, or is additional checking based on specialize trait needed? + && (Kokkos::View< OutputType, OutputP... >().rank() == 2) +#endif >::type spmv( #if KOKKOSKERNELS_VERSION >= 40199 const ExecutionSpace& space, #endif +#if KOKKOSKERNELS_VERSION < 40299 KokkosKernels::Experimental::Controls, +#else + KokkosSparse::SPMVHandle, Kokkos::View< OutputType, OutputP... >>* handle, +#endif const char mode[], const AlphaType& a, const MatrixType& A, const Kokkos::View< InputType, InputP... >& x, const BetaType& b, - const Kokkos::View< OutputType, OutputP... >& y, - const RANK_TWO) + const Kokkos::View< OutputType, OutputP... >& y +#if KOKKOSKERNELS_VERSION < 40299 + , const RANK_TWO +#endif + ) { + std::cout << " STOKHOS MPVEC SPMV R2" << std::endl; #if KOKKOSKERNELS_VERSION >= 40199 if(space != ExecutionSpace()) { Kokkos::Impl::raise_error( @@ -667,7 +693,9 @@ spmv( if (y.extent(1) == 1) { auto y_1D = subview(y, Kokkos::ALL(), 0); auto x_1D = subview(x, Kokkos::ALL(), 0); -#if KOKKOSKERNELS_VERSION >= 40199 +#if KOKKOSKERNELS_VERSION >= 40299 + spmv(space, handle, mode, a, A, x_1D, b, y_1D); +#elif (KOKKOSKERNELS_VERSION < 40299) && (KOKKOSKERNELS_VERSION >= 40199) spmv(space, KokkosKernels::Experimental::Controls(), mode, a, A, x_1D, b, y_1D, RANK_ONE()); #else spmv(KokkosKernels::Experimental::Controls(), mode, a, A, x_1D, b, y_1D, RANK_ONE()); From 3904ea84f1a5776ff4ec49a9918d7708c041a562 Mon Sep 17 00:00:00 2001 From: Brian Kelley Date: Wed, 13 Mar 2024 10:46:29 -0600 Subject: [PATCH 2/2] Finish updating sacado overloads of spmv --- .../pce/linalg/Kokkos_CrsMatrix_UQ_PCE.hpp | 22 +++++++++-------- .../linalg/Kokkos_CrsMatrix_MP_Vector.hpp | 24 ++++++++++--------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/packages/stokhos/src/sacado/kokkos/pce/linalg/Kokkos_CrsMatrix_UQ_PCE.hpp b/packages/stokhos/src/sacado/kokkos/pce/linalg/Kokkos_CrsMatrix_UQ_PCE.hpp index bd951d700755..6031d6fc4d2d 100644 --- a/packages/stokhos/src/sacado/kokkos/pce/linalg/Kokkos_CrsMatrix_UQ_PCE.hpp +++ b/packages/stokhos/src/sacado/kokkos/pce/linalg/Kokkos_CrsMatrix_UQ_PCE.hpp @@ -1470,6 +1470,9 @@ namespace KokkosSparse { template < #if KOKKOSKERNELS_VERSION >= 40199 typename ExecutionSpace, +#endif +#if KOKKOSKERNELS_VERSION >= 40299 + typename Handle, #endif typename AlphaType, typename BetaType, @@ -1482,9 +1485,8 @@ typename std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< InputType, InputP... > >::value && Kokkos::is_view_uq_pce< Kokkos::View< OutputType, OutputP... > >::value #if KOKKOSKERNELS_VERSION >= 40299 - // TODO what is an alternative compile-time option to determine the rank? - // Is rank appropriate here, or is additional checking based on specialize trait needed? - && (Kokkos::View< OutputType, OutputP... >().rank() == 1) + && KokkosSparse::is_crs_matrix_v + && (Kokkos::View< OutputType, OutputP... >::rank() == 1) #endif >::type spmv( @@ -1494,7 +1496,7 @@ spmv( #if KOKKOSKERNELS_VERSION < 40299 KokkosKernels::Experimental::Controls, #else - KokkosSparse::SPMVHandle, Kokkos::View< OutputType, OutputP... >>* handle, + Handle* handle, #endif const char mode[], const AlphaType& a, @@ -1507,7 +1509,6 @@ spmv( #endif ) { - std::cout << " STOKHOS UQPCE SPMV R1" << std::endl; typedef Kokkos::View< OutputType, OutputP... > OutputVectorType; typedef Kokkos::View< InputType, InputP... > InputVectorType; typedef Stokhos::Multiply= 40199 typename ExecutionSpace, +#endif +#if KOKKOSKERNELS_VERSION >= 40299 + typename Handle, #endif typename AlphaType, typename BetaType, @@ -1556,9 +1560,8 @@ typename std::enable_if< Kokkos::is_view_uq_pce< Kokkos::View< InputType, InputP... > >::value && Kokkos::is_view_uq_pce< Kokkos::View< OutputType, OutputP... > >::value #if KOKKOSKERNELS_VERSION >= 40299 - // TODO what is an alternative compile-time option to determine the rank? - // Is rank appropriate here, or is additional checking based on specialize trait needed? - && (Kokkos::View< OutputType, OutputP... >().rank() == 2) + && KokkosSparse::is_crs_matrix_v + && (Kokkos::View< OutputType, OutputP... >::rank() == 2) #endif >::type spmv( @@ -1568,7 +1571,7 @@ spmv( #if KOKKOSKERNELS_VERSION < 40299 KokkosKernels::Experimental::Controls, #else - KokkosSparse::SPMVHandle, Kokkos::View< OutputType, OutputP... >>* handle, + Handle* handle, #endif const char mode[], const AlphaType& a, @@ -1581,7 +1584,6 @@ spmv( #endif ) { - std::cout << " STOKHOS UQPCE SPMV R2" << std::endl; #if KOKKOSKERNELS_VERSION >= 40199 if(space != ExecutionSpace()) { Kokkos::Impl::raise_error( diff --git a/packages/stokhos/src/sacado/kokkos/vector/linalg/Kokkos_CrsMatrix_MP_Vector.hpp b/packages/stokhos/src/sacado/kokkos/vector/linalg/Kokkos_CrsMatrix_MP_Vector.hpp index c276b9d62757..2fd9472604c8 100644 --- a/packages/stokhos/src/sacado/kokkos/vector/linalg/Kokkos_CrsMatrix_MP_Vector.hpp +++ b/packages/stokhos/src/sacado/kokkos/vector/linalg/Kokkos_CrsMatrix_MP_Vector.hpp @@ -532,6 +532,9 @@ namespace KokkosSparse { template < #if KOKKOSKERNELS_VERSION >= 40199 typename ExecutionSpace, +#endif +#if KOKKOSKERNELS_VERSION >= 40299 + typename Handle, #endif typename AlphaType, typename BetaType, @@ -544,9 +547,8 @@ typename std::enable_if< Kokkos::is_view_mp_vector< Kokkos::View< InputType, InputP... > >::value && Kokkos::is_view_mp_vector< Kokkos::View< OutputType, OutputP... > >::value #if KOKKOSKERNELS_VERSION >= 40299 - // TODO what is an alternative compile-time option to determine the rank? - // Is rank appropriate here, or is additional checking based on specialize trait needed? - && (Kokkos::View< OutputType, OutputP... >().rank() == 1) + && KokkosSparse::is_crs_matrix_v + && (Kokkos::View< OutputType, OutputP... >::rank() == 1) #endif >::type spmv( @@ -556,7 +558,7 @@ spmv( #if KOKKOSKERNELS_VERSION < 40299 KokkosKernels::Experimental::Controls, #else - KokkosSparse::SPMVHandle, Kokkos::View< OutputType, OutputP... >>* handle, + Handle* handle, #endif const char mode[], const AlphaType& a, @@ -567,9 +569,8 @@ spmv( #if KOKKOSKERNELS_VERSION < 40299 , const RANK_ONE #endif - ) +) { - std::cout << " STOKHOS MPVEC SPMV R1" << std::endl; typedef Kokkos::View< OutputType, OutputP... > OutputVectorType; typedef Kokkos::View< InputType, InputP... > InputVectorType; using input_vector_type = const_type_t; @@ -642,6 +643,9 @@ spmv( template < #if KOKKOSKERNELS_VERSION >= 40199 typename ExecutionSpace, +#endif +#if KOKKOSKERNELS_VERSION >= 40299 + typename Handle, #endif typename AlphaType, typename BetaType, @@ -654,9 +658,8 @@ typename std::enable_if< Kokkos::is_view_mp_vector< Kokkos::View< InputType, InputP... > >::value && Kokkos::is_view_mp_vector< Kokkos::View< OutputType, OutputP... > >::value #if KOKKOSKERNELS_VERSION >= 40299 - // TODO what is an alternative compile-time option to determine the rank? - // Is rank appropriate here, or is additional checking based on specialize trait needed? - && (Kokkos::View< OutputType, OutputP... >().rank() == 2) + && KokkosSparse::is_crs_matrix_v + && (Kokkos::View< OutputType, OutputP... >::rank() == 2) #endif >::type spmv( @@ -666,7 +669,7 @@ spmv( #if KOKKOSKERNELS_VERSION < 40299 KokkosKernels::Experimental::Controls, #else - KokkosSparse::SPMVHandle, Kokkos::View< OutputType, OutputP... >>* handle, + Handle* handle, #endif const char mode[], const AlphaType& a, @@ -679,7 +682,6 @@ spmv( #endif ) { - std::cout << " STOKHOS MPVEC SPMV R2" << std::endl; #if KOKKOSKERNELS_VERSION >= 40199 if(space != ExecutionSpace()) { Kokkos::Impl::raise_error(