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"
35template <
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;
49template <
class LayoutType>
51 static constexpr bool value =
52 std::is_same<LayoutType, ::Kokkos::LayoutLeft>::value;
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);
80struct GetStride1DView {
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.");
99template <
class ViewType,
101struct 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);
114template <
class ViewType,
116struct 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);
132template <
class ViewType,
133 class IndexType =
int>
136 typedef Impl::GetStride1DView<ViewType, typename ViewType::array_layout, IndexType>
impl_type;
137 return impl_type::getStride(
x);
IndexType getStride1DView(const ViewType &x)
Get the stride ("INCX" in BLAS terms) of the 1-D Kokkos::View x.
IndexType getStride2DView(const ViewType &A)
Get the stride (leading dimension) of the 2-D Kokkos::View A.
Struct that holds views of the contents of a CrsMatrix.
Implementation details of Tpetra.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
Do BLAS libraries (all that are compliant with the BLAS Standard) support the given Kokkos array layo...
Do BLAS libraries (all that are compliant with the BLAS Standard) support the given "scalar" (matrix ...