Skip to content

Commit

Permalink
Improve docstrings and comments to describe getrf algo
Browse files Browse the repository at this point in the history
Signed-off-by: Yuuichi Asahi <[email protected]>
  • Loading branch information
Yuuichi Asahi committed Jan 8, 2025
1 parent 5ac29aa commit 6e051b4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
22 changes: 9 additions & 13 deletions batched/dense/impl/KokkosBatched_Getrf_Serial_Internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,8 @@ KOKKOS_INLINE_FUNCTION int SerialGetrfInternalHost<Algo::Getrf::Unblocked>::invo
// Use recursive code
auto n1 = Kokkos::min(m, n) / 2;

// [ A00 ]
// Factor [ --- ]
// [ A10 ]
// Factor A0 = [[A00],
// [A10]]

// split A into two submatrices A = [A0, A1]
auto A0 = Kokkos::subview(A, Kokkos::ALL, Kokkos::pair<int, int>(0, n1));
Expand All @@ -138,9 +137,8 @@ KOKKOS_INLINE_FUNCTION int SerialGetrfInternalHost<Algo::Getrf::Unblocked>::invo

if (info == 0 && iinfo > 0) info = iinfo;

// [ A01 ]
// Apply interchanges to [ --- ]
// [ A11 ]
// Apply interchanges to A1 = [[A01],
// [A11]]

[[maybe_unused]] auto info_laswp = KokkosBatched::SerialLaswp<Direct::Forward>::invoke(ipiv0, A1);

Expand Down Expand Up @@ -202,7 +200,7 @@ KOKKOS_INLINE_FUNCTION int SerialGetrfInternalDevice<Algo::Getrf::Unblocked>::in
if (m <= 0 || n <= 0) return 0;

while (!stack.isEmpty()) {
// First of make a subview based on the current state
// Firstly, make a subview based on the current state
int current[7];
stack.pop(current);

Expand Down Expand Up @@ -280,13 +278,11 @@ KOKKOS_INLINE_FUNCTION int SerialGetrfInternalDevice<Algo::Getrf::Unblocked>::in

} else if (state == 1) {
// after first recursive call
// [ A00 ]
// Factor [ --- ]
// [ A10 ]
// Factor A0 = [[A00],
// [A10]]

// [ A01 ]
// Apply interchanges to [ --- ]
// [ A11 ]
// Apply interchanges to A1 = [[A01],
// [A11]]
KokkosBatched::SerialLaswp<Direct::Forward>::invoke(ipiv0, A1);

// Solve A00 * X = A01
Expand Down
14 changes: 14 additions & 0 deletions batched/dense/src/KokkosBatched_Getrf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ namespace KokkosBatched {
/// where P is a permutation matrix, L is lower triangular with unit
/// diagonal elements (lower trapezoidal if m > n), and U is upper
/// triangular (upper trapezoidal if m < n).
///
/// This is the recusive version of the algorithm. It divides the matrix
/// into four submatrices:
/// A = [[A00, A01],
/// [A10, A11]]
/// where A00 is a square matrix of size n0, A11 is a matrix of size n1 by n1
/// with n0 = min(m, n) / 2 and n1 = n - n0.
///
/// This function calls itself to factorize A0 = [[A00],
// [A10]]
/// do the swaps on A1 = [[A01],
/// [A11]]
/// solve A01, update A11, then calls itself to factorize A11
/// and do the swaps on A10.
/// \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
///
Expand Down

0 comments on commit 6e051b4

Please sign in to comment.