| 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_GEMM_DECL_HPP |
| 17 |
#define KOKKOSBATCHED_GEMM_DECL_HPP |
| 18 |
|
| 19 |
#include "KokkosBatched_Vector.hpp" |
| 20 |
|
| 21 |
namespace KokkosBatched { |
| 22 |
/// |
| 23 |
/// Serial Gemm |
| 24 |
/// |
| 25 |
|
| 26 |
template <typename ArgTransA, typename ArgTransB, typename ArgAlgo> |
| 27 |
struct SerialGemm { |
| 28 |
template <typename ScalarType, typename AViewType, typename BViewType, typename CViewType> |
| 29 |
KOKKOS_INLINE_FUNCTION static int invoke(const ScalarType alpha, const AViewType &A, const BViewType &B, |
| 30 |
const ScalarType beta, const CViewType &C); |
| 31 |
}; |
| 32 |
|
| 33 |
/// |
| 34 |
/// Team Gemm |
| 35 |
/// |
| 36 |
|
| 37 |
template <typename MemberType, typename ArgTransA, typename ArgTransB, typename ArgAlgo> |
| 38 |
struct TeamGemm { |
| 39 |
template <typename ScalarType, typename AViewType, typename BViewType, typename CViewType> |
| 40 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 41 |
const BViewType &B, const ScalarType beta, const CViewType &C); |
| 42 |
}; |
| 43 |
|
| 44 |
/// |
| 45 |
/// TeamVector Gemm |
| 46 |
/// |
| 47 |
|
| 48 |
template <typename MemberType, typename ArgTransA, typename ArgTransB, typename ArgAlgo> |
| 49 |
struct TeamVectorGemm { |
| 50 |
template <typename ScalarType, typename AViewType, typename BViewType, typename CViewType> |
| 51 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 52 |
const BViewType &B, const ScalarType beta, const CViewType &C); |
| 53 |
}; |
| 54 |
|
| 55 |
/// |
| 56 |
/// Selective Interface |
| 57 |
/// |
| 58 |
template <typename MemberType, typename ArgTransA, typename ArgTransB, typename ArgMode, typename ArgAlgo> |
| 59 |
struct Gemm { |
| 60 |
template <typename ScalarType, typename AViewType, typename BViewType, typename CViewType> |
| 61 |
KOKKOS_FORCEINLINE_FUNCTION static int invoke(const MemberType &member, const ScalarType alpha, const AViewType &A, |
| 62 |
const BViewType &B, const ScalarType beta, const CViewType &C) { |
| 63 |
int r_val = 0; |
| 64 |
if (std::is_same<ArgMode, Mode::Serial>::value) { |
| 65 |
r_val = SerialGemm<ArgTransA, ArgTransB, ArgAlgo>::invoke(alpha, A, B, beta, C); |
| 66 |
} else if (std::is_same<ArgMode, Mode::Team>::value) { |
| 67 |
r_val = TeamGemm<MemberType, ArgTransA, ArgTransB, ArgAlgo>::invoke(member, alpha, A, B, beta, C); |
| 68 |
} |
| 69 |
return r_val; |
| 70 |
} |
| 71 |
}; |
| 72 |
} // namespace KokkosBatched |
| 73 |
|
| 74 |
#include "KokkosBatched_Gemm_Serial_Impl.hpp" |
| 75 |
#include "KokkosBatched_Gemm_Team_Impl.hpp" |
| 76 |
#include "KokkosBatched_Gemm_TeamVector_Impl.hpp" |
| 77 |
|
| 78 |
#endif // KOKKOSBATCHED_GEMM_DECL_HPP |