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) {
60 static_assert(ViewType::rank == 2,
"A must be a rank-2 Kokkos::View.");
61 static_assert(std::is_same<typename ViewType::array_layout, Kokkos::LayoutLeft>::value ||
62 std::is_same<typename ViewType::array_layout, Kokkos::LayoutRight>::value ||
63 std::is_same<typename ViewType::array_layout, Kokkos::LayoutStride>::value,
64 "A's layout must be either LayoutLeft, LayoutRight, or LayoutStride.");
65 static_assert(std::is_integral<IndexType>::value,
66 "IndexType must be a built-in integer type.");
71 const auto LDA = (A.extent(1) > 1) ? stride[1] : A.extent(0);
72 return LDA == 0 ? IndexType(1) : LDA;
77 template <
class ViewType,
80 struct GetStride1DView {
81 typedef ArrayLayout array_layout;
83 static IndexType getStride(
const ViewType& x) {
84 static_assert(ViewType::rank == 1,
"x must be a rank-1 Kokkos::View.");
85 static_assert(std::is_same<typename ViewType::array_layout, Kokkos::LayoutLeft>::value ||
86 std::is_same<typename ViewType::array_layout, Kokkos::LayoutRight>::value ||
87 std::is_same<typename ViewType::array_layout, Kokkos::LayoutStride>::value,
88 "x's layout must be either LayoutLeft, LayoutRight, or LayoutStride.");
89 static_assert(std::is_same<typename ViewType::array_layout, array_layout>::value,
90 "ViewType::array_layout must be the same as array_layout.");
91 static_assert(std::is_integral<IndexType>::value,
92 "IndexType must be a built-in integer type.");
99 template <
class ViewType,
101 struct GetStride1DView<ViewType, Kokkos::LayoutLeft, IndexType> {
102 typedef Kokkos::LayoutLeft array_layout;
104 static IndexType getStride(
const ViewType&) {
105 static_assert(ViewType::rank == 1,
"x must be a rank-1 Kokkos::View.");
106 static_assert(std::is_same<typename ViewType::array_layout, array_layout>::value,
107 "ViewType::array_layout must be the same as array_layout.");
108 static_assert(std::is_integral<IndexType>::value,
109 "IndexType must be a built-in integer type.");
110 return static_cast<IndexType
>(1);
114 template <
class ViewType,
116 struct GetStride1DView<ViewType, Kokkos::LayoutRight, IndexType> {
117 typedef Kokkos::LayoutRight array_layout;
119 static IndexType getStride(
const ViewType&) {
120 static_assert(ViewType::rank == 1,
"x must be a rank-1 Kokkos::View.");
121 static_assert(std::is_same<typename ViewType::array_layout, array_layout>::value,
122 "ViewType::array_layout must be the same as array_layout.");
123 static_assert(std::is_integral<IndexType>::value,
124 "IndexType must be a built-in integer type.");
125 return static_cast<IndexType
>(1);
132 template <
class ViewType,
133 class IndexType =
int>
135 getStride1DView(
const ViewType& x) {
136 typedef Impl::GetStride1DView<ViewType, typename ViewType::array_layout, IndexType> impl_type;
137 return impl_type::getStride(x);
144 #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...