Skip to content

Commit

Permalink
Lapack: gesv unit-test guard MAGMA specific cases
Browse files Browse the repository at this point in the history
Instead of running MAGMA specific tests by default we know have
generic tests by default for rocSOLVER and LAPACK and we only run
the specific MAGMA tests when we detect that the library is
available.
  • Loading branch information
lucbv committed Nov 13, 2023
1 parent e9badc0 commit 48d62ee
Showing 1 changed file with 60 additions and 76 deletions.
136 changes: 60 additions & 76 deletions lapack/unit_test/Test_Lapack_gesv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

namespace Test {

template <class ViewTypeA, class ViewTypeB, class Device>
template <class ViewTypeA, class ViewTypeB, class Device, bool MAGAMA>
void impl_test_gesv(const char* mode, const char* padding, int N) {
using execution_space = typename Device::execution_space;
using ScalarA = typename ViewTypeA::value_type;
Expand Down Expand Up @@ -84,7 +84,9 @@ void impl_test_gesv(const char* mode, const char* padding, int N) {
Kokkos::deep_copy(h_X0, X0);

// Allocate IPIV view on host
typedef Kokkos::View<int*, Kokkos::LayoutLeft, execution_space> ViewTypeP;
using ViewTypeP = std::conditional<MAGMA,
Kokkos::View<int*, Kokkos::LayoutLeft, Kokkos::HostSpace>,
Kokkos::View<int*, Kokkos::LayoutLeft, execution_space>>::type;
ViewTypeP ipiv;
int Nt = 0;
if (mode[0] == 'Y') {
Expand Down Expand Up @@ -191,7 +193,9 @@ void impl_test_gesv_mrhs(const char* mode, const char* padding, int N,
Kokkos::deep_copy(h_X0, X0);

// Allocate IPIV view on host
typedef Kokkos::View<int*, Kokkos::LayoutLeft, execution_space> ViewTypeP;
using ViewTypeP = std::conditional<MAGMA,
Kokkos::View<int*, Kokkos::LayoutLeft, Kokkos::HostSpace>,
Kokkos::View<int*, Kokkos::LayoutLeft, execution_space>>::type;
ViewTypeP ipiv;
int Nt = 0;
if (mode[0] == 'Y') {
Expand Down Expand Up @@ -259,53 +263,41 @@ int test_gesv(const char* mode) {
#if defined(KOKKOSKERNELS_INST_LAYOUTLEFT) || \
(!defined(KOKKOSKERNELS_ETI_ONLY) && \
!defined(KOKKOSKERNELS_IMPL_CHECK_ETI_CALLS))
typedef Kokkos::View<Scalar**, Kokkos::LayoutLeft, Device> view_type_a_ll;
typedef Kokkos::View<Scalar*, Kokkos::LayoutLeft, Device> view_type_b_ll;
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device>(
using view_type_a_ll = Kokkos::View<Scalar**, Kokkos::LayoutLeft, Device>;
using view_type_b_ll = Kokkos::View<Scalar*, Kokkos::LayoutLeft, Device>;

Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device, false>(
&mode[0], "N", 2); // no padding
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device>(
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device, false>(
&mode[0], "N", 13); // no padding
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device>(
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device, false>(
&mode[0], "N", 179); // no padding
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device>(
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device, false>(
&mode[0], "N", 64); // no padding
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device>(
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device, false>(
&mode[0], "N", 1024); // no padding
#if defined(KOKKOS_ENABLE_HIP)
if constexpr (!std::is_same_v<typename Device::execution_space,
Kokkos::HIP>) {
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device>(
&mode[0], "Y",
13); // padding
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device>(
&mode[0], "Y",
179); // padding

#if defined(KOKKOSKERNELS_ENABLE_TPL_MAGMA) && defined(KOKKOS_ENABLE_CUDA)
if constexpr (std::is_same_v<Kokkos::Cuda, typename Device::execution_space>) {
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device, true>(
&mode[0], "N", 2); // no padding
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device, true>(
&mode[0], "N", 13); // no padding
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device, true>(
&mode[0], "N", 179); // no padding
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device, true>(
&mode[0], "N", 64); // no padding
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device, true>(
&mode[0], "N", 1024); // no padding

Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device, true>(&mode[0], "Y",
13); // padding
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device, true>(&mode[0], "Y",
179); // padding
}
#else
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device>(&mode[0], "Y",
13); // padding
Test::impl_test_gesv<view_type_a_ll, view_type_b_ll, Device>(&mode[0], "Y",
179); // padding
#endif
#endif

/*
#if defined(KOKKOSKERNELS_INST_LAYOUTRIGHT) ||
(!defined(KOKKOSKERNELS_ETI_ONLY) &&
!defined(KOKKOSKERNELS_IMPL_CHECK_ETI_CALLS)) typedef Kokkos::View<ScalarA**,
Kokkos::LayoutRight, Device> view_type_a_lr; typedef Kokkos::View<ScalarB*,
Kokkos::LayoutRight, Device> view_type_b_lr;
Test::impl_test_gesv<view_type_a_lr, view_type_b_lr, Device>(&mode[0], "N",
2); //no padding Test::impl_test_gesv<view_type_a_lr, view_type_b_lr,
Device>(&mode[0], "N", 13); //no padding Test::impl_test_gesv<view_type_a_lr,
view_type_b_lr, Device>(&mode[0], "N", 179); //no padding
Test::impl_test_gesv<view_type_a_lr, view_type_b_lr, Device>(&mode[0], "N",
64); //no padding Test::impl_test_gesv<view_type_a_lr, view_type_b_lr,
Device>(&mode[0], "N", 1024);//no padding Test::impl_test_gesv<view_type_a_lr,
view_type_b_lr, Device>(&mode[0], "Y", 13); //padding
Test::impl_test_gesv<view_type_a_lr, view_type_b_lr, Device>(&mode[0], "Y",
179); //padding #endif
*/
// Supress unused parameters on CUDA10
(void)mode;
return 1;
Expand All @@ -316,57 +308,49 @@ int test_gesv_mrhs(const char* mode) {
#if defined(KOKKOSKERNELS_INST_LAYOUTLEFT) || \
(!defined(KOKKOSKERNELS_ETI_ONLY) && \
!defined(KOKKOSKERNELS_IMPL_CHECK_ETI_CALLS))
typedef Kokkos::View<Scalar**, Kokkos::LayoutLeft, Device> view_type_a_ll;
typedef Kokkos::View<Scalar**, Kokkos::LayoutLeft, Device> view_type_b_ll;
Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device>(
using view_type_a_ll = Kokkos::View<Scalar**, Kokkos::LayoutLeft, Device>;
using view_type_b_ll = Kokkos::View<Scalar**, Kokkos::LayoutLeft, Device>;

Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device, false>(
&mode[0], "N", 2, 5); // no padding
Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device>(
Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device, false>(
&mode[0], "N", 13, 5); // no padding
Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device>(
Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device, false>(
&mode[0], "N", 179, 5); // no padding
Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device>(
Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device, false>(
&mode[0], "N", 64, 5); // no padding
Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device>(
Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device, false>(
&mode[0], "N", 1024, 5); // no padding
#if defined(KOKKOS_ENABLE_HIP)
if constexpr (!std::is_same_v<typename Device::execution_space,
Kokkos::HIP>) {
Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device>(

// When appropriate run MAGMA specific tests
#if defined(KOKKOSKERNELS_ENABLE_TPL_MAGMA) && defined(KOKKOS_ENABLE_CUDA)
if constexpr (std::is_same_v<Kokkos::Cuda, typename Device::execution_space>) {

Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device, true>(
&mode[0], "N", 2, 5); // no padding
Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device, true>(
&mode[0], "N", 13, 5); // no padding
Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device, true>(
&mode[0], "N", 179, 5); // no padding
Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device, true>(
&mode[0], "N", 64, 5); // no padding
Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device, true>(
&mode[0], "N", 1024, 5); // no padding

Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device, true>(
&mode[0], "Y", 13, 5); // padding
Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device>(
Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device, true>(
&mode[0], "Y", 179, 5); // padding
}
#else
Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device>(
&mode[0], "Y", 13, 5); // padding
Test::impl_test_gesv_mrhs<view_type_a_ll, view_type_b_ll, Device>(
&mode[0], "Y", 179, 5); // padding
#endif
#endif

/*
#if defined(KOKKOSKERNELS_INST_LAYOUTRIGHT) ||
(!defined(KOKKOSKERNELS_ETI_ONLY) &&
!defined(KOKKOSKERNELS_IMPL_CHECK_ETI_CALLS)) typedef Kokkos::View<ScalarA**,
Kokkos::LayoutRight, Device> view_type_a_lr; typedef Kokkos::View<ScalarB**,
Kokkos::LayoutRight, Device> view_type_b_lr;
Test::impl_test_gesv_mrhs<view_type_a_lr, view_type_b_lr, Device>(&mode[0],
"N", 2, 5);//no padding Test::impl_test_gesv_mrhs<view_type_a_lr,
view_type_b_lr, Device>(&mode[0], "N", 13, 5);//no padding
Test::impl_test_gesv_mrhs<view_type_a_lr, view_type_b_lr, Device>(&mode[0],
"N", 179, 5);//no padding Test::impl_test_gesv_mrhs<view_type_a_lr,
view_type_b_lr, Device>(&mode[0], "N", 64, 5);//no padding
Test::impl_test_gesv_mrhs<view_type_a_lr, view_type_b_lr, Device>(&mode[0],
"N", 1024,5);//no padding Test::impl_test_gesv_mrhs<view_type_a_lr,
view_type_b_lr, Device>(&mode[0], "Y", 13, 5);//padding
Test::impl_test_gesv_mrhs<view_type_a_lr, view_type_b_lr, Device>(&mode[0],
"Y", 179, 5);//padding #endif
*/
// Supress unused parameters on CUDA10
(void)mode;
return 1;
}


#if defined(KOKKOSKERNELS_INST_FLOAT) || \
(!defined(KOKKOSKERNELS_ETI_ONLY) && \
!defined(KOKKOSKERNELS_IMPL_CHECK_ETI_CALLS))
Expand Down

0 comments on commit 48d62ee

Please sign in to comment.