| 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_TRSM_TEAMVECTOR_IMPL_HPP |
| 17 |
#define KOKKOSBATCHED_TRSM_TEAMVECTOR_IMPL_HPP |
| 18 |
|
| 19 |
/// \author Kyungjoo Kim ([email protected]) |
| 20 |
|
| 21 |
#include "KokkosBatched_Util.hpp" |
| 22 |
#include "KokkosBatched_Trsm_TeamVector_Internal.hpp" |
| 23 |
|
| 24 |
namespace KokkosBatched { |
| 25 |
|
| 26 |
/// |
| 27 |
/// Team Impl |
| 28 |
/// ========= |
| 29 |
|
| 30 |
/// |
| 31 |
/// L/L/NT |
| 32 |
/// |
| 33 |
/// B := inv(tril(A)) (alpha*B) |
| 34 |
/// A(m x m), B(m x n) |
| 35 |
|
| 36 |
template <typename MemberType, typename ArgDiag> |
| 37 |
struct TeamVectorTrsm<MemberType, Side::Left, Uplo::Lower, Trans::NoTranspose, ArgDiag, Algo::Trsm::Unblocked> { |
| 38 |
template <typename ScalarType, typename AViewType, typename BViewType> |
| 39 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 40 |
const BViewType &B) { |
| 41 |
return TeamVectorTrsmInternalLeftLower<Algo::Trsm::Unblocked>::invoke( |
| 42 |
member, ArgDiag::use_unit_diag, B.extent(0), B.extent(1), alpha, A.data(), A.stride_0(), A.stride_1(), B.data(), |
| 43 |
B.stride_0(), B.stride_1()); |
| 44 |
} |
| 45 |
}; |
| 46 |
|
| 47 |
/// |
| 48 |
/// R/U/NT |
| 49 |
/// |
| 50 |
/// B := (alpha*B) inv(triu(A)) |
| 51 |
/// A(n x n), B(m x n) |
| 52 |
|
| 53 |
template <typename MemberType, typename ArgDiag> |
| 54 |
struct TeamVectorTrsm<MemberType, Side::Right, Uplo::Upper, Trans::NoTranspose, ArgDiag, Algo::Trsm::Unblocked> { |
| 55 |
template <typename ScalarType, typename AViewType, typename BViewType> |
| 56 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 57 |
const BViewType &B) { |
| 58 |
return TeamVectorTrsmInternalLeftLower<Algo::Trsm::Unblocked>::invoke( |
| 59 |
member, ArgDiag::use_unit_diag, B.extent(1), B.extent(0), alpha, A.data(), A.stride_1(), A.stride_0(), B.data(), |
| 60 |
B.stride_1(), B.stride_0()); |
| 61 |
} |
| 62 |
}; |
| 63 |
|
| 64 |
/// |
| 65 |
/// L/U/NT |
| 66 |
/// |
| 67 |
/// B := inv(triu(A)) (alpha*B) |
| 68 |
/// A(m x m), B(m x n) |
| 69 |
|
| 70 |
template <typename MemberType, typename ArgDiag> |
| 71 |
struct TeamVectorTrsm<MemberType, Side::Left, Uplo::Upper, Trans::NoTranspose, ArgDiag, Algo::Trsm::Unblocked> { |
| 72 |
template <typename ScalarType, typename AViewType, typename BViewType> |
| 73 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 74 |
const BViewType &B) { |
| 75 |
return TeamVectorTrsmInternalLeftUpper<Algo::Trsm::Unblocked>::invoke( |
| 76 |
member, ArgDiag::use_unit_diag, B.extent(0), B.extent(1), alpha, A.data(), A.stride_0(), A.stride_1(), B.data(), |
| 77 |
B.stride_0(), B.stride_1()); |
| 78 |
} |
| 79 |
}; |
| 80 |
|
| 81 |
/// |
| 82 |
/// L/L/T |
| 83 |
/// |
| 84 |
/// B := inv(tril(AT)) (alpha*B) |
| 85 |
/// A(m x m), B(m x n) |
| 86 |
|
| 87 |
template <typename MemberType, typename ArgDiag> |
| 88 |
struct TeamVectorTrsm<MemberType, Side::Left, Uplo::Lower, Trans::Transpose, ArgDiag, Algo::Trsm::Unblocked> { |
| 89 |
template <typename ScalarType, typename AViewType, typename BViewType> |
| 90 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 91 |
const BViewType &B) { |
| 92 |
return TeamVectorTrsmInternalLeftUpper<Algo::Trsm::Unblocked>::invoke( |
| 93 |
member, ArgDiag::use_unit_diag, B.extent(0), B.extent(1), alpha, A.data(), A.stride_1(), A.stride_0(), B.data(), |
| 94 |
B.stride_0(), B.stride_1()); |
| 95 |
} |
| 96 |
}; |
| 97 |
|
| 98 |
/// |
| 99 |
/// L/U/T |
| 100 |
/// |
| 101 |
/// B := inv(triu(AT)) (alpha*B) |
| 102 |
/// A(m x m), B(m x n) |
| 103 |
|
| 104 |
template <typename MemberType, typename ArgDiag> |
| 105 |
struct TeamVectorTrsm<MemberType, Side::Left, Uplo::Upper, Trans::Transpose, ArgDiag, Algo::Trsm::Unblocked> { |
| 106 |
template <typename ScalarType, typename AViewType, typename BViewType> |
| 107 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 108 |
const BViewType &B) { |
| 109 |
return TeamVectorTrsmInternalLeftLower<Algo::Trsm::Unblocked>::invoke( |
| 110 |
member, ArgDiag::use_unit_diag, B.extent(0), B.extent(1), alpha, A.data(), A.stride_1(), A.stride_0(), B.data(), |
| 111 |
B.stride_0(), B.stride_1()); |
| 112 |
} |
| 113 |
}; |
| 114 |
|
| 115 |
} // namespace KokkosBatched |
| 116 |
|
| 117 |
#endif |