Correctly set CAFFE2_DISABLE_NUMA when USE_NUMA=OFF in cmake (#10061)

Summary:
previously https://github.com/pytorch/pytorch/blob/master/caffe2/core/numa.cc still gets compiled even when USE_NUMA=OFF
Pull Request resolved: https://github.com/pytorch/pytorch/pull/10061

Reviewed By: houseroad

Differential Revision: D9081385

Pulled By: bddppq

fbshipit-source-id: ad28b647e0033727839770b1da0fba341b1b7787
This commit is contained in:
Junjie Bai 2018-07-31 10:47:45 -07:00 committed by Facebook Github Bot
parent cba03e2ebe
commit f779202711

View File

@ -83,22 +83,26 @@ endif()
cmake_pop_check_state()
# ---[ Check for NUMA support
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_FLAGS "-std=c++11")
CHECK_CXX_SOURCE_COMPILES(
if (USE_NUMA)
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_FLAGS "-std=c++11")
CHECK_CXX_SOURCE_COMPILES(
"#include <numa.h>
#include <numaif.h>
int main(int argc, char** argv) {
}" CAFFE2_IS_NUMA_AVAILABLE)
if (CAFFE2_IS_NUMA_AVAILABLE)
message(STATUS "NUMA is available")
if (CAFFE2_IS_NUMA_AVAILABLE)
message(STATUS "NUMA is available")
else()
message(STATUS "NUMA is not available")
set(CAFFE2_DISABLE_NUMA 1)
endif()
cmake_pop_check_state()
else()
message(STATUS "NUMA is not available")
message(STATUS "NUMA is disabled")
set(CAFFE2_DISABLE_NUMA 1)
endif()
cmake_pop_check_state()
# ---[ Check if we want to turn off deprecated warning due to glog.
# Note(jiayq): on ubuntu 14.04, the default glog install uses ext/hash_set that