Debian Codegraph @

packages/kokkos-kernels/batched/dense/impl/KokkosBatched_InnerGemmFixC_Team_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_INNER_GEMM_FIX_C_TEAM_IMPL_HPP
17 #define KOKKOSBATCHED_INNER_GEMM_FIX_C_TEAM_IMPL_HPP
18
19 /// \author Kyungjoo Kim ([email protected])
20
21 #include "KokkosBatched_Util.hpp"
22 #include "KokkosBatched_InnerGemmFixC_Decl.hpp"
23
24 namespace KokkosBatched {
25
26 template <int mb, int nb>
27 template <typename MemberType, typename ScalarType, typename ValueType>
28 KOKKOS_INLINE_FUNCTION int InnerGemmFixC<mb, nb>::team_invoke(const MemberType &member, const ScalarType alpha,
29 const ValueType *KOKKOS_RESTRICT A,
30 const ValueType *KOKKOS_RESTRICT B, const int k,
31 /**/ ValueType *KOKKOS_RESTRICT C) {
32 Kokkos::parallel_for(Kokkos::TeamThreadRange(member, 0, mb * nb), [&](const int &ij) {
33 const int i = ij / nb, j = ij % nb;
34
35 const ValueType *KOKKOS_RESTRICT pA = A + i * _as0, *KOKKOS_RESTRICT pB = B + j * _bs1;
36
37 ValueType c = 0;
38 for (int p = 0; p < k; ++p) c += pA[p * _as1] * pB[p * _bs0];
39 C[i * _cs0 + j * _cs1] += alpha * c;
40 });
41 return 0;
42 }
43
44 template <int mb, int nb>
45 template <typename MemberType, typename ScalarType, typename ValueType>
46 KOKKOS_INLINE_FUNCTION int InnerGemmFixC<mb, nb>::team_invoke(const MemberType &member, const ScalarType alpha,
47 const ValueType *KOKKOS_RESTRICT A,
48 const ValueType *KOKKOS_RESTRICT B, const int m,
49 const int n, const int k,
50 /**/ ValueType *KOKKOS_RESTRICT C) {
51 Kokkos::parallel_for(Kokkos::TeamThreadRange(member, 0, m * n), [&](const int &ij) {
52 const int i = ij / n, j = ij % n;
53
54 const ValueType *KOKKOS_RESTRICT pA = A + i * _as0, *KOKKOS_RESTRICT pB = B + j * _bs1;
55
56 ValueType c = 0;
57 for (int p = 0; p < k; ++p) c += pA[p * _as1] * pB[p * _bs0];
58 C[i * _cs0 + j * _cs1] += alpha * c;
59 });
60 return 0;
61 }
62 } // namespace KokkosBatched
63
64 #endif