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/09/05 12:07:47 UTC

[GitHub] azai91 closed pull request #11118: [MXNET-431] Get physical cores

azai91 closed pull request #11118: [MXNET-431] Get physical cores
URL: https://github.com/apache/incubator-mxnet/pull/11118
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/.gitmodules b/.gitmodules
index 9aeb1c75498..429d7297e2d 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -26,3 +26,6 @@
 [submodule "3rdparty/tvm"]
 	path = 3rdparty/tvm
 	url = https://github.com/dmlc/tvm
+[submodule "3rdparty/cpuinfo"]
+	path = 3rdparty/cpuinfo
+	url = https://github.com/pytorch/cpuinfo.git
diff --git a/3rdparty/cpuinfo b/3rdparty/cpuinfo
new file mode 160000
index 00000000000..1e6c8c99d27
--- /dev/null
+++ b/3rdparty/cpuinfo
@@ -0,0 +1 @@
+Subproject commit 1e6c8c99d27f2b5eb9d2e6231055c6a4115b85e5
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4fe900d4694..ba2f497f1ba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -266,6 +266,7 @@ include_directories("3rdparty/tvm/nnvm/include")
 include_directories("3rdparty/tvm/include")
 include_directories("3rdparty/dmlc-core/include")
 include_directories("3rdparty/dlpack/include")
+include_directories("3rdparty/cpuinfo/include")
 
 # commented out until PR goes through
 #if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dlpack)
@@ -419,6 +420,13 @@ endif()
 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/mshadow/cmake)
   add_subdirectory("3rdparty/mshadow")
 endif()
+
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cpuinfo/cmake)
+  add_subdirectory(3rdparty/cpuinfo)
+  set(CPUINFO_LIB cpuinfo)
+  list(APPEND mxnet_LINKER_LIBS ${CPUINFO_LIB})
+endif()
+
 FILE(GLOB_RECURSE SOURCE "src/*.cc" "src/*.h" "include/*.h")
 FILE(GLOB_RECURSE CUDA "src/*.cu" "src/*.cuh")
 
diff --git a/LICENSE b/LICENSE
index a8b57e58376..fd02dec6d2c 100644
--- a/LICENSE
+++ b/LICENSE
@@ -511,6 +511,34 @@
 
     =======================================================================================
 
+    11. cpuinfo
+    For details, see, 3rdparty/cpuinfo/LICENSE
+
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+    =======================================================================================
+
     11. ONNX Export module
     For details, see, python/mxnet/contrib/onnx/_export/LICENSE
 
diff --git a/src/engine/openmp.cc b/src/engine/openmp.cc
index 8fe3939892d..4624fac3e4e 100644
--- a/src/engine/openmp.cc
+++ b/src/engine/openmp.cc
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+#include <cpuinfo.h>
 #include <dmlc/omp.h>
 #include <dmlc/base.h>
 #include <dmlc/parameter.h>
@@ -48,7 +49,11 @@ OpenMP::OpenMP()
     if (!omp_num_threads_set_in_environment_) {
       omp_thread_max_ = omp_get_num_procs();
 #ifdef ARCH_IS_INTEL_X86
-      omp_thread_max_ >>= 1;
+      if (cpuinfo_initialize()) {
+        omp_thread_max_ = cpuinfo_get_cores_count();
+      } else {
+        omp_thread_max_ >>= 1;
+      }
 #endif
       omp_set_num_threads(omp_thread_max_);
     } else {


 

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