| 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_SET_IDENTITY_DECL_HPP |
| 17 |
#define KOKKOSBATCHED_SET_IDENTITY_DECL_HPP |
| 18 |
|
| 19 |
/// \author Kyungjoo Kim ([email protected]) |
| 20 |
|
| 21 |
#include "KokkosBatched_Util.hpp" |
| 22 |
#include "KokkosBatched_Vector.hpp" |
| 23 |
|
| 24 |
namespace KokkosBatched { |
| 25 |
|
| 26 |
/// |
| 27 |
/// Serial SetIdentity |
| 28 |
/// |
| 29 |
|
| 30 |
struct SerialSetIdentity { |
| 31 |
template <typename AViewType> |
| 32 |
KOKKOS_INLINE_FUNCTION static int invoke(const AViewType &A); |
| 33 |
}; |
| 34 |
|
| 35 |
/// |
| 36 |
/// Team Set |
| 37 |
/// |
| 38 |
|
| 39 |
template <typename MemberType> |
| 40 |
struct TeamSetIdentity { |
| 41 |
template <typename AViewType> |
| 42 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const AViewType &A); |
| 43 |
}; |
| 44 |
|
| 45 |
/// |
| 46 |
/// Selective Interface |
| 47 |
/// |
| 48 |
template <typename MemberType, typename ArgMode> |
| 49 |
struct SetIdentity { |
| 50 |
template <typename AViewType> |
| 51 |
KOKKOS_FORCEINLINE_FUNCTION static int invoke(const MemberType &member, const AViewType &A) { |
| 52 |
int r_val = 0; |
| 53 |
if (std::is_same<ArgMode, Mode::Serial>::value) { |
| 54 |
r_val = SerialSetIdentity::invoke(A); |
| 55 |
} else if (std::is_same<ArgMode, Mode::Team>::value) { |
| 56 |
r_val = TeamSetIdentity<MemberType>::invoke(member, A); |
| 57 |
} |
| 58 |
return r_val; |
| 59 |
} |
| 60 |
}; |
| 61 |
|
| 62 |
} // namespace KokkosBatched |
| 63 |
|
| 64 |
#endif |