Debian Codegraph @

packages/kokkos-kernels/batched/dense/src/KokkosBatched_Copy_Decl.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_COPY_DECL_HPP
17 #define KOKKOSBATCHED_COPY_DECL_HPP
18
19 /// \author Kyungjoo Kim ([email protected])
20
21 #include "KokkosBatched_Util.hpp"
22
23 namespace KokkosBatched {
24
25 ///
26 /// Serial Copy
27 ///
28
29 template <typename ArgTrans = Trans::NoTranspose, int rank = 2>
30 struct SerialCopy {
31 template <typename AViewType, typename BViewType>
32 KOKKOS_INLINE_FUNCTION static int invoke(const AViewType &A, const BViewType &B);
33 };
34
35 ///
36 /// Team Copy
37 ///
38
39 template <typename MemberType, typename ArgTrans = Trans::NoTranspose, int rank = 2>
40 struct TeamCopy {
41 template <typename AViewType, typename BViewType>
42 KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const AViewType &A, const BViewType &B);
43 };
44
45 ///
46 /// TeamVector Copy
47 ///
48
49 template <typename MemberType, typename ArgTrans = Trans::NoTranspose, int rank = 2>
50 struct TeamVectorCopy {
51 template <typename AViewType, typename BViewType>
52 KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const AViewType &A, const BViewType &B);
53 };
54
55 ///
56 /// Selective Interface
57 ///
58 template <typename MemberType, typename ArgTrans, typename ArgMode, int rank = 2>
59 struct Copy {
60 template <typename AViewType, typename BViewType>
61 KOKKOS_FORCEINLINE_FUNCTION static int invoke(const MemberType &member, const AViewType &A, const BViewType &B) {
62 int r_val = 0;
63 if (std::is_same<ArgMode, Mode::Serial>::value) {
64 r_val = SerialCopy<ArgTrans, rank>::invoke(A, B);
65 } else if (std::is_same<ArgMode, Mode::Team>::value) {
66 r_val = TeamCopy<MemberType, ArgTrans, rank>::invoke(member, A, B);
67 } else if (std::is_same<ArgMode, Mode::TeamVector>::value) {
68 r_val = TeamVectorCopy<MemberType, ArgTrans, rank>::invoke(member, A, B);
69 }
70 return r_val;
71 }
72 };
73
74 } // namespace KokkosBatched
75
76 #include "KokkosBatched_Copy_Impl.hpp"
77
78 #define KOKKOSBATCHED_SERIAL_COPY_MATRIX_NO_TRANSPOSE_INTERNAL_INVOKE(M, N, A, AS0, AS1, B, BS0, BS1) \
79 KokkosBatched::SerialCopyInternal ::invoke(M, N, A, AS0, AS1, B, BS0, BS1)
80
81 #define KOKKOSBATCHED_TEAM_COPY_MATRIX_NO_TRANSPOSE_INTERNAL_INVOKE(MEMBER, M, N, A, AS0, AS1, B, BS0, BS1) \
82 KokkosBatched::TeamCopyInternal ::invoke(MEMBER, M, N, A, AS0, AS1, B, BS0, BS1)
83
84 #define KOKKOSBATCHED_SERIAL_COPY_VECTOR_INTERNAL_INVOKE(M, A, AS, B, BS) \
85 KokkosBatched::SerialCopyInternal ::invoke(M, A, AS, B, BS)
86
87 #define KOKKOSBATCHED_TEAM_COPY_VECTOR_NO_TRANSPOSE_INTERNAL_INVOKE(MEMBER, M, A, AS, B, BS) \
88 KokkosBatched::TeamCopyInternal ::invoke(MEMBER, M, A, AS, B, BS)
89
90 #define KOKKOSBATCHED_COPY_VECTOR_NO_TRANSPOSE_INTERNAL_INVOKE(MODETYPE, MEMBER, M, A, AS, B, BS) \
91 if (std::is_same<MODETYPE, KokkosBatched::Mode::Serial>::value) { \
92 KOKKOSBATCHED_SERIAL_COPY_VECTOR_INTERNAL_INVOKE(M, A, AS, B, BS); \
93 } else if (std::is_same<MODETYPE, KokkosBatched::Mode::Team>::value) { \
94 KOKKOSBATCHED_TEAM_COPY_VECTOR_NO_TRANSPOSE_INTERNAL_INVOKE(MEMBER, M, A, AS, B, BS); \
95 }
96
97 #endif