diff options
author | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2015-02-27 12:57:13 -0800 |
---|---|---|
committer | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2015-02-27 12:57:13 -0800 |
commit | 2386fc8528fa8f923b0300af6ddc4cd46a178afd (patch) | |
tree | 4ad32d535ce9e8874ac9bd8a6e16ff7da0f02118 /unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h | |
parent | 05089aba75f8bf1ab3d1bfd566decfc08ce729f9 (diff) |
Added support for 32bit index on a per tensor/tensor expression. This enables us to use 32bit indices to evaluate expressions on GPU faster while keeping the ability to use 64 bit indices to manipulate large tensors on CPU in the same binary.
Diffstat (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h')
-rw-r--r-- | unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h b/unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h index a844a4d68..424bb24eb 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h @@ -43,13 +43,24 @@ class compute_tensor_flags enum { ret = packet_access_bit | aligned_bit}; }; +template<bool force32bit> +struct compute_index_type { + typedef DenseIndex type; +}; + +template<> +struct compute_index_type<true> { + typedef int type; +}; + + template<typename Scalar_, std::size_t NumIndices_, int Options_> struct traits<Tensor<Scalar_, NumIndices_, Options_> > { typedef Scalar_ Scalar; typedef Dense StorageKind; - typedef DenseIndex Index; + typedef typename compute_index_type<Options_&Index32Bit>::type Index; static const int NumDimensions = NumIndices_; static const int Layout = Options_ & RowMajor ? RowMajor : ColMajor; enum { @@ -64,7 +75,7 @@ struct traits<TensorFixedSize<Scalar_, Dimensions, Options_> > { typedef Scalar_ Scalar; typedef Dense StorageKind; - typedef DenseIndex Index; + typedef typename compute_index_type<Options_&Index32Bit>::type Index; static const int NumDimensions = array_size<Dimensions>::value; static const int Layout = Options_ & RowMajor ? RowMajor : ColMajor; enum { |