| 1 |
//@HEADER |
| 2 |
// ************************************************************************ |
| 3 |
// |
| 4 |
// Kokkos v. 4.0 |
| 5 |
// Copyright (2022) National Technology & Engineering |
| 6 |
// Solutions of Sandia, LLC (NTESS). |
| 7 |
// |
| 8 |
// Under the terms of Contract DE-NA0003525 with NTESS, |
| 9 |
// the U.S. Government retains certain rights in this software. |
| 10 |
// |
| 11 |
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. |
| 12 |
// See https://kokkos.org/LICENSE for license information. |
| 13 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 14 |
// |
| 15 |
//@HEADER |
| 16 |
#ifndef KOKKOSBATCHED_INVERSELU_DECL_HPP |
| 17 |
#define KOKKOSBATCHED_INVERSELU_DECL_HPP |
| 18 |
|
| 19 |
/// \author Vinh Dang ([email protected]) |
| 20 |
|
| 21 |
#include "KokkosBatched_Vector.hpp" |
| 22 |
#include "KokkosBatched_Copy_Decl.hpp" |
| 23 |
#include "KokkosBatched_Copy_Impl.hpp" |
| 24 |
#include "KokkosBatched_SetIdentity_Decl.hpp" |
| 25 |
#include "KokkosBatched_SetIdentity_Impl.hpp" |
| 26 |
#include "KokkosBatched_SolveLU_Decl.hpp" |
| 27 |
|
| 28 |
namespace KokkosBatched { |
| 29 |
|
| 30 |
template <typename ArgAlgo> |
| 31 |
struct SerialInverseLU { |
| 32 |
template <typename AViewType, typename wViewType> |
| 33 |
KOKKOS_INLINE_FUNCTION static int invoke(const AViewType &A, const wViewType &w) { |
| 34 |
typedef typename wViewType::value_type value_type; |
| 35 |
// workspace w is always 1D view; reinterpret it |
| 36 |
Kokkos::View<value_type **, Kokkos::LayoutRight, Kokkos::AnonymousSpace> W(w.data(), A.extent(0), A.extent(1)); |
| 37 |
|
| 38 |
int r_val[3] = {}; |
| 39 |
r_val[0] = SerialCopy<Trans::NoTranspose>::invoke(A, W); |
| 40 |
r_val[1] = SerialSetIdentity::invoke(A); |
| 41 |
r_val[2] = SerialSolveLU<Trans::NoTranspose, ArgAlgo>::invoke(W, A); |
| 42 |
return r_val[0] + r_val[1] + r_val[2]; |
| 43 |
} |
| 44 |
}; |
| 45 |
|
| 46 |
template <typename MemberType, typename ArgAlgo> |
| 47 |
struct TeamInverseLU { |
| 48 |
template <typename AViewType, typename wViewType> |
| 49 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const AViewType &A, const wViewType &w) { |
| 50 |
typedef typename wViewType::value_type value_type; |
| 51 |
// workspace w is always 1D view; reinterpret it |
| 52 |
Kokkos::View<value_type **, Kokkos::LayoutRight, Kokkos::AnonymousSpace> W(w.data(), A.extent(0), A.extent(1)); |
| 53 |
|
| 54 |
int r_val[3] = {}; |
| 55 |
r_val[0] = TeamCopy<MemberType, Trans::NoTranspose>::invoke(member, A, W); |
| 56 |
r_val[1] = TeamSetIdentity<MemberType>::invoke(member, A); |
| 57 |
r_val[2] = TeamSolveLU<MemberType, Trans::NoTranspose, ArgAlgo>::invoke(member, W, A); |
| 58 |
return r_val[0] + r_val[1] + r_val[2]; |
| 59 |
} |
| 60 |
}; |
| 61 |
|
| 62 |
} // namespace KokkosBatched |
| 63 |
|
| 64 |
#endif |