Skip to content

Commit

Permalink
batched - dense: Testing and fixing Serial QR
Browse files Browse the repository at this point in the history
The serial QR algorithms does not have unit-tests and is failing
for non square matrices. See issue kokkos#2328.
This first commit fixes the issue with rectangular matrices and
adds a basic test for that use case. Next will work on adding a
test that exercises the interfaces on multiple matrices of different
sizes within a parallel_for. Finally equivalent tests will be added
for the square case as well.
Fixing unused variable error
It looks like the Left NoTranspose ApplyQ is not doing the correct
thing. Will have a look at that next.

Signed-off-by: Luc <[email protected]>
  • Loading branch information
lucbv committed Dec 4, 2024
1 parent 9121db7 commit 7a30712
Show file tree
Hide file tree
Showing 4 changed files with 418 additions and 6 deletions.
14 changes: 9 additions & 5 deletions batched/dense/impl/KokkosBatched_QR_FormQ_Serial_Internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ struct SerialQR_FormQ_Internal {
/// B is m x m

// set identity
if (is_Q_zero)
SerialSetInternal::invoke(m, value_type(1), Q, qs0 + qs1);
else
SerialSetIdentityInternal::invoke(m, Q, qs0, qs1);
if (is_Q_zero) {
for (int idx = 0; idx < m; ++idx) {
Q[(qs0 + qs1) * idx] = value_type(1);
// SerialSetInternal::invoke(m, value_type(1), Q, qs0 + qs1);
}
} else {
SerialSetIdentityInternal::invoke(m, m, Q, qs0, qs1);
}

return SerialApplyQ_LeftNoTransForwardInternal ::invoke(m, m, k, A, as0, as1, t, ts, Q, qs0, qs1, w);
return SerialApplyQ_LeftForwardInternal::invoke(m, m, k, A, as0, as1, t, ts, Q, qs0, qs1, w);
}
};

Expand Down
2 changes: 1 addition & 1 deletion batched/dense/impl/KokkosBatched_QR_Serial_Internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct SerialQR_Internal {
A_part2x2.partWithATL(A, m, n, 0, 0);
t_part2x1.partWithAT(t, m, 0);

for (int m_atl = 0; m_atl < m; ++m_atl) {
for (int m_atl = 0; m_atl < Kokkos::min(m, n); ++m_atl) {
// part 2x2 into 3x3
A_part3x3.partWithABR(A_part2x2, 1, 1);
const int m_A22 = m - m_atl - 1;
Expand Down
1 change: 1 addition & 0 deletions batched/dense/unit_test/Test_Batched_Dense.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "Test_Batched_SerialLU.hpp"
#include "Test_Batched_SerialLU_Real.hpp"
#include "Test_Batched_SerialLU_Complex.hpp"
#include "Test_Batched_SerialQR.hpp"
#include "Test_Batched_SerialSolveLU.hpp"
#include "Test_Batched_SerialSolveLU_Real.hpp"
#include "Test_Batched_SerialSolveLU_Complex.hpp"
Expand Down
Loading

0 comments on commit 7a30712

Please sign in to comment.