TaoLv commented on a change in pull request #12926: parallelize
NDArray::Copy<cpu, cpu> when data size is large
URL: https://github.com/apache/incubator-mxnet/pull/12926#discussion_r230435224
##########
File path: src/common/utils.h
##########
@@ -713,6 +713,20 @@ inline void EmplaceBackZeros(const NDArrayStorageType
stype, const TShape &shape
}
}
+
+/*!
+ * \brief parallelize copy by OpenMP.
+ */
+template<typename DType>
+void OMPCopy(const TBlob &from, TBlob *to, const index_t size) {
+ DType* dst_dptr = to->dptr<DType>();
+ const DType* src_dptr = from.dptr<DType>();
+ #pragma omp parallel for
num_threads(engine::OpenMP::Get()->GetRecommendedOMPThreadCount())
+ for (index_t i = 0; i < size; ++i) {
+ dst_dptr[i] = src_dptr[i];
Review comment:
may exceed the boundary of src and dst? Do we really need parameter `size`
here?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services