33 #ifndef EIGEN_ASSIGN_VML_H 34 #define EIGEN_ASSIGN_VML_H 43 template<
typename Dst,
typename Src,
typename UnaryOp>
51 StorageOrdersAgree = (int(Dst::IsRowMajor) == int(Src::IsRowMajor)),
52 InnerSize =
int(Dst::IsVectorAtCompileTime) ? int(Dst::SizeAtCompileTime)
53 : int(Dst::Flags)&
RowMajorBit ? int(Dst::ColsAtCompileTime)
54 : int(Dst::RowsAtCompileTime),
55 InnerMaxSize = int(Dst::IsVectorAtCompileTime) ? int(Dst::MaxSizeAtCompileTime)
56 : int(Dst::Flags)&
RowMajorBit ? int(Dst::MaxColsAtCompileTime)
57 : int(Dst::MaxRowsAtCompileTime),
58 MaxSizeAtCompileTime = Dst::SizeAtCompileTime,
60 MightEnableVml =
vml_call<UnaryOp>::
IsSupported && StorageOrdersAgree && DstHasDirectAccess && SrcHasDirectAccess
61 && Src::InnerStrideAtCompileTime==1 && Dst::InnerStrideAtCompileTime==1,
62 MightLinearize = MightEnableVml && (int(Dst::Flags) & int(Src::Flags) &
LinearAccessBit),
63 VmlSize = MightLinearize ? MaxSizeAtCompileTime : InnerMaxSize,
64 LargeEnough = VmlSize==
Dynamic || VmlSize>=EIGEN_MKL_VML_THRESHOLD,
65 MayEnableVml = MightEnableVml && LargeEnough,
66 MayLinearize = MayEnableVml && MightLinearize
76 template<
typename Derived1,
typename Derived2,
typename UnaryOp,
int Traversal,
int Unrolling,
79 :
assign_impl<Derived1, Eigen::CwiseUnaryOp<UnaryOp, Derived2>,Traversal,Unrolling,BuiltIn>
83 template<
typename Derived1,
typename Derived2,
typename UnaryOp,
int Traversal,
int Unrolling>
86 typedef typename Derived1::Scalar
Scalar;
87 typedef typename Derived1::Index
Index;
92 const Index innerSize = dst.innerSize();
93 const Index outerSize = dst.outerSize();
94 for(Index outer = 0; outer < outerSize; ++outer) {
95 const Scalar *src_ptr = src.IsRowMajor ? &(src.
nestedExpression().coeffRef(outer,0)) :
97 Scalar *dst_ptr = dst.IsRowMajor ? &(dst.coeffRef(outer,0)) : &(dst.coeffRef(0, outer));
103 template<
typename Derived1,
typename Derived2,
typename UnaryOp,
int Traversal,
int Unrolling>
116 #define EIGEN_MKL_VML_SPECIALIZE_ASSIGN(TRAVERSAL,UNROLLING) \ 117 template<typename Derived1, typename Derived2, typename UnaryOp> \ 118 struct assign_impl<Derived1, Eigen::CwiseUnaryOp<UnaryOp, Derived2>, TRAVERSAL, UNROLLING, Specialized> { \ 119 static inline void run(Derived1 &dst, const Eigen::CwiseUnaryOp<UnaryOp, Derived2> &src) { \ 120 vml_assign_impl<Derived1,Derived2,UnaryOp,TRAVERSAL,UNROLLING>::run(dst, src); \ 137 #if !defined (EIGEN_FAST_MATH) || (EIGEN_FAST_MATH != 1) 138 #define EIGEN_MKL_VML_MODE VML_HA 140 #define EIGEN_MKL_VML_MODE VML_LA 143 #define EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, VMLOP, EIGENTYPE, VMLTYPE) \ 144 template<> struct vml_call< scalar_##EIGENOP##_op<EIGENTYPE> > { \ 145 enum { IsSupported = 1 }; \ 146 static inline void run( const scalar_##EIGENOP##_op<EIGENTYPE>& , \ 147 int size, const EIGENTYPE* src, EIGENTYPE* dst) { \ 148 VMLOP(size, (const VMLTYPE*)src, (VMLTYPE*)dst); \ 152 #define EIGEN_MKL_VML_DECLARE_UNARY_CALL_LA(EIGENOP, VMLOP, EIGENTYPE, VMLTYPE) \ 153 template<> struct vml_call< scalar_##EIGENOP##_op<EIGENTYPE> > { \ 154 enum { IsSupported = 1 }; \ 155 static inline void run( const scalar_##EIGENOP##_op<EIGENTYPE>& , \ 156 int size, const EIGENTYPE* src, EIGENTYPE* dst) { \ 157 MKL_INT64 vmlMode = EIGEN_MKL_VML_MODE; \ 158 VMLOP(size, (const VMLTYPE*)src, (VMLTYPE*)dst, vmlMode); \ 162 #define EIGEN_MKL_VML_DECLARE_POW_CALL(EIGENOP, VMLOP, EIGENTYPE, VMLTYPE) \ 163 template<> struct vml_call< scalar_##EIGENOP##_op<EIGENTYPE> > { \ 164 enum { IsSupported = 1 }; \ 165 static inline void run( const scalar_##EIGENOP##_op<EIGENTYPE>& func, \ 166 int size, const EIGENTYPE* src, EIGENTYPE* dst) { \ 167 EIGENTYPE exponent = func.m_exponent; \ 168 MKL_INT64 vmlMode = EIGEN_MKL_VML_MODE; \ 169 VMLOP(&size, (const VMLTYPE*)src, (const VMLTYPE*)&exponent, \ 170 (VMLTYPE*)dst, &vmlMode); \ 174 #define EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(EIGENOP, VMLOP) \ 175 EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, vs##VMLOP, float, float) \ 176 EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, vd##VMLOP, double, double) 178 #define EIGEN_MKL_VML_DECLARE_UNARY_CALLS_COMPLEX(EIGENOP, VMLOP) \ 179 EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, vc##VMLOP, scomplex, MKL_Complex8) \ 180 EIGEN_MKL_VML_DECLARE_UNARY_CALL(EIGENOP, vz##VMLOP, dcomplex, MKL_Complex16) 182 #define EIGEN_MKL_VML_DECLARE_UNARY_CALLS(EIGENOP, VMLOP) \ 183 EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(EIGENOP, VMLOP) \ 184 EIGEN_MKL_VML_DECLARE_UNARY_CALLS_COMPLEX(EIGENOP, VMLOP) 187 #define EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL_LA(EIGENOP, VMLOP) \ 188 EIGEN_MKL_VML_DECLARE_UNARY_CALL_LA(EIGENOP, vms##VMLOP, float, float) \ 189 EIGEN_MKL_VML_DECLARE_UNARY_CALL_LA(EIGENOP, vmd##VMLOP, double, double) 191 #define EIGEN_MKL_VML_DECLARE_UNARY_CALLS_COMPLEX_LA(EIGENOP, VMLOP) \ 192 EIGEN_MKL_VML_DECLARE_UNARY_CALL_LA(EIGENOP, vmc##VMLOP, scomplex, MKL_Complex8) \ 193 EIGEN_MKL_VML_DECLARE_UNARY_CALL_LA(EIGENOP, vmz##VMLOP, dcomplex, MKL_Complex16) 195 #define EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(EIGENOP, VMLOP) \ 196 EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL_LA(EIGENOP, VMLOP) \ 197 EIGEN_MKL_VML_DECLARE_UNARY_CALLS_COMPLEX_LA(EIGENOP, VMLOP) 224 #endif // EIGEN_ASSIGN_VML_H
const UnaryOp & functor() const
#define EIGEN_MKL_VML_DECLARE_POW_CALL(EIGENOP, VMLOP, EIGENTYPE, VMLTYPE)
USING_NAMESPACE_ACADO IntermediateState sin(const Expression &arg)
#define EIGEN_MKL_VML_DECLARE_UNARY_CALLS_LA(EIGENOP, VMLOP)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_pow_op< typename Derived::Scalar >, const Derived > pow(const Eigen::ArrayBase< Derived > &x, const typename Derived::Scalar &exponent)
IntermediateState sqrt(const Expression &arg)
#define EIGEN_MKL_VML_DECLARE_UNARY_CALLS_REAL(EIGENOP, VMLOP)
Implements the scalar sine operator within the symbolic operators family.
const internal::remove_all< typename XprType::Nested >::type & nestedExpression() const
const unsigned int DirectAccessBit
iterative scaling algorithm to equilibrate rows and column norms in matrices
IntermediateState asin(const Expression &arg)
IntermediateState tan(const Expression &arg)
const unsigned int RowMajorBit
IntermediateState cos(const Expression &arg)
Implements the scalar cosine operator within the symbolic operators family.
IntermediateState acos(const Expression &arg)
Implements the scalar tangens operator within the symbolic operators family.
Implements the scalar exponential operator within the symbolic operators family.
IntermediateState square(const Expression &arg)
Implements the scalar inverse sine operator (arcsin) within the symbolic operators family...
#define EIGEN_MKL_VML_SPECIALIZE_ASSIGN(TRAVERSAL, UNROLLING)
Implements the scalar inverse cosine operator (arccos) within the symbolic operators family...
IntermediateState exp(const Expression &arg)
Generic expression where a coefficient-wise unary operator is applied to an expression.
static void run(Derived1 &dst, const CwiseUnaryOp< UnaryOp, Derived2 > &src)
static void run(Derived1 &dst, const CwiseUnaryOp< UnaryOp, Derived2 > &src)
const unsigned int LinearAccessBit
IntermediateState log(const Expression &arg)