From 734b61ef5b6856f8115cfbffc02b47cba41b313e Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Mon, 9 Dec 2019 06:26:18 +0000 Subject: [PATCH 1/2] Replace mxnet_option macro with standard CMAKE_DEPENDENT_OPTION --- CMakeLists.txt | 66 +++++++++++++++++++------------------ cmake/Modules/FindMKL.cmake | 10 +++--- cmake/Utils.cmake | 41 ----------------------- 3 files changed, 39 insertions(+), 78 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a8a3d5c512e..9725dade9275 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,39 +18,41 @@ endif() include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Utils.cmake) +include(CMakeDependentOption) #Some things have order. This must be put in front alone -mxnet_option(USE_CUDA "Build with CUDA support" ON) -mxnet_option(USE_OLDCMAKECUDA "Build with old cmake cuda" OFF) -mxnet_option(USE_NCCL "Use NVidia NCCL with CUDA" OFF) -mxnet_option(USE_OPENCV "Build with OpenCV support" ON) -mxnet_option(USE_OPENMP "Build with Openmp support" ON) -mxnet_option(USE_CUDNN "Build with cudnn support" ON) # one could set CUDNN_ROOT for search path -mxnet_option(USE_SSE "Build with x86 SSE instruction support" ON IF NOT ARM) -mxnet_option(USE_F16C "Build with x86 F16C instruction support" ON) # autodetects support if ON -mxnet_option(USE_LAPACK "Build with lapack support" ON) -mxnet_option(USE_MKL_IF_AVAILABLE "Use MKL if found" ON) -mxnet_option(USE_MKLDNN "Build with MKL-DNN support" ON IF USE_MKL_IF_AVAILABLE AND (NOT APPLE) AND (NOT MSVC) AND (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64") AND (NOT CMAKE_CROSSCOMPILING)) -mxnet_option(USE_OPERATOR_TUNING "Enable auto-tuning of operators" ON IF NOT MSVC) -mxnet_option(USE_GPERFTOOLS "Build with GPerfTools support" OFF) -mxnet_option(USE_JEMALLOC "Build with Jemalloc support" ON) -mxnet_option(USE_DIST_KVSTORE "Build with DIST_KVSTORE support" OFF) -mxnet_option(USE_PLUGINS_WARPCTC "Use WARPCTC Plugins" OFF) -mxnet_option(USE_PLUGIN_CAFFE "Use Caffe Plugin" OFF) -mxnet_option(USE_CPP_PACKAGE "Build C++ Package" OFF) -mxnet_option(USE_MXNET_LIB_NAMING "Use MXNet library naming conventions." ON) -mxnet_option(USE_GPROF "Compile with gprof (profiling) flag" OFF) -mxnet_option(USE_CXX14_IF_AVAILABLE "Build with C++14 if the compiler supports it" OFF) -mxnet_option(USE_VTUNE "Enable use of Intel Amplifier XE (VTune)" OFF) # one could set VTUNE_ROOT for search path -mxnet_option(USE_TVM_OP "Enable use of TVM operator build system." OFF) -mxnet_option(ENABLE_CUDA_RTC "Build with CUDA runtime compilation support" ON) -mxnet_option(BUILD_CPP_EXAMPLES "Build cpp examples" ON) -mxnet_option(INSTALL_EXAMPLES "Install the example source files." OFF) -mxnet_option(USE_SIGNAL_HANDLER "Print stack traces on segfaults." ON) -mxnet_option(USE_TENSORRT "Enable inference optimization with TensorRT." OFF) -mxnet_option(USE_ASAN "Enable Clang/GCC ASAN sanitizers." OFF) -mxnet_option(ENABLE_TESTCOVERAGE "Enable compilation with test coverage metric output" OFF) -mxnet_option(USE_INT64_TENSOR_SIZE "Use int64_t to represent the total number of elements in a tensor" OFF) -mxnet_option(BUILD_CYTHON_MODULES "Build cython modules." OFF) +option(USE_CUDA "Build with CUDA support" ON) +option(USE_OLDCMAKECUDA "Build with old cmake cuda" OFF) +option(USE_NCCL "Use NVidia NCCL with CUDA" OFF) +option(USE_OPENCV "Build with OpenCV support" ON) +option(USE_OPENMP "Build with Openmp support" ON) +cmake_dependent_option(USE_CUDNN "Build with cudnn support" ON "USE_CUDA" OFF) # one could set CUDNN_ROOT for search path +cmake_dependent_option(USE_SSE "Build with x86 SSE instruction support" ON "NOT ARM" OFF) +option(USE_F16C "Build with x86 F16C instruction support" ON) # autodetects support if ON +option(USE_LAPACK "Build with lapack support" ON) +option(USE_MKL_IF_AVAILABLE "Use MKL if found" ON) +cmake_dependent_option(USE_MKLDNN "Build with MKL-DNN support" ON + "USE_MKL_IF_AVAILABLE;NOT APPLE;NOT MSVC;CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL \"x86_64\";NOT CMAKE_CROSSCOMPILING" OFF) +cmake_dependent_option(USE_OPERATOR_TUNING "Enable auto-tuning of operators" ON "NOT MSVC" OFF) +option(USE_GPERFTOOLS "Build with GPerfTools support" OFF) +option(USE_JEMALLOC "Build with Jemalloc support" ON) +option(USE_DIST_KVSTORE "Build with DIST_KVSTORE support" OFF) +option(USE_PLUGINS_WARPCTC "Use WARPCTC Plugins" OFF) +option(USE_PLUGIN_CAFFE "Use Caffe Plugin" OFF) +option(USE_CPP_PACKAGE "Build C++ Package" OFF) +option(USE_MXNET_LIB_NAMING "Use MXNet library naming conventions." ON) +option(USE_GPROF "Compile with gprof (profiling) flag" OFF) +option(USE_CXX14_IF_AVAILABLE "Build with C++14 if the compiler supports it" OFF) +option(USE_VTUNE "Enable use of Intel Amplifier XE (VTune)" OFF) # one could set VTUNE_ROOT for search path +option(USE_TVM_OP "Enable use of TVM operator build system." OFF) +option(ENABLE_CUDA_RTC "Build with CUDA runtime compilation support" ON) +option(BUILD_CPP_EXAMPLES "Build cpp examples" ON) +option(INSTALL_EXAMPLES "Install the example source files." OFF) +option(USE_SIGNAL_HANDLER "Print stack traces on segfaults." ON) +option(USE_TENSORRT "Enable inference optimization with TensorRT." OFF) +option(USE_ASAN "Enable Clang/GCC ASAN sanitizers." OFF) +option(ENABLE_TESTCOVERAGE "Enable compilation with test coverage metric output" OFF) +option(USE_INT64_TENSOR_SIZE "Use int64_t to represent the total number of elements in a tensor" OFF) +option(BUILD_CYTHON_MODULES "Build cython modules." OFF) message(STATUS "CMAKE_CROSSCOMPILING ${CMAKE_CROSSCOMPILING}") message(STATUS "CMAKE_HOST_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR}") diff --git a/cmake/Modules/FindMKL.cmake b/cmake/Modules/FindMKL.cmake index 51fca23c1161..51eff8fe09aa 100644 --- a/cmake/Modules/FindMKL.cmake +++ b/cmake/Modules/FindMKL.cmake @@ -45,11 +45,11 @@ set(INTEL_ROOT "/opt/intel" CACHE PATH "Folder contains intel libs") # ---[ Options - mxnet_option(MKL_USE_SINGLE_DYNAMIC_LIBRARY "Use single dynamic library interface" ON) - mxnet_option(MKL_USE_STATIC_LIBS "Use static libraries" OFF IF NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY) - mxnet_option(MKL_MULTI_THREADED "Use multi-threading" ON IF NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY) - mxnet_option(MKL_USE_ILP64 "Use ilp64 data model" OFF) - mxnet_option(MKL_USE_CLUSTER "Use cluster functions" OFF IF CMAKE_SIZEOF_VOID_P EQUAL 4) + option(MKL_USE_SINGLE_DYNAMIC_LIBRARY "Use single dynamic library interface" ON) + cmake_dependent_option(MKL_USE_STATIC_LIBS "Use static libraries" OFF "NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY" OFF) + cmake_dependent_option(MKL_MULTI_THREADED "Use multi-threading" ON "NOT MKL_USE_SINGLE_DYNAMIC_LIBRARY" OFF) + option(MKL_USE_ILP64 "Use ilp64 data model" OFF) + cmake_dependent_option(MKL_USE_CLUSTER "Use cluster functions" OFF "CMAKE_SIZEOF_VOID_P EQUAL 4" OFF) find_path(MKL_ROOT include/mkl.h PATHS $ENV{MKL_ROOT} ${INTEL_ROOT}/mkl DOC "Folder contains MKL") diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake index 6b427db85ec9..294e7cf4cc5c 100644 --- a/cmake/Utils.cmake +++ b/cmake/Utils.cmake @@ -179,47 +179,6 @@ function(mxnet_parse_header_single_define LIBNAME HDR_PATH VARNAME) endif() endfunction() -######################################################################################################## -# An option that the user can select. Can accept condition to control when option is available for user. -# Usage: -# mxnet_option( "doc string" [IF ]) -function(mxnet_option variable description value) - set(__value ${value}) - set(__condition "") - set(__varname "__value") - foreach(arg ${ARGN}) - if(arg STREQUAL "IF" OR arg STREQUAL "if") - set(__varname "__condition") - else() - list(APPEND ${__varname} ${arg}) - endif() - endforeach() - unset(__varname) - if("${__condition}" STREQUAL "") - set(__condition 2 GREATER 1) - endif() - - if(${__condition}) - if("${__value}" MATCHES ";") - if(${__value}) - option(${variable} "${description}" ON) - else() - option(${variable} "${description}" OFF) - endif() - elseif(DEFINED ${__value}) - if(${__value}) - option(${variable} "${description}" ON) - else() - option(${variable} "${description}" OFF) - endif() - else() - option(${variable} "${description}" ${__value}) - endif() - else() - option(${variable} "${description}" OFF) - endif() -endfunction() - ################################################################################################ # Utility macro for comparing two lists. Used for CMake debugging purposes # Usage: From 0fe21bbd827a81fad7ef987d2c147b5710f9072f Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Tue, 10 Dec 2019 08:12:29 +0000 Subject: [PATCH 2/2] Fix MSVC option hiding --- CMakeLists.txt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9725dade9275..6a06ac548190 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,9 +30,16 @@ cmake_dependent_option(USE_SSE "Build with x86 SSE instruction support" ON "NOT option(USE_F16C "Build with x86 F16C instruction support" ON) # autodetects support if ON option(USE_LAPACK "Build with lapack support" ON) option(USE_MKL_IF_AVAILABLE "Use MKL if found" ON) -cmake_dependent_option(USE_MKLDNN "Build with MKL-DNN support" ON - "USE_MKL_IF_AVAILABLE;NOT APPLE;NOT MSVC;CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL \"x86_64\";NOT CMAKE_CROSSCOMPILING" OFF) -cmake_dependent_option(USE_OPERATOR_TUNING "Enable auto-tuning of operators" ON "NOT MSVC" OFF) +if(USE_MKL_IF_AVAILABLE AND (NOT APPLE) AND (NOT MSVC) AND (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64") AND (NOT CMAKE_CROSSCOMPILING)) + option(USE_MKLDNN "Build with MKL-DNN support" ON) +else() + option(USE_MKLDNN "Build with MKL-DNN support" OFF) +endif() +if(NOT MSVC) + option(USE_OPERATOR_TUNING "Enable auto-tuning of operators" ON) +else() + option(USE_OPERATOR_TUNING "Enable auto-tuning of operators" OFF) +endif() option(USE_GPERFTOOLS "Build with GPerfTools support" OFF) option(USE_JEMALLOC "Build with Jemalloc support" ON) option(USE_DIST_KVSTORE "Build with DIST_KVSTORE support" OFF)