From 8e41e93ba170924f2f9565b1981eaf286dc40f73 Mon Sep 17 00:00:00 2001 From: Luc Berger-Vergiat Date: Thu, 16 Apr 2026 11:59:57 -0600 Subject: [PATCH 1/8] Batched: allowing dynrankview in get_extent get_stride Some downstream libraries and applications like Intrepid2 use dynamic rank views and we need to allow them to get passed in as input parameters. Signed-off-by: Luc Berger-Vergiat --- batched/KokkosBatched_Util.hpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/batched/KokkosBatched_Util.hpp b/batched/KokkosBatched_Util.hpp index c8dae37678..0760cc72a2 100644 --- a/batched/KokkosBatched_Util.hpp +++ b/batched/KokkosBatched_Util.hpp @@ -22,6 +22,7 @@ #include #include "Kokkos_Complex.hpp" +#include "Kokkos_DynRankView.hpp" #include "KokkosKernels_config.h" #include "KokkosKernels_Macros.hpp" @@ -677,9 +678,16 @@ KOKKOS_INLINE_FUNCTION void fma_bounds_check(ViewType v, SizeType m, SizeType n, namespace Impl { template KOKKOS_INLINE_FUNCTION int get_extent_int(const ViewType &v, const int r) { - static_assert(Kokkos::is_view_v, "KokkosBatched: ViewType is not a Kokkos::View."); - constexpr std::size_t V_rank = ViewType::rank(); - static_assert(V_rank <= 2, "KokkosBatched: ViewType must have rank 0, 1 or 2."); + // Check for view and dynrankview + if constexpr (Kokkos::is_view_v) { + static_assert(ViewType::rank() <= 2, "KokkosBatched: ViewType must have rank 0, 1 or 2."); + } else if constexpr (Kokkos::is_dyn_rank_view_v) { + if (v.rank() > 2) { + throw std::runtime_error("KokkosBatched: ViewType must have rank 0, 1 or 2."); + } + } + + const std::size_t V_rank = v.rank(); if (r == 0) { int V_extent_0 = V_rank < 1 ? 1 : v.extent_int(0); @@ -694,9 +702,16 @@ KOKKOS_INLINE_FUNCTION int get_extent_int(const ViewType &v, const int r) { template KOKKOS_INLINE_FUNCTION std::size_t get_stride(const ViewType &v, const int r) { - static_assert(Kokkos::is_view_v, "KokkosBatched: ViewType is not a Kokkos::View."); - constexpr std::size_t V_rank = ViewType::rank(); - static_assert(V_rank <= 2, "KokkosBatched: ViewType must have rank 0, 1 or 2."); + // Check for view and dynrankview + if constexpr (Kokkos::is_view_v) { + static_assert(ViewType::rank() <= 2, "KokkosBatched: ViewType must have rank 0, 1 or 2."); + } else if constexpr (Kokkos::is_dyn_rank_view_v) { + if (v.rank() > 2) { + throw std::runtime_error("KokkosBatched: ViewType must have rank 0, 1 or 2."); + } + } + + const std::size_t V_rank = v.rank(); if (r == 0) { std::size_t V_stride_0 = V_rank < 1 ? 1 : v.stride(0); From 7de61785513ad4b334591284666dfed790b70ce1 Mon Sep 17 00:00:00 2001 From: Luc Berger Date: Thu, 16 Apr 2026 20:06:22 -0600 Subject: [PATCH 2/8] Update batched/KokkosBatched_Util.hpp Signed-off-by: Luc Berger --- batched/KokkosBatched_Util.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/batched/KokkosBatched_Util.hpp b/batched/KokkosBatched_Util.hpp index 0760cc72a2..24abf8d236 100644 --- a/batched/KokkosBatched_Util.hpp +++ b/batched/KokkosBatched_Util.hpp @@ -681,10 +681,8 @@ KOKKOS_INLINE_FUNCTION int get_extent_int(const ViewType &v, const int r) { // Check for view and dynrankview if constexpr (Kokkos::is_view_v) { static_assert(ViewType::rank() <= 2, "KokkosBatched: ViewType must have rank 0, 1 or 2."); - } else if constexpr (Kokkos::is_dyn_rank_view_v) { - if (v.rank() > 2) { - throw std::runtime_error("KokkosBatched: ViewType must have rank 0, 1 or 2."); - } + } else { + `static_assert(Kokkos::is_dyn_rank_view_v, "KokkosBatched: ViewType must be a Kokkos::View or a Kokkos::DynRankView");` } const std::size_t V_rank = v.rank(); From 946716276b6e0431e54fd240c17f5ebd2b701f8a Mon Sep 17 00:00:00 2001 From: Luc Berger Date: Thu, 16 Apr 2026 20:06:29 -0600 Subject: [PATCH 3/8] Update batched/KokkosBatched_Util.hpp Signed-off-by: Luc Berger --- batched/KokkosBatched_Util.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/batched/KokkosBatched_Util.hpp b/batched/KokkosBatched_Util.hpp index 24abf8d236..ca535c52e6 100644 --- a/batched/KokkosBatched_Util.hpp +++ b/batched/KokkosBatched_Util.hpp @@ -703,10 +703,8 @@ KOKKOS_INLINE_FUNCTION std::size_t get_stride(const ViewType &v, const int r) { // Check for view and dynrankview if constexpr (Kokkos::is_view_v) { static_assert(ViewType::rank() <= 2, "KokkosBatched: ViewType must have rank 0, 1 or 2."); - } else if constexpr (Kokkos::is_dyn_rank_view_v) { - if (v.rank() > 2) { - throw std::runtime_error("KokkosBatched: ViewType must have rank 0, 1 or 2."); - } + } else if constexpr () { + static_assert(Kokkos::is_dyn_rank_view_v, "KokkosBatched: ViewType must be a Kokkos::View or a Kokkos::DynRankView"); } const std::size_t V_rank = v.rank(); From 8054162f31844d0cd50a5d9f5a86149af9664549 Mon Sep 17 00:00:00 2001 From: Luc Berger Date: Thu, 16 Apr 2026 20:08:40 -0600 Subject: [PATCH 4/8] Update batched/KokkosBatched_Util.hpp Signed-off-by: Luc Berger --- batched/KokkosBatched_Util.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batched/KokkosBatched_Util.hpp b/batched/KokkosBatched_Util.hpp index ca535c52e6..2619395c6a 100644 --- a/batched/KokkosBatched_Util.hpp +++ b/batched/KokkosBatched_Util.hpp @@ -682,7 +682,7 @@ KOKKOS_INLINE_FUNCTION int get_extent_int(const ViewType &v, const int r) { if constexpr (Kokkos::is_view_v) { static_assert(ViewType::rank() <= 2, "KokkosBatched: ViewType must have rank 0, 1 or 2."); } else { - `static_assert(Kokkos::is_dyn_rank_view_v, "KokkosBatched: ViewType must be a Kokkos::View or a Kokkos::DynRankView");` + static_assert(Kokkos::is_dyn_rank_view_v, "KokkosBatched: ViewType must be a Kokkos::View or a Kokkos::DynRankView"); } const std::size_t V_rank = v.rank(); From 2373c33d113a965f75308ab6fb5c6eca25585b10 Mon Sep 17 00:00:00 2001 From: Luc Berger Date: Thu, 16 Apr 2026 20:10:04 -0600 Subject: [PATCH 5/8] Update batched/KokkosBatched_Util.hpp Signed-off-by: Luc Berger --- batched/KokkosBatched_Util.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/batched/KokkosBatched_Util.hpp b/batched/KokkosBatched_Util.hpp index 2619395c6a..14a979ad67 100644 --- a/batched/KokkosBatched_Util.hpp +++ b/batched/KokkosBatched_Util.hpp @@ -703,7 +703,7 @@ KOKKOS_INLINE_FUNCTION std::size_t get_stride(const ViewType &v, const int r) { // Check for view and dynrankview if constexpr (Kokkos::is_view_v) { static_assert(ViewType::rank() <= 2, "KokkosBatched: ViewType must have rank 0, 1 or 2."); - } else if constexpr () { + } else { static_assert(Kokkos::is_dyn_rank_view_v, "KokkosBatched: ViewType must be a Kokkos::View or a Kokkos::DynRankView"); } From 4ef0fa51f4cb396efd9bd8566600abad5159ad4a Mon Sep 17 00:00:00 2001 From: Luc Berger-Vergiat Date: Fri, 17 Apr 2026 13:40:58 -0600 Subject: [PATCH 6/8] Re-adding the DynRankView branch to check rank We really do require these views to have only rank 0, 1 or 2 as we later on index with the raw pointer directly and will only use two extents and strides to do so... Signed-off-by: Luc Berger-Vergiat --- batched/KokkosBatched_Util.hpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/batched/KokkosBatched_Util.hpp b/batched/KokkosBatched_Util.hpp index 14a979ad67..f64b797125 100644 --- a/batched/KokkosBatched_Util.hpp +++ b/batched/KokkosBatched_Util.hpp @@ -21,6 +21,7 @@ #include #include +#include #include "Kokkos_Complex.hpp" #include "Kokkos_DynRankView.hpp" @@ -681,10 +682,12 @@ KOKKOS_INLINE_FUNCTION int get_extent_int(const ViewType &v, const int r) { // Check for view and dynrankview if constexpr (Kokkos::is_view_v) { static_assert(ViewType::rank() <= 2, "KokkosBatched: ViewType must have rank 0, 1 or 2."); + } else if constexpr (Kokkos::is_dyn_rank_view_v) { + KOKKOS_EXPECTS((v.rank() <= 2)); } else { - static_assert(Kokkos::is_dyn_rank_view_v, "KokkosBatched: ViewType must be a Kokkos::View or a Kokkos::DynRankView"); + static_assert(false, "KokkosBatched: ViewType must be a Kokkos::View or a Kokkos::DynRankView"); } - + const std::size_t V_rank = v.rank(); if (r == 0) { @@ -703,10 +706,12 @@ KOKKOS_INLINE_FUNCTION std::size_t get_stride(const ViewType &v, const int r) { // Check for view and dynrankview if constexpr (Kokkos::is_view_v) { static_assert(ViewType::rank() <= 2, "KokkosBatched: ViewType must have rank 0, 1 or 2."); + } else if constexpr (Kokkos::is_dyn_rank_view_v) { + KOKKOS_EXPECTS((v.rank() <= 2)); } else { - static_assert(Kokkos::is_dyn_rank_view_v, "KokkosBatched: ViewType must be a Kokkos::View or a Kokkos::DynRankView"); + static_assert(false, "KokkosBatched: ViewType must be a Kokkos::View or a Kokkos::DynRankView"); } - + const std::size_t V_rank = v.rank(); if (r == 0) { From a64faf50c3839c745b0164b2901e7185795584a0 Mon Sep 17 00:00:00 2001 From: Luc Berger-Vergiat Date: Fri, 17 Apr 2026 13:57:48 -0600 Subject: [PATCH 7/8] Fix if constexpr static_assert statement Signed-off-by: Luc Berger-Vergiat --- batched/KokkosBatched_Util.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/batched/KokkosBatched_Util.hpp b/batched/KokkosBatched_Util.hpp index f64b797125..293e3cb2ab 100644 --- a/batched/KokkosBatched_Util.hpp +++ b/batched/KokkosBatched_Util.hpp @@ -685,7 +685,7 @@ KOKKOS_INLINE_FUNCTION int get_extent_int(const ViewType &v, const int r) { } else if constexpr (Kokkos::is_dyn_rank_view_v) { KOKKOS_EXPECTS((v.rank() <= 2)); } else { - static_assert(false, "KokkosBatched: ViewType must be a Kokkos::View or a Kokkos::DynRankView"); + static_assert(Kokkos::is_view_v || Kokkos::is_dyn_rank_view_v, "KokkosBatched: ViewType must be a Kokkos::View or a Kokkos::DynRankView"); } const std::size_t V_rank = v.rank(); @@ -709,7 +709,8 @@ KOKKOS_INLINE_FUNCTION std::size_t get_stride(const ViewType &v, const int r) { } else if constexpr (Kokkos::is_dyn_rank_view_v) { KOKKOS_EXPECTS((v.rank() <= 2)); } else { - static_assert(false, "KokkosBatched: ViewType must be a Kokkos::View or a Kokkos::DynRankView"); + static_assert(Kokkos::is_view_v || Kokkos::is_dyn_rank_view_v, + "KokkosBatched: ViewType must be a Kokkos::View or a Kokkos::DynRankView"); } const std::size_t V_rank = v.rank(); From 511fcd1b75e7f1d6ab00845025697f13c3a1343d Mon Sep 17 00:00:00 2001 From: Luc Berger-Vergiat Date: Fri, 17 Apr 2026 14:02:40 -0600 Subject: [PATCH 8/8] clang-format Signed-off-by: Luc Berger-Vergiat --- batched/KokkosBatched_Util.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/batched/KokkosBatched_Util.hpp b/batched/KokkosBatched_Util.hpp index 293e3cb2ab..ceee7346da 100644 --- a/batched/KokkosBatched_Util.hpp +++ b/batched/KokkosBatched_Util.hpp @@ -685,7 +685,8 @@ KOKKOS_INLINE_FUNCTION int get_extent_int(const ViewType &v, const int r) { } else if constexpr (Kokkos::is_dyn_rank_view_v) { KOKKOS_EXPECTS((v.rank() <= 2)); } else { - static_assert(Kokkos::is_view_v || Kokkos::is_dyn_rank_view_v, "KokkosBatched: ViewType must be a Kokkos::View or a Kokkos::DynRankView"); + static_assert(Kokkos::is_view_v || Kokkos::is_dyn_rank_view_v, + "KokkosBatched: ViewType must be a Kokkos::View or a Kokkos::DynRankView"); } const std::size_t V_rank = v.rank(); @@ -710,7 +711,7 @@ KOKKOS_INLINE_FUNCTION std::size_t get_stride(const ViewType &v, const int r) { KOKKOS_EXPECTS((v.rank() <= 2)); } else { static_assert(Kokkos::is_view_v || Kokkos::is_dyn_rank_view_v, - "KokkosBatched: ViewType must be a Kokkos::View or a Kokkos::DynRankView"); + "KokkosBatched: ViewType must be a Kokkos::View or a Kokkos::DynRankView"); } const std::size_t V_rank = v.rank();