You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/11/03 07:01:41 UTC

[GitHub] XiaotaoChen commented on a change in pull request #12926: parallelize NDArray::Copy when data size is large

XiaotaoChen 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_r230547085
 
 

 ##########
 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:
   yeh, you are right. we can fetch data size by `from` or `to`. We need to check if the sizes of `from` and `to` are equal before calling `OMPCopy`. So i don't want to re-fetch this parameter, just pass this parameter from `Copy` function in `ndarray/ndarray_function.cc`. 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services