42 #ifndef TPETRA_DETAILS_BLAS_HPP
43 #define TPETRA_DETAILS_BLAS_HPP
53 #include "TpetraCore_config.h"
54 #include "Kokkos_Core.hpp"
55 #include "Kokkos_Complex.hpp"
56 #include <type_traits>
67 template<
class ScalarType>
69 static constexpr
bool value =
70 std::is_same<ScalarType, float>::value ||
71 std::is_same<ScalarType, double>::value ||
72 std::is_same<ScalarType, ::Kokkos::complex<float> >::value ||
73 std::is_same<ScalarType, ::Kokkos::complex<double> >::value;
81 template<
class LayoutType>
83 static constexpr
bool value =
84 std::is_same<LayoutType, ::Kokkos::LayoutLeft>::value;
88 template<
class ViewType,
89 class IndexType =
int>
91 getStride2DView (
const ViewType& A)
93 static_assert (ViewType::Rank == 2,
"A must be a rank-2 Kokkos::View.");
94 static_assert (std::is_same<typename ViewType::array_layout, Kokkos::LayoutLeft>::value ||
95 std::is_same<typename ViewType::array_layout, Kokkos::LayoutRight>::value ||
96 std::is_same<typename ViewType::array_layout, Kokkos::LayoutStride>::value,
97 "A's layout must be either LayoutLeft, LayoutRight, or LayoutStride.");
98 static_assert (std::is_integral<IndexType>::value,
99 "IndexType must be a built-in integer type.");
104 const auto LDA = (A.extent (1) > 1) ? stride[1] : A.extent (0);
105 return LDA == 0 ? IndexType (1) : LDA;
110 template<
class ViewType,
113 struct GetStride1DView {
114 typedef ArrayLayout array_layout;
116 static IndexType getStride (
const ViewType& x)
118 static_assert (ViewType::Rank == 1,
"x must be a rank-1 Kokkos::View.");
119 static_assert (std::is_same<typename ViewType::array_layout, Kokkos::LayoutLeft>::value ||
120 std::is_same<typename ViewType::array_layout, Kokkos::LayoutRight>::value ||
121 std::is_same<typename ViewType::array_layout, Kokkos::LayoutStride>::value,
122 "x's layout must be either LayoutLeft, LayoutRight, or LayoutStride.");
123 static_assert (std::is_same<typename ViewType::array_layout, array_layout>::value,
124 "ViewType::array_layout must be the same as array_layout.");
125 static_assert (std::is_integral<IndexType>::value,
126 "IndexType must be a built-in integer type.");
133 template<
class ViewType,
135 struct GetStride1DView<ViewType, Kokkos::LayoutLeft, IndexType> {
136 typedef Kokkos::LayoutLeft array_layout;
138 static IndexType getStride (
const ViewType&)
140 static_assert (ViewType::Rank == 1,
"x must be a rank-1 Kokkos::View.");
141 static_assert (std::is_same<typename ViewType::array_layout, array_layout>::value,
142 "ViewType::array_layout must be the same as array_layout.");
143 static_assert (std::is_integral<IndexType>::value,
144 "IndexType must be a built-in integer type.");
145 return static_cast<IndexType
> (1);
149 template<
class ViewType,
151 struct GetStride1DView<ViewType, Kokkos::LayoutRight, IndexType> {
152 typedef Kokkos::LayoutRight array_layout;
154 static IndexType getStride (
const ViewType&)
156 static_assert (ViewType::Rank == 1,
"x must be a rank-1 Kokkos::View.");
157 static_assert (std::is_same<typename ViewType::array_layout, array_layout>::value,
158 "ViewType::array_layout must be the same as array_layout.");
159 static_assert (std::is_integral<IndexType>::value,
160 "IndexType must be a built-in integer type.");
161 return static_cast<IndexType
> (1);
168 template<
class ViewType,
169 class IndexType =
int>
171 getStride1DView (
const ViewType& x)
173 typedef Impl::GetStride1DView<ViewType, typename ViewType::array_layout, IndexType> impl_type;
174 return impl_type::getStride (x);
181 #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...