diff options
author | Eugene Zhulenev <ezhulenev@google.com> | 2019-06-28 11:22:46 -0700 |
---|---|---|
committer | Eugene Zhulenev <ezhulenev@google.com> | 2019-06-28 11:22:46 -0700 |
commit | 6e7c76481adeef47535aff2e15526ffa0d00eee0 (patch) | |
tree | 352e6e1c3235f781f47a805e93370a5bf5f27287 /unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h | |
parent | 878845cb25c1ba9e56883fd0654eafb55a22fc34 (diff) | |
parent | 1f61aee5ca3a1372e7cabf6dc8725d4b54ec54ce (diff) |
Merge with Eigen head
Diffstat (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h')
-rw-r--r-- | unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h b/unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h index 186457a31..27a15bfb2 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h @@ -78,9 +78,10 @@ class TensorForcedEvalOp : public TensorBase<TensorForcedEvalOp<XprType>, ReadOn }; -template<typename ArgType, typename Device> -struct TensorEvaluator<const TensorForcedEvalOp<ArgType>, Device> +template<typename ArgType_, typename Device> +struct TensorEvaluator<const TensorForcedEvalOp<ArgType_>, Device> { + typedef const typename internal::remove_all<ArgType_>::type ArgType; typedef TensorForcedEvalOp<ArgType> XprType; typedef typename ArgType::Scalar Scalar; typedef typename TensorEvaluator<ArgType, Device>::Dimensions Dimensions; @@ -88,6 +89,9 @@ struct TensorEvaluator<const TensorForcedEvalOp<ArgType>, Device> typedef typename XprType::CoeffReturnType CoeffReturnType; typedef typename PacketType<CoeffReturnType, Device>::type PacketReturnType; static const int PacketSize = PacketType<CoeffReturnType, Device>::size; + typedef typename Eigen::internal::traits<XprType>::PointerType TensorPointerType; + typedef StorageMemory<CoeffReturnType, Device> Storage; + typedef typename Storage::Type EvaluatorPointerType; enum { IsAligned = true, @@ -106,8 +110,8 @@ struct TensorEvaluator<const TensorForcedEvalOp<ArgType>, Device> TensorBlockReader; EIGEN_DEVICE_FUNC TensorEvaluator(const XprType& op, const Device& device) - /// op_ is used for sycl - : m_impl(op.expression(), device), m_op(op.expression()), m_device(device), m_buffer(NULL) + : m_impl(op.expression(), device), m_op(op.expression()), + m_device(device), m_buffer(NULL) { } EIGEN_DEVICE_FUNC const Dimensions& dimensions() const { return m_impl.dimensions(); } @@ -115,18 +119,19 @@ struct TensorEvaluator<const TensorForcedEvalOp<ArgType>, Device> #if !defined(EIGEN_HIPCC) EIGEN_DEVICE_FUNC #endif - EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(CoeffReturnType*) { + EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(EvaluatorPointerType) { const Index numValues = internal::array_prod(m_impl.dimensions()); - m_buffer = (CoeffReturnType*)m_device.allocate_temp(numValues * sizeof(CoeffReturnType)); + m_buffer = m_device.get((CoeffReturnType*)m_device.allocate_temp(numValues * sizeof(CoeffReturnType))); + #ifndef EIGEN_USE_SYCL // Should initialize the memory in case we're dealing with non POD types. if (NumTraits<CoeffReturnType>::RequireInitialization) { for (Index i = 0; i < numValues; ++i) { new(m_buffer+i) CoeffReturnType(); } } + #endif typedef TensorEvalToOp< const typename internal::remove_const<ArgType>::type > EvalTo; - EvalTo evalToTmp(m_buffer, m_op); - + EvalTo evalToTmp(m_device.get(m_buffer), m_op); const bool Vectorize = internal::IsVectorizable<Device, const ArgType>::value; const bool Tile = TensorEvaluator<const ArgType, Device>::BlockAccess && TensorEvaluator<const ArgType, Device>::PreferBlockAccess; @@ -165,17 +170,20 @@ struct TensorEvaluator<const TensorForcedEvalOp<ArgType>, Device> } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE - typename Eigen::internal::traits<XprType>::PointerType data() const { return m_buffer; } + EvaluatorPointerType data() const { return m_buffer; } - /// required by sycl in order to extract the sycl accessor - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorEvaluator<ArgType, Device>& impl() { return m_impl; } - /// used by sycl in order to build the sycl buffer - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Device& device() const{return m_device;} +#ifdef EIGEN_USE_SYCL + // binding placeholder accessors to a command group handler for SYCL + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void bind(cl::sycl::handler &cgh) const { + m_buffer.bind(cgh); + m_impl.bind(cgh); + } +#endif private: TensorEvaluator<ArgType, Device> m_impl; const ArgType m_op; - const Device& m_device; - CoeffReturnType* m_buffer; + const Device m_device; + EvaluatorPointerType m_buffer; }; |