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/10/24 18:02:03 UTC

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

szha 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_r227898781
 
 

 ##########
 File path: src/ndarray/ndarray_function.cc
 ##########
 @@ -32,19 +32,34 @@
 
 namespace mxnet {
 namespace ndarray {
+template<typename DType>
+void OMPCopy(const TBlob &from, TBlob *to, const index_t size) {
+  DType* dst_dptr = to->dptr<DType>();
+  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];
+  }
+}
+
 template<>
 void Copy<cpu, cpu>(const TBlob &from, TBlob *to,
                     Context from_ctx, Context to_ctx,
                     RunContext ctx) {
   MSHADOW_TYPE_SWITCH(to->type_flag_, DType, {
     if (to->type_flag_ == from.type_flag_) {
-        mshadow::Copy(to->FlatTo1D<cpu, DType>(),
-                      from.FlatTo1D<cpu, DType>());
+      index_t copy_block_size = dmlc::GetEnv("MXNET_CPU_PARALLEL_COPY_SIZE", 200000);
 
 Review comment:
   static?

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