| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// Stokhos Package |
| 4 |
// |
| 5 |
// Copyright 2009 NTESS and the Stokhos contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#ifndef KOKKOSBLAS3_GEMM_MP_VECTOR_HPP |
| 11 |
#define KOKKOSBLAS3_GEMM_MP_VECTOR_HPP |
| 12 |
|
| 13 |
#include <type_traits> |
| 14 |
#include "Sacado_ConfigDefs.h" |
| 15 |
|
| 16 |
#include "Stokhos_ViewStorage.hpp" |
| 17 |
#include "Sacado_MP_Vector.hpp" |
| 18 |
#include "Kokkos_View_MP_Vector.hpp" |
| 19 |
#include "Kokkos_ArithTraits_MP_Vector.hpp" |
| 20 |
#include "KokkosBlas.hpp" |
| 21 |
|
| 22 |
namespace KokkosBlas |
| 23 |
{ |
| 24 |
template <typename DA, typename... PA, |
| 25 |
typename DB, typename... PB, |
| 26 |
typename DC, typename... PC> |
| 27 |
typename std::enable_if<Kokkos::is_view_mp_vector<Kokkos::View<DA, PA...>>::value && |
| 28 |
Kokkos::is_view_mp_vector<Kokkos::View<DB, PB...>>::value && |
| 29 |
Kokkos::is_view_mp_vector<Kokkos::View<DC, PC...>>::value>::type |
| 30 |
gemm(const char transA[], |
| 31 |
const char transB[], |
| 32 |
typename Kokkos::View<DA, PA...>::const_value_type &alpha, |
| 33 |
const Kokkos::View<DA, PA...> &A, |
| 34 |
const Kokkos::View<DB, PB...> &B, |
| 35 |
typename Kokkos::View<DC, PC...>::const_value_type &beta, |
| 36 |
const Kokkos::View<DC, PC...> &C) |
| 37 |
{ |
| 38 |
// Assert that A, B, and C are in fact matrices |
| 39 |
static_assert(Kokkos::View<DA, PA...>::rank == 2, "GEMM: A must have rank 2 (be a matrix)."); |
| 40 |
static_assert(Kokkos::View<DB, PB...>::rank == 2, "GEMM: B must have rank 2 (be a matrix)."); |
| 41 |
static_assert(Kokkos::View<DC, PC...>::rank == 2, "GEMM: C must have rank 2 (be a matrix)."); |
| 42 |
|
| 43 |
if (B.extent(1) == 1 && C.extent(1) == 1) |
| 44 |
{ |
| 45 |
auto x = Kokkos::subview(B, Kokkos::ALL, 0); |
| 46 |
auto y = Kokkos::subview(C, Kokkos::ALL, 0); |
| 47 |
KokkosBlas::gemv(transA, alpha, A, x, beta, y); |
| 48 |
} |
| 49 |
else |
| 50 |
TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "GEMM: Not implemented for Sacado::MP::Vector scalar type!"); |
| 51 |
} |
| 52 |
} // namespace KokkosBlas |
| 53 |
|
| 54 |
#endif |