| 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_TRIANGULAR_INTERNAL_HPP |
| 17 |
#define KOKKOSBATCHED_SET_TRIANGULAR_INTERNAL_HPP |
| 18 |
|
| 19 |
/// \author Kyungjoo Kim ([email protected]) |
| 20 |
|
| 21 |
#include "KokkosBatched_Util.hpp" |
| 22 |
|
| 23 |
namespace KokkosBatched { |
| 24 |
|
| 25 |
/// |
| 26 |
/// Serial Internal Impl |
| 27 |
/// ==================== |
| 28 |
struct SerialSetLowerTriangularInternal { |
| 29 |
template <typename ScalarType, typename ValueType> |
| 30 |
KOKKOS_INLINE_FUNCTION static int invoke(const int m, const int n, const int dist, const ScalarType alpha, |
| 31 |
/* */ ValueType *KOKKOS_RESTRICT A, const int as0, const int as1) { |
| 32 |
for (int j = 0; j < n; ++j) { |
| 33 |
#if defined(KOKKOS_ENABLE_PRAGMA_UNROLL) |
| 34 |
#pragma unroll |
| 35 |
#endif |
| 36 |
for (int i = (j + dist); i < m; ++i) { |
| 37 |
A[i * as0 + j * as1] = alpha; |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
return 0; |
| 42 |
} |
| 43 |
}; |
| 44 |
|
| 45 |
struct TeamVectorSetLowerTriangularInternal { |
| 46 |
template <typename MemberType, typename ScalarType, typename ValueType> |
| 47 |
KOKKOS_INLINE_FUNCTION static int invoke(const MemberType &member, const int m, const int n, const int dist, |
| 48 |
const ScalarType alpha, |
| 49 |
/* */ ValueType *KOKKOS_RESTRICT A, const int as0, const int as1) { |
| 50 |
Kokkos::parallel_for(Kokkos::TeamThreadRange(member, n), [&](const int &j) { |
| 51 |
const int jdist = j + dist; |
| 52 |
Kokkos::parallel_for(Kokkos::ThreadVectorRange(member, m), [=](const int &i) { |
| 53 |
if (i >= jdist) A[i * as0 + j * as1] = alpha; |
| 54 |
}); |
| 55 |
}); |
| 56 |
return 0; |
| 57 |
} |
| 58 |
}; |
| 59 |
|
| 60 |
} // end namespace KokkosBatched |
| 61 |
|
| 62 |
#endif |