From 9dff7d80ac539ed97edb1fff0281ee09643130e6 Mon Sep 17 00:00:00 2001 From: Pedro Larroy Date: Wed, 21 Aug 2019 14:12:49 -0700 Subject: [PATCH] Add option to choose between OMP implementations --- CMakeLists.txt | 11 ++++++----- cmake/cmake_options.yml | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 976c736f5f35..bab0301e53a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,8 +23,7 @@ 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_OPENMP_BUNDLED_LLVM "Build with bundled llvm openmp from 3rdparty" OFF) +mxnet_option(USE_OPENMP "Build with Openmp support" PLATFORM) # OFF | PLATFORM | BUNDLED 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 @@ -434,11 +433,11 @@ if(USE_OPENMP) find_package(OpenMP REQUIRED) # This should build on Windows, but there's some problem and I don't have a Windows box, so # could a Windows user please fix? - if(USE_OPENMP_BUNDLED_LLVM AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/openmp/CMakeLists.txt + if(USE_OPENMP STREQUAL "BUNDLED" AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/openmp/CMakeLists.txt AND SYSTEM_ARCHITECTURE STREQUAL "x86_64" AND NOT MSVC AND NOT CMAKE_CROSSCOMPILING) - message("Using bundlded LLVM OpenMP") + message("Using bundlded LLVM OpenMP from 3rdparty") # Intel/llvm OpenMP: https://github.com/llvm-mirror/openmp set(OPENMP_STANDALONE_BUILD TRUE) set(LIBOMP_ENABLE_SHARED TRUE) @@ -451,7 +450,7 @@ if(USE_OPENMP) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") add_definitions(-DMXNET_USE_OPENMP=1) - else() + elseif(USE_OPENMP STREQUAL "PLATFORM" OR USE_OPENMP STREQUAL "ON") message("Using platform provided OpenMP") if(OPENMP_FOUND) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") @@ -460,6 +459,8 @@ if(USE_OPENMP) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") add_definitions(-DMXNET_USE_OPENMP=1) endif() + else() + message(FATAL_ERROR "USE_OPENMP takes values [PLATFORM, BUNDLED, OFF]") endif() elseif(UNIX AND NOT ANDROID) list(APPEND mxnet_LINKER_LIBS pthread) diff --git a/cmake/cmake_options.yml b/cmake/cmake_options.yml index 81138241dfc6..18bf2fa67922 100644 --- a/cmake/cmake_options.yml +++ b/cmake/cmake_options.yml @@ -20,7 +20,7 @@ USE_CUDA: "OFF" # Build with CUDA support USE_OLDCMAKECUDA: "OFF" # Build with old cmake cuda USE_NCCL: "OFF" # Use NVidia NCCL with CUDA USE_OPENCV: "ON" # Build with OpenCV support -USE_OPENMP: "ON" # Build with Openmp support +USE_OPENMP: "PLATFORM" # Build with Openmp support USE_CUDNN: "ON" # Build with cudnn support) # one could set CUDNN_ROOT for search path USE_SSE: "ON" # Build with x86 SSE instruction support IF NOT ARM USE_F16C: "ON" # Build with x86 F16C instruction support) # autodetects support if "ON"