From 87aee5fda1d42f5e6fdbce3c5c91f28e291147cd Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 5 Nov 2013 15:40:58 +0100 Subject: Allow calling attributes of dynamic size objects from device --- Eigen/src/Core/DenseStorage.h | 88 ++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 43 deletions(-) (limited to 'Eigen/src/Core/DenseStorage.h') diff --git a/Eigen/src/Core/DenseStorage.h b/Eigen/src/Core/DenseStorage.h index af14832cf..b9dd75ade 100644 --- a/Eigen/src/Core/DenseStorage.h +++ b/Eigen/src/Core/DenseStorage.h @@ -24,7 +24,9 @@ namespace internal { struct constructor_without_unaligned_array_assert {}; -template void check_static_allocation_size() +template +EIGEN_DEVICE_FUNC +void check_static_allocation_size() { // if EIGEN_STACK_ALLOCATION_LIMIT is defined to 0, then no limit #if EIGEN_STACK_ALLOCATION_LIMIT @@ -152,18 +154,18 @@ template class DenseSt template class DenseStorage { public: - DenseStorage() {} - DenseStorage(internal::constructor_without_unaligned_array_assert) {} - DenseStorage(const DenseStorage&) {} - DenseStorage& operator=(const DenseStorage&) { return *this; } - DenseStorage(DenseIndex,DenseIndex,DenseIndex) {} - void swap(DenseStorage& ) {} - static DenseIndex rows(void) {return _Rows;} - static DenseIndex cols(void) {return _Cols;} - void conservativeResize(DenseIndex,DenseIndex,DenseIndex) {} - void resize(DenseIndex,DenseIndex,DenseIndex) {} - const T *data() const { return 0; } - T *data() { return 0; } + EIGEN_DEVICE_FUNC DenseStorage() {} + EIGEN_DEVICE_FUNC DenseStorage(internal::constructor_without_unaligned_array_assert) {} + EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage&) {} + EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage&) { return *this; } + EIGEN_DEVICE_FUNC DenseStorage(DenseIndex,DenseIndex,DenseIndex) {} + EIGEN_DEVICE_FUNC void swap(DenseStorage& ) {} + EIGEN_DEVICE_FUNC static DenseIndex rows(void) {return _Rows;} + EIGEN_DEVICE_FUNC static DenseIndex cols(void) {return _Cols;} + EIGEN_DEVICE_FUNC void conservativeResize(DenseIndex,DenseIndex,DenseIndex) {} + EIGEN_DEVICE_FUNC void resize(DenseIndex,DenseIndex,DenseIndex) {} + EIGEN_DEVICE_FUNC const T *data() const { return 0; } + EIGEN_DEVICE_FUNC T *data() { return 0; } }; // more specializations for null matrices; these are necessary to resolve ambiguities @@ -183,7 +185,7 @@ template class DenseStorage class DenseStorage class DenseStorage m_data; DenseIndex m_rows; public: - DenseStorage() : m_rows(0) {} + EIGEN_DEVICE_FUNC DenseStorage() : m_rows(0) {} DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0) {} DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_rows(other.m_rows) {} @@ -229,12 +231,12 @@ template class DenseStorage class DenseStorage m_data; DenseIndex m_cols; public: - DenseStorage() : m_cols(0) {} + EIGEN_DEVICE_FUNC DenseStorage() : m_cols(0) {} DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(internal::constructor_without_unaligned_array_assert()), m_cols(0) {} DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_cols(other.m_cols) {} @@ -258,12 +260,12 @@ template class DenseStorage class DenseStorage class DenseStorage(m_data, m_rows*m_cols); } void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); } - DenseIndex rows(void) const {return m_rows;} - DenseIndex cols(void) const {return m_cols;} + EIGEN_DEVICE_FUNC DenseIndex rows(void) const {return m_rows;} + EIGEN_DEVICE_FUNC DenseIndex cols(void) const {return m_cols;} void conservativeResize(DenseIndex size, DenseIndex nbRows, DenseIndex nbCols) { m_data = internal::conditional_aligned_realloc_new_auto(m_data, size, m_rows*m_cols); @@ -337,8 +339,8 @@ template class DenseStorage class DenseStorage(size)), m_cols(nbCols) { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN } @@ -383,8 +385,8 @@ template class DenseStorage(m_data, _Rows*m_cols); } void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); } - static DenseIndex rows(void) {return _Rows;} - DenseIndex cols(void) const {return m_cols;} + EIGEN_DEVICE_FUNC static DenseIndex rows(void) {return _Rows;} + EIGEN_DEVICE_FUNC DenseIndex cols(void) const {return m_cols;} void conservativeResize(DenseIndex size, DenseIndex, DenseIndex nbCols) { m_data = internal::conditional_aligned_realloc_new_auto(m_data, size, _Rows*m_cols); @@ -403,8 +405,8 @@ template class DenseStorage class DenseStorage(size)), m_rows(nbRows) { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN } @@ -449,8 +451,8 @@ template class DenseStorage(m_data, _Cols*m_rows); } void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); } - DenseIndex rows(void) const {return m_rows;} - static DenseIndex cols(void) {return _Cols;} + EIGEN_DEVICE_FUNC DenseIndex rows(void) const {return m_rows;} + EIGEN_DEVICE_FUNC static DenseIndex cols(void) {return _Cols;} void conservativeResize(DenseIndex size, DenseIndex nbRows, DenseIndex) { m_data = internal::conditional_aligned_realloc_new_auto(m_data, size, m_rows*_Cols); @@ -469,8 +471,8 @@ template class DenseStorage