-
Notifications
You must be signed in to change notification settings - Fork 5
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
Upgrade to Kokkos v4.5.01 #692
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
include/ddc/kernels/splines/kokkos-kernels-ext/KokkosBatched_Gbtrs.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (C) The DDC development team, see COPYRIGHT.md file | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
// clang-format off | ||
// NOLINTBEGIN(*) | ||
|
||
#ifndef KOKKOSBATCHED_GBTRS_HPP_ | ||
#define KOKKOSBATCHED_GBTRS_HPP_ | ||
|
||
#include <KokkosBatched_Util.hpp> | ||
|
||
/// \author Yuuichi Asahi (yuuichi.asahi@cea.fr) | ||
|
||
namespace KokkosBatched { | ||
|
||
/// \brief Serial Batched Gbtrs: | ||
/// | ||
/// Solve A_l x_l = b_l for all l = 0, ..., N | ||
/// with a general band matrix A using the LU factorization computed | ||
/// by gbtrf. | ||
/// | ||
/// \tparam AViewType: Input type for the matrix, needs to be a 2D view | ||
/// \tparam BViewType: Input type for the right-hand side and the solution, | ||
/// needs to be a 1D view | ||
/// \tparam PivViewType: Integer type for pivot indices, needs to be a 1D view | ||
/// | ||
/// \param A [in]: A is a ldab by n banded matrix. | ||
/// Details of the LU factorization of the band matrix A, as computed by | ||
/// gbtrf. U is stored as an upper triangular band matrix with KL+KU | ||
/// superdiagonals in rows 1 to KL+KU+1, and the multipliers used during | ||
/// the factorization are stored in rows KL+KU+2 to 2*KL+KU+1. | ||
/// \param b [inout]: right-hand side and the solution | ||
/// \param piv [in]: The pivot indices; for 1 <= i <= N, row i of the matrix | ||
/// was interchanged with row piv(i). | ||
/// \param kl [in]: kl specifies the number of subdiagonals within the band | ||
/// of A. kl >= 0 | ||
/// \param ku [in]: ku specifies the number of superdiagonals within the band | ||
/// of A. ku >= 0 | ||
/// | ||
/// No nested parallel_for is used inside of the function. | ||
/// | ||
|
||
template <typename ArgTrans, typename ArgAlgo> | ||
struct SerialGbtrs { | ||
template <typename AViewType, typename BViewType, typename PivViewType> | ||
KOKKOS_INLINE_FUNCTION static int invoke(const AViewType &A, | ||
const BViewType &b, | ||
const PivViewType &piv, const int kl, | ||
const int ku); | ||
}; | ||
} // namespace KokkosBatched | ||
|
||
#include "KokkosBatched_Gbtrs_Serial_Impl.hpp" | ||
|
||
#endif // KOKKOSBATCHED_GBTRS_HPP_ | ||
|
||
// NOLINTEND(*) | ||
// clang-format on |
170 changes: 170 additions & 0 deletions
170
include/ddc/kernels/splines/kokkos-kernels-ext/KokkosBatched_Gbtrs_Serial_Impl.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
// Copyright (C) The DDC development team, see COPYRIGHT.md file | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
// clang-format off | ||
// NOLINTBEGIN(*) | ||
|
||
#ifndef KOKKOSBATCHED_GBTRS_SERIAL_IMPL_HPP_ | ||
#define KOKKOSBATCHED_GBTRS_SERIAL_IMPL_HPP_ | ||
|
||
#include <Kokkos_Swap.hpp> | ||
#include <KokkosBatched_Util.hpp> | ||
#include <KokkosBlas2_gemv.hpp> | ||
#include <KokkosBatched_Tbsv.hpp> | ||
|
||
namespace KokkosBatched { | ||
|
||
template <typename AViewType, typename BViewType> | ||
KOKKOS_INLINE_FUNCTION static int checkGbtrsInput( | ||
[[maybe_unused]] const AViewType &A, [[maybe_unused]] const BViewType &b, | ||
[[maybe_unused]] const int kl, [[maybe_unused]] const int ku) { | ||
static_assert(Kokkos::is_view_v<AViewType>, | ||
"KokkosBatched::gbtrs: AViewType is not a Kokkos::View."); | ||
static_assert(Kokkos::is_view_v<BViewType>, | ||
"KokkosBatched::gbtrs: BViewType is not a Kokkos::View."); | ||
static_assert(AViewType::rank == 2, | ||
"KokkosBatched::gbtrs: AViewType must have rank 2."); | ||
static_assert(BViewType::rank == 1, | ||
"KokkosBatched::gbtrs: BViewType must have rank 1."); | ||
#if (KOKKOSKERNELS_DEBUG_LEVEL > 0) | ||
if (kl < 0) { | ||
Kokkos::printf( | ||
"KokkosBatched::gbtrs: input parameter kl must not be less than 0: kl " | ||
"= " | ||
"%d\n", | ||
kl); | ||
return 1; | ||
} | ||
|
||
if (ku < 0) { | ||
Kokkos::printf( | ||
"KokkosBatched::gbtrs: input parameter ku must not be less than 0: ku " | ||
"= " | ||
"%d\n", | ||
ku); | ||
return 1; | ||
} | ||
|
||
const int lda = A.extent(0), n = A.extent(1); | ||
if (lda < (2 * kl + ku + 1)) { | ||
Kokkos::printf( | ||
"KokkosBatched::gbtrs: leading dimension of A must be smaller than 2 * " | ||
"kl + ku + 1: " | ||
"lda = %d, kl = %d, ku = %d\n", | ||
lda, kl, ku); | ||
return 1; | ||
} | ||
|
||
const int ldb = b.extent(0); | ||
if (ldb < Kokkos::max(1, n)) { | ||
Kokkos::printf( | ||
"KokkosBatched::gbtrs: leading dimension of b must be smaller than " | ||
"max(1, n): " | ||
"ldb = %d, n = %d\n", | ||
ldb, n); | ||
return 1; | ||
} | ||
|
||
#endif | ||
return 0; | ||
} | ||
|
||
//// Non-transpose //// | ||
template <> | ||
struct SerialGbtrs<Trans::NoTranspose, Algo::Level3::Unblocked> { | ||
template <typename AViewType, typename BViewType, typename PivViewType> | ||
KOKKOS_INLINE_FUNCTION static int invoke(const AViewType &A, | ||
const BViewType &b, | ||
const PivViewType &piv, const int kl, | ||
const int ku) { | ||
// Quick return if possible | ||
const int n = A.extent(1); | ||
if (n == 0) return 0; | ||
|
||
auto info = checkGbtrsInput(A, b, kl, ku); | ||
if (info) return info; | ||
|
||
bool lonti = kl > 0; | ||
const int kd = ku + kl + 1; | ||
if (lonti) { | ||
for (int j = 0; j < n - 1; ++j) { | ||
const int lm = Kokkos::min(kl, n - j - 1); | ||
auto l = piv(j); | ||
// If pivot index is not j, swap rows l and j in b | ||
if (l != j) { | ||
Kokkos::kokkos_swap(b(l), b(j)); | ||
} | ||
|
||
// Perform a rank-1 update of the remaining part of the current column | ||
// (ger) | ||
for (int i = 0; i < lm; ++i) { | ||
b(j + 1 + i) = b(j + 1 + i) - A(kd + i, j) * b(j); | ||
} | ||
} | ||
} | ||
|
||
// Solve U*X = b for each right hand side, overwriting B with X. | ||
[[maybe_unused]] auto info_tbsv = | ||
KokkosBatched::SerialTbsv<Uplo::Upper, Trans::NoTranspose, | ||
Diag::NonUnit, | ||
Algo::Trsv::Unblocked>::invoke(A, b, kl + ku); | ||
|
||
return 0; | ||
} | ||
}; | ||
|
||
//// Transpose //// | ||
template <> | ||
struct SerialGbtrs<Trans::Transpose, Algo::Level3::Unblocked> { | ||
template <typename AViewType, typename BViewType, typename PivViewType> | ||
KOKKOS_INLINE_FUNCTION static int invoke(const AViewType &A, | ||
const BViewType &b, | ||
const PivViewType &piv, const int kl, | ||
const int ku) { | ||
// Quick return if possible | ||
const int n = A.extent(1); | ||
if (n == 0) return 0; | ||
|
||
auto info = checkGbtrsInput(A, b, kl, ku); | ||
if (info) return info; | ||
|
||
bool lonti = kl > 0; | ||
const int kd = ku + kl + 1; | ||
|
||
// Solve U*X = b for each right hand side, overwriting B with X. | ||
[[maybe_unused]] auto info_tbsv = | ||
KokkosBatched::SerialTbsv<Uplo::Upper, Trans::Transpose, Diag::NonUnit, | ||
Algo::Tbsv::Unblocked>::invoke(A, b, kl + ku); | ||
|
||
if (lonti) { | ||
for (int j = n - 2; j >= 0; --j) { | ||
const int lm = Kokkos::min(kl, n - j - 1); | ||
|
||
// Gemv transposed | ||
auto a = Kokkos::subview(b, Kokkos::pair(j + 1, j + 1 + lm)); | ||
auto x = Kokkos::subview(A, Kokkos::pair(kd, kd + lm), j); | ||
auto y = Kokkos::subview(b, Kokkos::pair(j, j + lm)); | ||
|
||
[[maybe_unused]] auto info_gemv = | ||
KokkosBlas::Impl::SerialGemvInternal<Algo::Gemv::Unblocked>::invoke( | ||
1, a.extent(0), -1.0, a.data(), a.stride_0(), a.stride_0(), | ||
x.data(), x.stride_0(), 1.0, y.data(), y.stride_0()); | ||
|
||
// If pivot index is not j, swap rows l and j in b | ||
auto l = piv(j); | ||
if (l != j) { | ||
Kokkos::kokkos_swap(b(l), b(j)); | ||
} | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
}; | ||
} // namespace KokkosBatched | ||
|
||
#endif // KOKKOSBATCHED_GBTRS_SERIAL_IMPL_HPP_ | ||
|
||
// NOLINTEND(*) | ||
// clang-format on |
48 changes: 48 additions & 0 deletions
48
include/ddc/kernels/splines/kokkos-kernels-ext/KokkosBatched_Getrs.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (C) The DDC development team, see COPYRIGHT.md file | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
// clang-format off | ||
// NOLINTBEGIN(*) | ||
|
||
#ifndef KOKKOSBATCHED_GETRS_HPP_ | ||
#define KOKKOSBATCHED_GETRS_HPP_ | ||
|
||
#include <KokkosBatched_Util.hpp> | ||
|
||
/// \author Yuuichi Asahi (yuuichi.asahi@cea.fr) | ||
|
||
namespace KokkosBatched { | ||
|
||
/// \brief Serial Batched Getrs: | ||
/// Solve a system of linear equations | ||
/// A * x = b or A**T * x = b | ||
/// with a general N-by-N matrix A using LU factorization computed | ||
/// by Getrf. | ||
/// \tparam AViewType: Input type for the matrix, needs to be a 2D view | ||
/// \tparam PivViewType: Input type for the pivot indices, needs to be a 1D view | ||
/// \tparam BViewType: Input type for the right-hand side and the solution, | ||
/// needs to be a 1D view | ||
/// | ||
/// \param A [inout]: A is a m by n general matrix, a rank 2 view | ||
/// \param piv [out]: On exit, the pivot indices, a rank 1 view | ||
/// \param B [inout]: right-hand side and the solution, a rank 1 view | ||
/// | ||
/// No nested parallel_for is used inside of the function. | ||
/// | ||
|
||
template <typename ArgTrans, typename ArgAlgo> | ||
struct SerialGetrs { | ||
template <typename AViewType, typename PivViewType, typename BViewType> | ||
KOKKOS_INLINE_FUNCTION static int invoke(const AViewType &A, | ||
const PivViewType &piv, | ||
const BViewType &b); | ||
}; | ||
} // namespace KokkosBatched | ||
|
||
#include "KokkosBatched_Getrs_Serial_Impl.hpp" | ||
|
||
#endif // KOKKOSBATCHED_GETRS_HPP_ | ||
|
||
// NOLINTEND(*) | ||
// clang-format on |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As found in the title of this PR, we need 4.5.01 or later right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am hesitating:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
Then, relying on
4.5.1
?I would like to disallow
4.5.0
since it does not work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it a shame we cannot claim we support 4.4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I am fine either one of these
CMake
+ documentation of supported versions (4.5 is not available)CMake
(do not allow 4.5)Documentation may be updated in another PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a "known issues" section in the README.md