aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Eugene Zhulenev <ezhulenev@google.com>2019-10-29 11:25:24 -0700
committerGravatar Eugene Zhulenev <ezhulenev@google.com>2019-10-29 11:25:24 -0700
commite7ed4bd388be80db9cc5689e623fbdd9e5cfdf7b (patch)
treeeeb905e8f418f9d7f5bbde7ebeced53111bc1c89
parentfbc0a9a3ec19bbe9106754ca4e4d3f382ce50530 (diff)
Remove internal::smart_copy and replace with std::copy
-rw-r--r--Eigen/src/Core/DenseStorage.h6
-rw-r--r--Eigen/src/Core/util/Memory.h25
-rw-r--r--Eigen/src/SparseCore/CompressedStorage.h20
-rw-r--r--Eigen/src/SparseCore/SparseBlock.h16
-rw-r--r--Eigen/src/SparseCore/SparseMatrix.h10
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h2
-rw-r--r--unsupported/Eigen/CXX11/src/util/CXX11Meta.h4
7 files changed, 28 insertions, 55 deletions
diff --git a/Eigen/src/Core/DenseStorage.h b/Eigen/src/Core/DenseStorage.h
index a8bb8a624..e8a7f65ed 100644
--- a/Eigen/src/Core/DenseStorage.h
+++ b/Eigen/src/Core/DenseStorage.h
@@ -369,7 +369,7 @@ template<typename T, int _Options> class DenseStorage<T, Dynamic, Dynamic, Dynam
, m_cols(other.m_cols)
{
EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = m_rows*m_cols)
- internal::smart_copy(other.m_data, other.m_data+other.m_rows*other.m_cols, m_data);
+ std::copy(other.m_data, other.m_data+other.m_rows*other.m_cols, m_data);
}
EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)
{
@@ -452,7 +452,7 @@ template<typename T, int _Rows, int _Options> class DenseStorage<T, Dynamic, _Ro
, m_cols(other.m_cols)
{
EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = m_cols*_Rows)
- internal::smart_copy(other.m_data, other.m_data+_Rows*m_cols, m_data);
+ std::copy(other.m_data, other.m_data+_Rows*m_cols, m_data);
}
EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)
{
@@ -528,7 +528,7 @@ template<typename T, int _Cols, int _Options> class DenseStorage<T, Dynamic, Dyn
, m_rows(other.m_rows)
{
EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN(Index size = m_rows*_Cols)
- internal::smart_copy(other.m_data, other.m_data+other.m_rows*_Cols, m_data);
+ std::copy(other.m_data, other.m_data+other.m_rows*_Cols, m_data);
}
EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage& other)
{
diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h
index 1b12544d2..d0622d0b4 100644
--- a/Eigen/src/Core/util/Memory.h
+++ b/Eigen/src/Core/util/Memory.h
@@ -507,31 +507,6 @@ inline Index first_multiple(Index size, Index base)
return ((size+base-1)/base)*base;
}
-// std::copy is much slower than memcpy, so let's introduce a smart_copy which
-// use memcpy on trivial types, i.e., on types that does not require an initialization ctor.
-template<typename T, bool UseMemcpy> struct smart_copy_helper;
-
-template<typename T> EIGEN_DEVICE_FUNC void smart_copy(const T* start, const T* end, T* target)
-{
- smart_copy_helper<T,!NumTraits<T>::RequireInitialization>::run(start, end, target);
-}
-
-template<typename T> struct smart_copy_helper<T,true> {
- EIGEN_DEVICE_FUNC static inline void run(const T* start, const T* end, T* target)
- {
- IntPtr size = IntPtr(end)-IntPtr(start);
- if(size==0) return;
- eigen_internal_assert(start!=0 && end!=0 && target!=0);
- EIGEN_USING_STD(memcpy)
- memcpy(target, start, size);
- }
-};
-
-template<typename T> struct smart_copy_helper<T,false> {
- EIGEN_DEVICE_FUNC static inline void run(const T* start, const T* end, T* target)
- { std::copy(start, end, target); }
-};
-
// intelligent memmove. falls back to std::memmove for POD types, uses std::copy otherwise.
template<typename T, bool UseMemmove> struct smart_memmove_helper;
diff --git a/Eigen/src/SparseCore/CompressedStorage.h b/Eigen/src/SparseCore/CompressedStorage.h
index acd986fab..5c69b4b6a 100644
--- a/Eigen/src/SparseCore/CompressedStorage.h
+++ b/Eigen/src/SparseCore/CompressedStorage.h
@@ -53,8 +53,8 @@ class CompressedStorage
resize(other.size());
if(other.size()>0)
{
- internal::smart_copy(other.m_values, other.m_values + m_size, m_values);
- internal::smart_copy(other.m_indices, other.m_indices + m_size, m_indices);
+ std::copy(other.m_values, other.m_values + m_size, m_values);
+ std::copy(other.m_indices, other.m_indices + m_size, m_indices);
}
return *this;
}
@@ -183,14 +183,14 @@ class CompressedStorage
internal::scoped_array<StorageIndex> newIndices(m_allocatedSize);
// copy first chunk
- internal::smart_copy(m_values, m_values +id, newValues.ptr());
- internal::smart_copy(m_indices, m_indices+id, newIndices.ptr());
+ std::copy(m_values, m_values +id, newValues.ptr());
+ std::copy(m_indices, m_indices+id, newIndices.ptr());
// copy the rest
if(m_size>id)
{
- internal::smart_copy(m_values +id, m_values +m_size, newValues.ptr() +id+1);
- internal::smart_copy(m_indices+id, m_indices+m_size, newIndices.ptr()+id+1);
+ std::copy(m_values +id, m_values +m_size, newValues.ptr() +id+1);
+ std::copy(m_indices+id, m_indices+m_size, newIndices.ptr()+id+1);
}
std::swap(m_values,newValues.ptr());
std::swap(m_indices,newIndices.ptr());
@@ -218,8 +218,8 @@ class CompressedStorage
}
else
{
- internal::smart_copy(m_values+from, m_values+from+chunkSize, m_values+to);
- internal::smart_copy(m_indices+from, m_indices+from+chunkSize, m_indices+to);
+ std::copy(m_values+from, m_values+from+chunkSize, m_values+to);
+ std::copy(m_indices+from, m_indices+from+chunkSize, m_indices+to);
}
}
@@ -251,8 +251,8 @@ class CompressedStorage
internal::scoped_array<StorageIndex> newIndices(size);
Index copySize = (std::min)(size, m_size);
if (copySize>0) {
- internal::smart_copy(m_values, m_values+copySize, newValues.ptr());
- internal::smart_copy(m_indices, m_indices+copySize, newIndices.ptr());
+ std::copy(m_values, m_values+copySize, newValues.ptr());
+ std::copy(m_indices, m_indices+copySize, newIndices.ptr());
}
std::swap(m_values,newValues.ptr());
std::swap(m_indices,newIndices.ptr());
diff --git a/Eigen/src/SparseCore/SparseBlock.h b/Eigen/src/SparseCore/SparseBlock.h
index d4535d866..e2ea5494f 100644
--- a/Eigen/src/SparseCore/SparseBlock.h
+++ b/Eigen/src/SparseCore/SparseBlock.h
@@ -147,14 +147,14 @@ public:
// realloc manually to reduce copies
typename SparseMatrixType::Storage newdata(m_matrix.data().allocatedSize() - block_size + nnz);
- internal::smart_copy(m_matrix.valuePtr(), m_matrix.valuePtr() + start, newdata.valuePtr());
- internal::smart_copy(m_matrix.innerIndexPtr(), m_matrix.innerIndexPtr() + start, newdata.indexPtr());
+ std::copy(m_matrix.valuePtr(), m_matrix.valuePtr() + start, newdata.valuePtr());
+ std::copy(m_matrix.innerIndexPtr(), m_matrix.innerIndexPtr() + start, newdata.indexPtr());
- internal::smart_copy(tmp.valuePtr() + tmp_start, tmp.valuePtr() + tmp_start + nnz, newdata.valuePtr() + start);
- internal::smart_copy(tmp.innerIndexPtr() + tmp_start, tmp.innerIndexPtr() + tmp_start + nnz, newdata.indexPtr() + start);
+ std::copy(tmp.valuePtr() + tmp_start, tmp.valuePtr() + tmp_start + nnz, newdata.valuePtr() + start);
+ std::copy(tmp.innerIndexPtr() + tmp_start, tmp.innerIndexPtr() + tmp_start + nnz, newdata.indexPtr() + start);
- internal::smart_copy(matrix.valuePtr()+end, matrix.valuePtr()+end + tail_size, newdata.valuePtr()+start+nnz);
- internal::smart_copy(matrix.innerIndexPtr()+end, matrix.innerIndexPtr()+end + tail_size, newdata.indexPtr()+start+nnz);
+ std::copy(matrix.valuePtr()+end, matrix.valuePtr()+end + tail_size, newdata.valuePtr()+start+nnz);
+ std::copy(matrix.innerIndexPtr()+end, matrix.innerIndexPtr()+end + tail_size, newdata.indexPtr()+start+nnz);
newdata.resize(m_matrix.outerIndexPtr()[m_matrix.outerSize()] - block_size + nnz);
@@ -175,8 +175,8 @@ public:
update_trailing_pointers = true;
}
- internal::smart_copy(tmp.valuePtr() + tmp_start, tmp.valuePtr() + tmp_start + nnz, matrix.valuePtr() + start);
- internal::smart_copy(tmp.innerIndexPtr() + tmp_start, tmp.innerIndexPtr() + tmp_start + nnz, matrix.innerIndexPtr() + start);
+ std::copy(tmp.valuePtr() + tmp_start, tmp.valuePtr() + tmp_start + nnz, matrix.valuePtr() + start);
+ std::copy(tmp.innerIndexPtr() + tmp_start, tmp.innerIndexPtr() + tmp_start + nnz, matrix.innerIndexPtr() + start);
}
// update outer index pointers and innerNonZeros
diff --git a/Eigen/src/SparseCore/SparseMatrix.h b/Eigen/src/SparseCore/SparseMatrix.h
index e0910a2cb..2bd4cee84 100644
--- a/Eigen/src/SparseCore/SparseMatrix.h
+++ b/Eigen/src/SparseCore/SparseMatrix.h
@@ -767,7 +767,7 @@ class SparseMatrix
initAssignment(other);
if(other.isCompressed())
{
- internal::smart_copy(other.m_outerIndex, other.m_outerIndex + m_outerSize + 1, m_outerIndex);
+ std::copy(other.m_outerIndex, other.m_outerIndex + m_outerSize + 1, m_outerIndex);
m_data = other.m_data;
}
else
@@ -982,8 +982,8 @@ protected:
{
Index i = newEntries[k].i;
Index p = newEntries[k].p;
- internal::smart_copy(m_data.valuePtr()+prev_p, m_data.valuePtr()+p, newData.valuePtr()+prev_p+k);
- internal::smart_copy(m_data.indexPtr()+prev_p, m_data.indexPtr()+p, newData.indexPtr()+prev_p+k);
+ std::copy(m_data.valuePtr()+prev_p, m_data.valuePtr()+p, newData.valuePtr()+prev_p+k);
+ std::copy(m_data.indexPtr()+prev_p, m_data.indexPtr()+p, newData.indexPtr()+prev_p+k);
for(Index j=prev_i;j<i;++j)
m_outerIndex[j+1] += k;
if(!isComp)
@@ -995,8 +995,8 @@ protected:
assignFunc.assignCoeff(newData.value(p+k), diaEval.coeff(i));
}
{
- internal::smart_copy(m_data.valuePtr()+prev_p, m_data.valuePtr()+m_data.size(), newData.valuePtr()+prev_p+n_entries);
- internal::smart_copy(m_data.indexPtr()+prev_p, m_data.indexPtr()+m_data.size(), newData.indexPtr()+prev_p+n_entries);
+ std::copy(m_data.valuePtr()+prev_p, m_data.valuePtr()+m_data.size(), newData.valuePtr()+prev_p+n_entries);
+ std::copy(m_data.indexPtr()+prev_p, m_data.indexPtr()+m_data.size(), newData.indexPtr()+prev_p+n_entries);
for(Index j=prev_i+1;j<=m_outerSize;++j)
m_outerIndex[j] += n_entries;
}
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h b/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h
index e6a666f78..1f0cd9638 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h
@@ -96,7 +96,7 @@ class TensorStorage<T, DSizes<IndexType, NumIndices_>, Options_>
: m_data(internal::conditional_aligned_new_auto<T,(Options_&DontAlign)==0>(internal::array_prod(other.m_dimensions)))
, m_dimensions(other.m_dimensions)
{
- internal::smart_copy(other.m_data, other.m_data+internal::array_prod(other.m_dimensions), m_data);
+ std::copy(other.m_data, other.m_data+internal::array_prod(other.m_dimensions), m_data);
}
EIGEN_DEVICE_FUNC Self& operator=(const Self& other)
{
diff --git a/unsupported/Eigen/CXX11/src/util/CXX11Meta.h b/unsupported/Eigen/CXX11/src/util/CXX11Meta.h
index 1c770a32e..014f5116a 100644
--- a/unsupported/Eigen/CXX11/src/util/CXX11Meta.h
+++ b/unsupported/Eigen/CXX11/src/util/CXX11Meta.h
@@ -67,13 +67,11 @@ class array : public std::array<T, N> {
: Base{{v1, v2, v3, v4, v5, v6, v7, v8}} {
EIGEN_STATIC_ASSERT(N == 8, YOU_MADE_A_PROGRAMMING_MISTAKE);
}
-#if EIGEN_HAS_VARIADIC_TEMPLATES
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
array(std::initializer_list<T> l) {
eigen_assert(l.size() == N);
- internal::smart_copy(l.begin(), l.end(), &this->front());
+ std::copy(l.begin(), l.end(), &this->front());
}
-#endif
};
namespace internal {