10 #ifndef TPETRA_DETAILS_BLAS_HPP
11 #define TPETRA_DETAILS_BLAS_HPP
21 #include "TpetraCore_config.h"
22 #include "Kokkos_Core.hpp"
23 #include "Kokkos_Complex.hpp"
24 #include <type_traits>
35 template<
class ScalarType>
37 static constexpr
bool value =
38 std::is_same<ScalarType, float>::value ||
39 std::is_same<ScalarType, double>::value ||
40 std::is_same<ScalarType, ::Kokkos::complex<float> >::value ||
41 std::is_same<ScalarType, ::Kokkos::complex<double> >::value;
49 template<
class LayoutType>
51 static constexpr
bool value =
52 std::is_same<LayoutType, ::Kokkos::LayoutLeft>::value;
56 template<
class ViewType,
57 class IndexType =
int>
59 getStride2DView (
const ViewType& A)
61 static_assert (ViewType::rank == 2,
"A must be a rank-2 Kokkos::View.");
62 static_assert (std::is_same<typename ViewType::array_layout, Kokkos::LayoutLeft>::value ||
63 std::is_same<typename ViewType::array_layout, Kokkos::LayoutRight>::value ||
64 std::is_same<typename ViewType::array_layout, Kokkos::LayoutStride>::value,
65 "A's layout must be either LayoutLeft, LayoutRight, or LayoutStride.");
66 static_assert (std::is_integral<IndexType>::value,
67 "IndexType must be a built-in integer type.");
72 const auto LDA = (A.extent (1) > 1) ? stride[1] : A.extent (0);
73 return LDA == 0 ? IndexType (1) : LDA;
78 template<
class ViewType,
81 struct GetStride1DView {
82 typedef ArrayLayout array_layout;
84 static IndexType getStride (
const ViewType& x)
86 static_assert (ViewType::rank == 1,
"x must be a rank-1 Kokkos::View.");
87 static_assert (std::is_same<typename ViewType::array_layout, Kokkos::LayoutLeft>::value ||
88 std::is_same<typename ViewType::array_layout, Kokkos::LayoutRight>::value ||
89 std::is_same<typename ViewType::array_layout, Kokkos::LayoutStride>::value,
90 "x's layout must be either LayoutLeft, LayoutRight, or LayoutStride.");
91 static_assert (std::is_same<typename ViewType::array_layout, array_layout>::value,
92 "ViewType::array_layout must be the same as array_layout.");
93 static_assert (std::is_integral<IndexType>::value,
94 "IndexType must be a built-in integer type.");
101 template<
class ViewType,
103 struct GetStride1DView<ViewType, Kokkos::LayoutLeft, IndexType> {
104 typedef Kokkos::LayoutLeft array_layout;
106 static IndexType getStride (
const ViewType&)
108 static_assert (ViewType::rank == 1,
"x must be a rank-1 Kokkos::View.");
109 static_assert (std::is_same<typename ViewType::array_layout, array_layout>::value,
110 "ViewType::array_layout must be the same as array_layout.");
111 static_assert (std::is_integral<IndexType>::value,
112 "IndexType must be a built-in integer type.");
113 return static_cast<IndexType
> (1);
117 template<
class ViewType,
119 struct GetStride1DView<ViewType, Kokkos::LayoutRight, IndexType> {
120 typedef Kokkos::LayoutRight array_layout;
122 static IndexType getStride (
const ViewType&)
124 static_assert (ViewType::rank == 1,
"x must be a rank-1 Kokkos::View.");
125 static_assert (std::is_same<typename ViewType::array_layout, array_layout>::value,
126 "ViewType::array_layout must be the same as array_layout.");
127 static_assert (std::is_integral<IndexType>::value,
128 "IndexType must be a built-in integer type.");
129 return static_cast<IndexType
> (1);
136 template<
class ViewType,
137 class IndexType =
int>
139 getStride1DView (
const ViewType& x)
141 typedef Impl::GetStride1DView<ViewType, typename ViewType::array_layout, IndexType> impl_type;
142 return impl_type::getStride (x);
149 #endif // TPETRA_DETAILS_BLAS_HPP
Do BLAS libraries (all that are compliant with the BLAS Standard) support the given "scalar" (matrix ...
Do BLAS libraries (all that are compliant with the BLAS Standard) support the given Kokkos array layo...