Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KokkosBlas3_gemm_MP_Vector.hpp
Go to the documentation of this file.
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"
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
std::enable_if< Kokkos::is_view_mp_vector< Kokkos::View< DA, PA...> >::value &&Kokkos::is_view_mp_vector< Kokkos::View< DX, PX...> >::value &&Kokkos::is_view_mp_vector< Kokkos::View< DY, PY...> >::value >::type gemv(const char trans[], typename Kokkos::View< DA, PA...>::const_value_type &alpha, const Kokkos::View< DA, PA...> &A, const Kokkos::View< DX, PX...> &x, typename Kokkos::View< DY, PY...>::const_value_type &beta, const Kokkos::View< DY, PY...> &y)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
std::enable_if< Kokkos::is_view_mp_vector< Kokkos::View< DA, PA...> >::value &&Kokkos::is_view_mp_vector< Kokkos::View< DB, PB...> >::value &&Kokkos::is_view_mp_vector< Kokkos::View< DC, PC...> >::value >::type gemm(const char transA[], const char transB[], typename Kokkos::View< DA, PA...>::const_value_type &alpha, const Kokkos::View< DA, PA...> &A, const Kokkos::View< DB, PB...> &B, typename Kokkos::View< DC, PC...>::const_value_type &beta, const Kokkos::View< DC, PC...> &C)