| 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_TEAM_IMPL_HPP |
| 17 |
#define KOKKOSBATCHED_TRSM_TEAM_IMPL_HPP |
| 18 |
|
| 19 |
/// \author Kyungjoo Kim ([email protected]) |
| 20 |
|
| 21 |
#include "KokkosBatched_Util.hpp" |
| 22 |
#include "KokkosBatched_Trsm_Team_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 TeamTrsm<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 TeamTrsmInternalLeftLower<Algo::Trsm::Unblocked>::invoke(member, ArgDiag::use_unit_diag, B.extent(0), |
| 42 |
B.extent(1), alpha, A.data(), A.stride_0(), |
| 43 |
A.stride_1(), B.data(), B.stride_0(), B.stride_1()); |
| 44 |
} |
| 45 |
}; |
| 46 |
|
| 47 |
template <typename MemberType, typename ArgDiag> |
| 48 |
struct TeamTrsm<MemberType, Side::Left, Uplo::Lower, Trans::NoTranspose, ArgDiag, Algo::Trsm::Blocked> { |
| 49 |
template <typename ScalarType, typename AViewType, typename BViewType> |
| 50 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 51 |
const BViewType &B) { |
| 52 |
return TeamTrsmInternalLeftLower<Algo::Trsm::Blocked>::invoke(member, ArgDiag::use_unit_diag, B.extent(0), |
| 53 |
B.extent(1), alpha, A.data(), A.stride_0(), |
| 54 |
A.stride_1(), B.data(), B.stride_0(), B.stride_1()); |
| 55 |
} |
| 56 |
}; |
| 57 |
|
| 58 |
/// |
| 59 |
/// R/U/NT |
| 60 |
/// |
| 61 |
/// B := (alpha*B) inv(triu(A)) |
| 62 |
/// A(n x n), B(m x n) |
| 63 |
|
| 64 |
template <typename MemberType, typename ArgDiag> |
| 65 |
struct TeamTrsm<MemberType, Side::Right, Uplo::Upper, Trans::NoTranspose, ArgDiag, Algo::Trsm::Unblocked> { |
| 66 |
template <typename ScalarType, typename AViewType, typename BViewType> |
| 67 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 68 |
const BViewType &B) { |
| 69 |
return TeamTrsmInternalLeftLower<Algo::Trsm::Unblocked>::invoke(member, ArgDiag::use_unit_diag, B.extent(1), |
| 70 |
B.extent(0), alpha, A.data(), A.stride_1(), |
| 71 |
A.stride_0(), B.data(), B.stride_1(), B.stride_0()); |
| 72 |
} |
| 73 |
}; |
| 74 |
|
| 75 |
template <typename MemberType, typename ArgDiag> |
| 76 |
struct TeamTrsm<MemberType, Side::Right, Uplo::Upper, Trans::NoTranspose, ArgDiag, Algo::Trsm::Blocked> { |
| 77 |
template <typename ScalarType, typename AViewType, typename BViewType> |
| 78 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 79 |
const BViewType &B) { |
| 80 |
return TeamTrsmInternalLeftLower<Algo::Trsm::Blocked>::invoke(member, ArgDiag::use_unit_diag, B.extent(1), |
| 81 |
B.extent(0), alpha, A.data(), A.stride_1(), |
| 82 |
A.stride_0(), B.data(), B.stride_1(), B.stride_0()); |
| 83 |
} |
| 84 |
}; |
| 85 |
|
| 86 |
/// |
| 87 |
/// R/L/NT |
| 88 |
/// |
| 89 |
/// B := (alpha*B) inv(tril(A)) |
| 90 |
/// A(n x n), B(m x n) |
| 91 |
|
| 92 |
template <typename MemberType, typename ArgDiag> |
| 93 |
struct TeamTrsm<MemberType, Side::Right, Uplo::Lower, Trans::NoTranspose, ArgDiag, Algo::Trsm::Unblocked> { |
| 94 |
template <typename ScalarType, typename AViewType, typename BViewType> |
| 95 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 96 |
const BViewType &B) { |
| 97 |
return TeamTrsmInternalLeftUpper<Algo::Trsm::Unblocked>::invoke(member, ArgDiag::use_unit_diag, B.extent(1), |
| 98 |
B.extent(0), alpha, A.data(), A.stride_1(), |
| 99 |
A.stride_0(), B.data(), B.stride_1(), B.stride_0()); |
| 100 |
} |
| 101 |
}; |
| 102 |
|
| 103 |
template <typename MemberType, typename ArgDiag> |
| 104 |
struct TeamTrsm<MemberType, Side::Right, Uplo::Lower, Trans::NoTranspose, ArgDiag, Algo::Trsm::Blocked> { |
| 105 |
template <typename ScalarType, typename AViewType, typename BViewType> |
| 106 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 107 |
const BViewType &B) { |
| 108 |
return TeamTrsmInternalLeftUpper<Algo::Trsm::Blocked>::invoke(member, ArgDiag::use_unit_diag, B.extent(1), |
| 109 |
B.extent(0), alpha, A.data(), A.stride_1(), |
| 110 |
A.stride_0(), B.data(), B.stride_1(), B.stride_0()); |
| 111 |
} |
| 112 |
}; |
| 113 |
|
| 114 |
/// |
| 115 |
/// R/U/T |
| 116 |
/// |
| 117 |
/// B := (alpha*B) inv(triu(A)) |
| 118 |
/// A(n x n), B(m x n) |
| 119 |
|
| 120 |
template <typename MemberType, typename ArgDiag> |
| 121 |
struct TeamTrsm<MemberType, Side::Right, Uplo::Upper, Trans::Transpose, ArgDiag, Algo::Trsm::Unblocked> { |
| 122 |
template <typename ScalarType, typename AViewType, typename BViewType> |
| 123 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 124 |
const BViewType &B) { |
| 125 |
return TeamTrsmInternalLeftUpper<Algo::Trsm::Unblocked>::invoke(member, ArgDiag::use_unit_diag, B.extent(1), |
| 126 |
B.extent(0), alpha, A.data(), A.stride_0(), |
| 127 |
A.stride_1(), B.data(), B.stride_1(), B.stride_0()); |
| 128 |
} |
| 129 |
}; |
| 130 |
|
| 131 |
template <typename MemberType, typename ArgDiag> |
| 132 |
struct TeamTrsm<MemberType, Side::Right, Uplo::Upper, Trans::Transpose, ArgDiag, Algo::Trsm::Blocked> { |
| 133 |
template <typename ScalarType, typename AViewType, typename BViewType> |
| 134 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 135 |
const BViewType &B) { |
| 136 |
return TeamTrsmInternalLeftUpper<Algo::Trsm::Blocked>::invoke(member, ArgDiag::use_unit_diag, B.extent(1), |
| 137 |
B.extent(0), alpha, A.data(), A.stride_0(), |
| 138 |
A.stride_1(), B.data(), B.stride_1(), B.stride_0()); |
| 139 |
} |
| 140 |
}; |
| 141 |
|
| 142 |
/// |
| 143 |
/// L/U/NT |
| 144 |
/// |
| 145 |
/// B := inv(triu(A)) (alpha*B) |
| 146 |
/// A(m x m), B(m x n) |
| 147 |
|
| 148 |
template <typename MemberType, typename ArgDiag> |
| 149 |
struct TeamTrsm<MemberType, Side::Left, Uplo::Upper, Trans::NoTranspose, ArgDiag, Algo::Trsm::Unblocked> { |
| 150 |
template <typename ScalarType, typename AViewType, typename BViewType> |
| 151 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 152 |
const BViewType &B) { |
| 153 |
return TeamTrsmInternalLeftUpper<Algo::Trsm::Unblocked>::invoke(member, ArgDiag::use_unit_diag, B.extent(0), |
| 154 |
B.extent(1), alpha, A.data(), A.stride_0(), |
| 155 |
A.stride_1(), B.data(), B.stride_0(), B.stride_1()); |
| 156 |
} |
| 157 |
}; |
| 158 |
|
| 159 |
template <typename MemberType, typename ArgDiag> |
| 160 |
struct TeamTrsm<MemberType, Side::Left, Uplo::Upper, Trans::NoTranspose, ArgDiag, Algo::Trsm::Blocked> { |
| 161 |
template <typename ScalarType, typename AViewType, typename BViewType> |
| 162 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 163 |
const BViewType &B) { |
| 164 |
return TeamTrsmInternalLeftUpper<Algo::Trsm::Blocked>::invoke(member, ArgDiag::use_unit_diag, B.extent(0), |
| 165 |
B.extent(1), alpha, A.data(), A.stride_0(), |
| 166 |
A.stride_1(), B.data(), B.stride_0(), B.stride_1()); |
| 167 |
} |
| 168 |
}; |
| 169 |
|
| 170 |
/// |
| 171 |
/// L/L/T |
| 172 |
/// |
| 173 |
/// B := inv(tril(AT)) (alpha*B) |
| 174 |
/// A(m x m), B(m x n) |
| 175 |
|
| 176 |
template <typename MemberType, typename ArgDiag> |
| 177 |
struct TeamTrsm<MemberType, Side::Left, Uplo::Lower, Trans::Transpose, ArgDiag, Algo::Trsm::Unblocked> { |
| 178 |
template <typename ScalarType, typename AViewType, typename BViewType> |
| 179 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 180 |
const BViewType &B) { |
| 181 |
return TeamTrsmInternalLeftUpper<Algo::Trsm::Unblocked>::invoke(member, ArgDiag::use_unit_diag, B.extent(0), |
| 182 |
B.extent(1), alpha, A.data(), A.stride_1(), |
| 183 |
A.stride_0(), B.data(), B.stride_0(), B.stride_1()); |
| 184 |
} |
| 185 |
}; |
| 186 |
|
| 187 |
template <typename MemberType, typename ArgDiag> |
| 188 |
struct TeamTrsm<MemberType, Side::Left, Uplo::Lower, Trans::Transpose, ArgDiag, Algo::Trsm::Blocked> { |
| 189 |
template <typename ScalarType, typename AViewType, typename BViewType> |
| 190 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 191 |
const BViewType &B) { |
| 192 |
return TeamTrsmInternalLeftUpper<Algo::Trsm::Blocked>::invoke(member, ArgDiag::use_unit_diag, B.extent(0), |
| 193 |
B.extent(1), alpha, A.data(), A.stride_1(), |
| 194 |
A.stride_0(), B.data(), B.stride_0(), B.stride_1()); |
| 195 |
} |
| 196 |
}; |
| 197 |
|
| 198 |
/// |
| 199 |
/// L/U/T |
| 200 |
/// |
| 201 |
/// B := inv(triu(AT)) (alpha*B) |
| 202 |
/// A(m x m), B(m x n) |
| 203 |
|
| 204 |
template <typename MemberType, typename ArgDiag> |
| 205 |
struct TeamTrsm<MemberType, Side::Left, Uplo::Upper, Trans::Transpose, ArgDiag, Algo::Trsm::Unblocked> { |
| 206 |
template <typename ScalarType, typename AViewType, typename BViewType> |
| 207 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 208 |
const BViewType &B) { |
| 209 |
return TeamTrsmInternalLeftLower<Algo::Trsm::Unblocked>::invoke(member, ArgDiag::use_unit_diag, B.extent(0), |
| 210 |
B.extent(1), alpha, A.data(), A.stride_1(), |
| 211 |
A.stride_0(), B.data(), B.stride_0(), B.stride_1()); |
| 212 |
} |
| 213 |
}; |
| 214 |
|
| 215 |
template <typename MemberType, typename ArgDiag> |
| 216 |
struct TeamTrsm<MemberType, Side::Left, Uplo::Upper, Trans::Transpose, ArgDiag, Algo::Trsm::Blocked> { |
| 217 |
template <typename ScalarType, typename AViewType, typename BViewType> |
| 218 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 219 |
const BViewType &B) { |
| 220 |
return TeamTrsmInternalLeftLower<Algo::Trsm::Blocked>::invoke(member, ArgDiag::use_unit_diag, B.extent(0), |
| 221 |
B.extent(1), alpha, A.data(), A.stride_1(), |
| 222 |
A.stride_0(), B.data(), B.stride_0(), B.stride_1()); |
| 223 |
} |
| 224 |
}; |
| 225 |
|
| 226 |
} // namespace KokkosBatched |
| 227 |
|
| 228 |
#endif |