Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BatchedTeamGemv fails with ViewType = Kokkos::DynRankView<> #1764

Closed
japlews opened this issue Mar 30, 2023 · 10 comments
Closed

BatchedTeamGemv fails with ViewType = Kokkos::DynRankView<> #1764

japlews opened this issue Mar 30, 2023 · 10 comments
Assignees

Comments

@japlews
Copy link

japlews commented Mar 30, 2023

BatchedTeamGemv is now incompatible with Kokkos::DynRankView<> because of static assertions on View rank. See KokkosBatched_Gemv_Team_Impl.hpp:48:

    static_assert(AViewType::Rank == 3,
                  "Batched TeamGemv requires rank-3 A matrix (use "
                  "KokkosBlas::TeamGemv for regular rank-2 matrix)");

I can work around this issue by using the Batched_Gemm interface instead (which does not require compile-time View dimensions for some reason), but I'm wondering if there are plans to continue support for DynRankView?

Thanks!
Julia

@kliegeois
Copy link
Contributor

@lucbv do you have an opinion about this support? I don't have experience with DynRankView.

@e10harvey
Copy link
Contributor

@japlews: While the functor-level interfaces (https://kokkos-kernels.readthedocs.io/en/latest/developer/apidocs/batched_dense.html#gemm) do not check the compile-time View dimensions, our host-level BatchedGemm function does:
/// \brief Non-blocking solve of general matrix multiply on a batch of

@japlews
Copy link
Author

japlews commented Mar 31, 2023

Thanks for the information. Would it be possible to support an API with conditional compile- and run-time checks based on the existence of a compile-time View rank? The Trilinos/Intrepid2 library is the use case in question here, where the API-level array types they rely on are almost all Kokkos::DynRankViews... Or otherwise something more complex that is duck-typed like a Kokkos::DynRankView.

@e10harvey
Copy link
Contributor

@japlews: For this use-case, Rank in ViewType::Rank would not exist? If so, I think this can be supported via sizeof and SFINAE.

@japlews
Copy link
Author

japlews commented Mar 31, 2023

@e10harvey, exactly. DynRankViews have a method called ViewType::rank() rather than a ViewType::Rank based on template parameters. It seems in principle like this would be tractable using constexpr if rather than SFINAE. See, for example, the free functions defined at https://github.com/kokkos/kokkos/blob/aa1f48f3172069f212ed2c97b74b786999b26f17/core/src/Kokkos_View.hpp#L1690 and https://github.com/kokkos/kokkos/blob/aa1f48f3172069f212ed2c97b74b786999b26f17/containers/src/Kokkos_DynRankView.hpp#L1302

@lucbv
Copy link
Contributor

lucbv commented Mar 31, 2023

I am thinking something like this:

if constexpr (Kokkos::is_dyn_rank_view<user_type>::value) {
   // runtime check of view.rank();
} else {
   static_assert(user_type::rank == 3)
}

@e10harvey
Copy link
Contributor

Nice!

@e10harvey
Copy link
Contributor

e10harvey commented Jun 12, 2023

@japlews: A fix for this was propsed via #1850 last week, can you please check if that fix resolves this issue?

@japlews
Copy link
Author

japlews commented Jun 16, 2023

@e10harvey, I was able to confirm that my code builds and runs with the fixes. Thanks!

@e10harvey
Copy link
Contributor

Closing as complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants