From 925d0d375a05f09c3e3abb91f29fc2513bb25d0d Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Wed, 1 Jul 2015 11:32:04 -0700 Subject: Enabled the vectorized evaluation of several tensor expressions that was previously disabled by mistake --- unsupported/Eigen/CXX11/src/Tensor/TensorChipping.h | 6 ++---- .../Eigen/CXX11/src/Tensor/TensorConcatenation.h | 6 +++--- .../Eigen/CXX11/src/Tensor/TensorConvolution.h | 4 ++-- unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h | 11 +---------- .../Eigen/CXX11/src/Tensor/TensorForcedEval.h | 2 +- .../CXX11/src/Tensor/TensorForwardDeclarations.h | 21 ++++++++++++++++++++- .../Eigen/CXX11/src/Tensor/TensorLayoutSwap.h | 4 ++-- unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h | 10 +++++----- unsupported/Eigen/CXX11/src/Tensor/TensorReverse.h | 4 ++-- .../Eigen/CXX11/src/Tensor/TensorShuffling.h | 4 ++-- unsupported/Eigen/CXX11/src/Tensor/TensorStriding.h | 4 ++-- 11 files changed, 42 insertions(+), 34 deletions(-) diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorChipping.h b/unsupported/Eigen/CXX11/src/Tensor/TensorChipping.h index 3b99ef069..2ef5ff205 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorChipping.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorChipping.h @@ -106,8 +106,7 @@ class TensorChippingOp : public TensorBase > { typedef TensorAssignOp Assign; Assign assign(*this, other); - static const bool Vectorize = TensorEvaluator::PacketAccess; - internal::TensorExecutor::run(assign, DefaultDevice()); + internal::TensorExecutor::run(assign, DefaultDevice()); return *this; } @@ -117,8 +116,7 @@ class TensorChippingOp : public TensorBase > { typedef TensorAssignOp Assign; Assign assign(*this, other); - static const bool Vectorize = TensorEvaluator::PacketAccess; - internal::TensorExecutor::run(assign, DefaultDevice()); + internal::TensorExecutor::run(assign, DefaultDevice()); return *this; } diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorConcatenation.h b/unsupported/Eigen/CXX11/src/Tensor/TensorConcatenation.h index 6979fb4ec..759e8208f 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorConcatenation.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorConcatenation.h @@ -88,7 +88,7 @@ class TensorConcatenationOp : public TensorBase Assign; Assign assign(*this, other); - internal::TensorExecutor::run(assign, DefaultDevice()); + internal::TensorExecutor::run(assign, DefaultDevice()); return *this; } @@ -98,7 +98,7 @@ class TensorConcatenationOp : public TensorBase Assign; Assign assign(*this, other); - internal::TensorExecutor::run(assign, DefaultDevice()); + internal::TensorExecutor::run(assign, DefaultDevice()); return *this; } @@ -334,7 +334,7 @@ templatedimensions().TotalSize()); EIGEN_ALIGN_DEFAULT CoeffReturnType values[packetSize]; - PacketReturnType rslt = internal::pstore(values, x); + internal::pstore(values, x); for (int i = 0; i < packetSize; ++i) { coeffRef(index+i) = values[i]; } diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorConvolution.h b/unsupported/Eigen/CXX11/src/Tensor/TensorConvolution.h index 6b8f71b96..07cba649b 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorConvolution.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorConvolution.h @@ -510,7 +510,7 @@ struct TensorEvaluator EvalTo; EvalTo evalToTmp(local, m_kernelArg); - internal::TensorExecutor::PacketAccess>::run(evalToTmp, m_device); + internal::TensorExecutor::run(evalToTmp, m_device); m_kernel = local; m_local_kernel = true; @@ -815,7 +815,7 @@ struct TensorEvaluator EvalTo; EvalTo evalToTmp(local, m_kernelArg); - internal::TensorExecutor::PacketAccess>::run(evalToTmp, m_device); + internal::TensorExecutor::run(evalToTmp, m_device); m_kernel = local; m_local_kernel = true; diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h b/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h index 6ea588e4b..24606b0c8 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h @@ -22,13 +22,8 @@ namespace Eigen { */ namespace internal { -template -struct IsVectorizable { - static const bool value = TensorEvaluator::PacketAccess; -}; - // Default strategy: the expression is evaluated with a single cpu thread. -template::value> +template class TensorExecutor { public: @@ -198,10 +193,6 @@ EigenMetaKernel_Vectorizable(Evaluator memcopied_eval, Index size) { } } -template -struct IsVectorizable { - static const bool value = TensorEvaluator::PacketAccess && TensorEvaluator::IsAligned; -}; template class TensorExecutor diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h b/unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h index 41a36cb75..bd32249b6 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorForcedEval.h @@ -116,7 +116,7 @@ struct TensorEvaluator, Device> } typedef TensorEvalToOp EvalTo; EvalTo evalToTmp(m_buffer, m_op); - internal::TensorExecutor::PacketAccess>::run(evalToTmp, m_device); + internal::TensorExecutor::run(evalToTmp, m_device); m_impl.cleanup(); return true; } diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorForwardDeclarations.h b/unsupported/Eigen/CXX11/src/Tensor/TensorForwardDeclarations.h index 7df8d1453..b3bc16bc4 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorForwardDeclarations.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorForwardDeclarations.h @@ -51,8 +51,27 @@ template class TensorForcedEvalOp; template class TensorDevice; template struct TensorEvaluator; +class DefaultDevice; +class ThreadPoolDevice; +class GpuDevice; + namespace internal { -template class TensorExecutor; + +template +struct IsVectorizable { + static const bool value = TensorEvaluator::PacketAccess; +}; + +template +struct IsVectorizable { + static const bool value = TensorEvaluator::PacketAccess && + TensorEvaluator::IsAligned; +}; + +template ::value> +class TensorExecutor; + } // end namespace internal } // end namespace Eigen diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorLayoutSwap.h b/unsupported/Eigen/CXX11/src/Tensor/TensorLayoutSwap.h index 054ecf7b5..ee66ae192 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorLayoutSwap.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorLayoutSwap.h @@ -90,7 +90,7 @@ class TensorLayoutSwapOp : public TensorBase, WriteA { typedef TensorAssignOp Assign; Assign assign(*this, other); - internal::TensorExecutor::run(assign, DefaultDevice()); + internal::TensorExecutor::run(assign, DefaultDevice()); return *this; } @@ -100,7 +100,7 @@ class TensorLayoutSwapOp : public TensorBase, WriteA { typedef TensorAssignOp Assign; Assign assign(*this, other); - internal::TensorExecutor::run(assign, DefaultDevice()); + internal::TensorExecutor::run(assign, DefaultDevice()); return *this; } diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h b/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h index fa1e6931c..15e004ee9 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h @@ -78,7 +78,7 @@ class TensorReshapingOp : public TensorBase Assign; Assign assign(*this, other); - internal::TensorExecutor::run(assign, DefaultDevice()); + internal::TensorExecutor::run(assign, DefaultDevice()); return *this; } @@ -88,7 +88,7 @@ class TensorReshapingOp : public TensorBase Assign; Assign assign(*this, other); - internal::TensorExecutor::run(assign, DefaultDevice()); + internal::TensorExecutor::run(assign, DefaultDevice()); return *this; } @@ -262,7 +262,7 @@ class TensorSlicingOp : public TensorBase Assign; Assign assign(*this, other); - internal::TensorExecutor::run(assign, DefaultDevice()); + internal::TensorExecutor::run(assign, DefaultDevice()); return *this; } @@ -271,7 +271,7 @@ class TensorSlicingOp : public TensorBase Assign; Assign assign(*this, other); - internal::TensorExecutor::run(assign, DefaultDevice()); + internal::TensorExecutor::run(assign, DefaultDevice()); return *this; } @@ -411,7 +411,7 @@ struct TensorEvaluator, Devi { const int packetSize = internal::unpacket_traits::size; EIGEN_STATIC_ASSERT(packetSize > 1, YOU_MADE_A_PROGRAMMING_MISTAKE) - eigen_assert(index+packetSize-1 < dimensions().TotalSize()); + eigen_assert(index+packetSize-1 < array_prod(dimensions())); Index inputIndices[] = {0, 0}; Index indices[] = {index, index + packetSize - 1}; diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReverse.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReverse.h index 16bef2ad3..52f95b2a2 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReverse.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReverse.h @@ -80,7 +80,7 @@ class TensorReverseOp : public TensorBase Assign; Assign assign(*this, other); - internal::TensorExecutor::run(assign, DefaultDevice()); + internal::TensorExecutor::run(assign, DefaultDevice()); return *this; } @@ -90,7 +90,7 @@ class TensorReverseOp : public TensorBase Assign; Assign assign(*this, other); - internal::TensorExecutor::run(assign, DefaultDevice()); + internal::TensorExecutor::run(assign, DefaultDevice()); return *this; } diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h b/unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h index 1012ecd69..02f73dd37 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorShuffling.h @@ -78,7 +78,7 @@ class TensorShufflingOp : public TensorBase { typedef TensorAssignOp Assign; Assign assign(*this, other); - internal::TensorExecutor::run(assign, DefaultDevice()); + internal::TensorExecutor::run(assign, DefaultDevice()); return *this; } @@ -88,7 +88,7 @@ class TensorShufflingOp : public TensorBase { typedef TensorAssignOp Assign; Assign assign(*this, other); - internal::TensorExecutor::run(assign, DefaultDevice()); + internal::TensorExecutor::run(assign, DefaultDevice()); return *this; } diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorStriding.h b/unsupported/Eigen/CXX11/src/Tensor/TensorStriding.h index 00cb8e373..dd913fbae 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorStriding.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorStriding.h @@ -78,7 +78,7 @@ class TensorStridingOp : public TensorBase > { typedef TensorAssignOp Assign; Assign assign(*this, other); - internal::TensorExecutor::run(assign, DefaultDevice()); + internal::TensorExecutor::run(assign, DefaultDevice()); return *this; } @@ -88,7 +88,7 @@ class TensorStridingOp : public TensorBase > { typedef TensorAssignOp Assign; Assign assign(*this, other); - internal::TensorExecutor::run(assign, DefaultDevice()); + internal::TensorExecutor::run(assign, DefaultDevice()); return *this; } -- cgit v1.2.3