43 #ifndef KOKKOS_CRSMATRIX_MKL_HPP
44 #define KOKKOS_CRSMATRIX_MKL_HPP
49 #include <impl/Kokkos_PhysicalLayout.hpp>
58 template<
typename T,
class RangeVector,
class CrsMatrix,
class DomainVector>
61 ! Kokkos::Impl::is_same<T,double>::value &&
62 ! Kokkos::Impl::is_same<T,float>::value,
63 typename RangeVector::value_type>::type s_b,
65 typename DomainVector::value_type s_a,
67 const DomainVector& x)
72 template<
typename T,
class RangeVector,
class CrsMatrix,
class DomainVector>
73 bool MV_Multiply_DoMKL(
typename Kokkos::Impl::enable_if<Kokkos::Impl::is_same<T,double>::value,
double >::type s_b
74 ,
const RangeVector & y,
double s_a,
75 const CrsMatrix & A ,
const DomainVector & x) {
77 char matdescra[6] =
"GLNC0";
80 int n = x.dimension_1();
82 double* x_ptr = (
double*)x.ptr_on_device();
83 double* y_ptr = (
double*)y.ptr_on_device();
84 if(x.dimension_1()>1) {
85 Impl::PhysicalLayout layout_x(x);
86 Impl::PhysicalLayout layout_y(y);
87 if((layout_x.layout_type!=layout_x.Right) || layout_y.layout_type!=layout_y.Right)
return false;
89 int stride_x = layout_x.stride[0];
90 int stride_y = layout_y.stride[0];
100 A.values.ptr_on_device(),
101 A.graph.entries.ptr_on_device(),
102 (
int*) &A.graph.row_map(0),
103 (
int*) &A.graph.row_map(1),
114 A.values.ptr_on_device(),
115 A.graph.entries.ptr_on_device(),
116 (
int*) &A.graph.row_map(0),
117 (
int*) &A.graph.row_map(1),
124 template<
typename T,
class RangeVector,
class CrsMatrix,
class DomainVector>
125 bool MV_Multiply_DoMKL(
typename Kokkos::Impl::enable_if<Kokkos::Impl::is_same<T,float>::value,
float >::type s_b
126 ,
const RangeVector & y,
float s_a,
127 const CrsMatrix & A ,
const DomainVector & x) {
129 char matdescra[6] =
"GLNC0";
130 int stride_x = layout_x.stride[0];
131 int stride_y = layout_y.stride[0];
134 int n = x.dimension_1();
136 float* x_ptr = (
float*)x.ptr_on_device();
137 float* y_ptr = (
float*)y.ptr_on_device();
138 if(x.dimension_1()>1) {
140 Impl::PhysicalLayout layout_x(x);
141 Impl::PhysicalLayout layout_y(y);
142 if((layout_x.layout_type!=layout_x.Right) || layout_y.layout_type!=layout_y.Right)
return false;
148 A.values.ptr_on_device(),
149 A.graph.entries.ptr_on_device(),
150 (
int*) &A.graph.row_map(0),
151 (
int*) &A.graph.row_map(1),
162 A.values.ptr_on_device(),
163 A.graph.entries.ptr_on_device(),
164 (
int*) &A.graph.row_map(0),
165 (
int*) &A.graph.row_map(1),
173 template<
class RangeVector,
class CrsMatrix,
class DomainVector>
174 bool MV_Multiply_Try_MKL(
typename RangeVector::value_type s_b,
const RangeVector & y,
typename DomainVector::value_type s_a,
175 const CrsMatrix & A ,
const DomainVector & x)
177 if( ! Kokkos::Impl::is_same<typename RangeVector::device_type::memory_space,typename Kokkos::HostSpace>::value )
return false;
178 if(Kokkos::Impl::is_same<typename RangeVector::non_const_value_type,float>::value&&
179 Kokkos::Impl::is_same<typename DomainVector::non_const_value_type,float>::value&&
180 Kokkos::Impl::is_same<typename CrsMatrix::values_type::non_const_value_type,float>::value) {
181 return MV_Multiply_DoMKL<typename RangeVector::value_type,RangeVector,CrsMatrix,DomainVector>(s_b,y,s_a,A,x);
183 if(Kokkos::Impl::is_same<typename RangeVector::non_const_value_type,double>::value&&
184 Kokkos::Impl::is_same<typename DomainVector::non_const_value_type,double>::value&&
185 Kokkos::Impl::is_same<typename CrsMatrix::values_type::non_const_value_type,double>::value) {
186 return MV_Multiply_DoMKL<typename RangeVector::value_type,RangeVector,CrsMatrix,DomainVector>(s_b,y,s_a,A,x);
193 #endif // KOKKOS_CRSMATRIX_MKL_HPP
bool MV_Multiply_DoMKL(typename Kokkos::Impl::enable_if< !Kokkos::Impl::is_same< T, double >::value &&!Kokkos::Impl::is_same< T, float >::value, typename RangeVector::value_type >::type s_b, const RangeVector &y, typename DomainVector::value_type s_a, const CrsMatrix &A, const DomainVector &x)
Attempt to compute y = s_a * A * x using Intel MKL.
Compressed sparse row implementation of a sparse matrix.