Debian Codegraph @

packages/kokkos-kernels/batched/dense/impl/KokkosBatched_Pbtrf_Serial_Impl.hpp

raw
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_PBTRF_SERIAL_IMPL_HPP_
17 #define KOKKOSBATCHED_PBTRF_SERIAL_IMPL_HPP_
18
19 #include <KokkosBatched_Util.hpp>
20 #include "KokkosBatched_Pbtrf_Serial_Internal.hpp"
21
22 /// \author Yuuichi Asahi ([email protected])
23
24 namespace KokkosBatched {
25
26 template <typename ABViewType>
27 KOKKOS_INLINE_FUNCTION static int checkPbtrfInput([[maybe_unused]] const ABViewType &Ab) {
28 static_assert(Kokkos::is_view_v<ABViewType>, "KokkosBatched::pbtrf: ABViewType is not a Kokkos::View.");
29 static_assert(ABViewType::rank == 2, "KokkosBatched::pbtrf: ABViewType must have rank 2.");
30
31 #if (KOKKOSKERNELS_DEBUG_LEVEL > 0)
32 const int kd = Ab.extent(0) - 1;
33 if (kd < 0) {
34 Kokkos::printf(
35 "KokkosBatched::pbtrf: input parameter kd must not be less than 0: kd "
36 "= "
37 "%d\n",
38 kd);
39 return 1;
40 }
41 #endif
42 return 0;
43 }
44
45 //// Lower ////
46 template <>
47 struct SerialPbtrf<Uplo::Lower, Algo::Pbtrf::Unblocked> {
48 template <typename ABViewType>
49 KOKKOS_INLINE_FUNCTION static int invoke(const ABViewType &Ab) {
50 // Quick return if possible
51 const int n = Ab.extent(1);
52 if (n == 0) return 0;
53
54 auto info = checkPbtrfInput(Ab);
55 if (info) return info;
56
57 const int kd = Ab.extent(0) - 1;
58 return SerialPbtrfInternalLower<Algo::Pbtrf::Unblocked>::invoke(n, Ab.data(), Ab.stride_0(), Ab.stride_1(), kd);
59 }
60 };
61
62 //// Upper ////
63 template <>
64 struct SerialPbtrf<Uplo::Upper, Algo::Pbtrf::Unblocked> {
65 template <typename ABViewType>
66 KOKKOS_INLINE_FUNCTION static int invoke(const ABViewType &Ab) {
67 // Quick return if possible
68 const int n = Ab.extent(1);
69 if (n == 0) return 0;
70
71 auto info = checkPbtrfInput(Ab);
72 if (info) return info;
73
74 const int kd = Ab.extent(0) - 1;
75 return SerialPbtrfInternalUpper<Algo::Pbtrf::Unblocked>::invoke(n, Ab.data(), Ab.stride_0(), Ab.stride_1(), kd);
76 }
77 };
78
79 } // namespace KokkosBatched
80
81 #endif // KOKKOSBATCHED_PBTRF_SERIAL_IMPL_HPP_