| 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_LU_SERIAL_IMPL_HPP |
| 17 |
#define KOKKOSBATCHED_LU_SERIAL_IMPL_HPP |
| 18 |
|
| 19 |
/// \author Kyungjoo Kim ([email protected]) |
| 20 |
|
| 21 |
#include "KokkosBatched_Util.hpp" |
| 22 |
#include "KokkosBatched_LU_Serial_Internal.hpp" |
| 23 |
|
| 24 |
namespace KokkosBatched { |
| 25 |
|
| 26 |
/// |
| 27 |
/// Serial Impl |
| 28 |
/// ========= |
| 29 |
|
| 30 |
/// |
| 31 |
/// SerialLU no piv |
| 32 |
/// |
| 33 |
|
| 34 |
#if defined(KOKKOSBATCHED_IMPL_ENABLE_INTEL_MKL) && defined(KOKKOSBATCHED_IMPL_ENABLE_INTEL_MKL_BATCHED) && \ |
| 35 |
defined(__KOKKOSBATCHED_ENABLE_INTEL_MKL_COMPACT_BATCHED__) |
| 36 |
template <> |
| 37 |
template <typename AViewType> |
| 38 |
KOKKOS_INLINE_FUNCTION int SerialLU<Algo::LU::CompactMKL>::invoke( |
| 39 |
const AViewType &A, const typename MagnitudeScalarType<typename AViewType::non_const_value_type>::type tiny) { |
| 40 |
typedef typename AViewType::value_type vector_type; |
| 41 |
// typedef typename vector_type::value_type value_type; |
| 42 |
|
| 43 |
const int m = A.extent(0), n = A.extent(1); |
| 44 |
|
| 45 |
static_assert(is_vector<vector_type>::value, "value type is not vector type"); |
| 46 |
static_assert(vector_type::vector_length == 4 || vector_type::vector_length == 8, |
| 47 |
"AVX, AVX2 and AVX512 is supported"); |
| 48 |
const MKL_COMPACT_PACK format = vector_type::vector_length == 8 ? MKL_COMPACT_AVX512 : MKL_COMPACT_AVX; |
| 49 |
|
| 50 |
int r_val = 0; |
| 51 |
if (A.stride_0() == 1) { |
| 52 |
mkl_dgetrfnp_compact(MKL_COL_MAJOR, m, n, (double *)A.data(), A.stride_1(), (MKL_INT *)&r_val, format, |
| 53 |
(MKL_INT)vector_type::vector_length); |
| 54 |
} else if (A.stride_1() == 1) { |
| 55 |
mkl_dgetrfnp_compact(MKL_ROW_MAJOR, m, n, (double *)A.data(), A.stride_0(), (MKL_INT *)&r_val, format, |
| 56 |
(MKL_INT)vector_type::vector_length); |
| 57 |
} else { |
| 58 |
r_val = -1; |
| 59 |
} |
| 60 |
return r_val; |
| 61 |
} |
| 62 |
#endif |
| 63 |
|
| 64 |
template <> |
| 65 |
template <typename AViewType> |
| 66 |
KOKKOS_INLINE_FUNCTION int SerialLU<Algo::LU::Unblocked>::invoke( |
| 67 |
const AViewType &A, const typename MagnitudeScalarType<typename AViewType::non_const_value_type>::type tiny) { |
| 68 |
return SerialLU_Internal<Algo::LU::Unblocked>::invoke(A.extent(0), A.extent(1), A.data(), A.stride_0(), A.stride_1(), |
| 69 |
tiny); |
| 70 |
} |
| 71 |
|
| 72 |
template <> |
| 73 |
template <typename AViewType> |
| 74 |
KOKKOS_INLINE_FUNCTION int SerialLU<Algo::LU::Blocked>::invoke( |
| 75 |
const AViewType &A, const typename MagnitudeScalarType<typename AViewType::non_const_value_type>::type tiny) { |
| 76 |
return SerialLU_Internal<Algo::LU::Blocked>::invoke(A.extent(0), A.extent(1), A.data(), A.stride_0(), A.stride_1(), |
| 77 |
tiny); |
| 78 |
} |
| 79 |
|
| 80 |
} // namespace KokkosBatched |
| 81 |
|
| 82 |
#endif |