From 7a42cd4db999228a177b7a1da9ab73a1b017a640 Mon Sep 17 00:00:00 2001 From: Hu Shiwen Date: Thu, 5 Dec 2019 16:07:24 +0800 Subject: [PATCH] fix --- CMakeLists.txt | 599 ++++++++++++++++------------------------ ci/build_windows.py | 2 + tools/build_gen_warp.py | 8 - tools/gen_warp.cpp | 19 ++ tools/gen_warp.py | 18 ++ tools/warp_dll.cpp | 19 ++ 6 files changed, 293 insertions(+), 372 deletions(-) delete mode 100644 tools/build_gen_warp.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ebf58579f0e..a316a3e83abc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.0.2) -# workaround to store CMAKE_CROSSCOMPILING because is getting reset by the -# project command +# workaround to store CMAKE_CROSSCOMPILING because is getting reset by the project command if(CMAKE_CROSSCOMPILING) set(__CMAKE_CROSSCOMPILING ${CMAKE_CROSSCOMPILING}) set(__CMAKE_CROSSCOMPILING_OVERRIDE ON) @@ -19,65 +18,44 @@ endif() include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Utils.cmake) -# 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) +#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_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(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) message(STATUS "CMAKE_CROSSCOMPILING ${CMAKE_CROSSCOMPILING}") message(STATUS "CMAKE_HOST_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR}") message(STATUS "CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}") + message(STATUS "CMAKE_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}") if(USE_TVM_OP) @@ -91,6 +69,7 @@ if(USE_CUDA AND NOT USE_OLDCMAKECUDA) if(((${CMAKE_GENERATOR} MATCHES "Visual Studio.*") OR (${CMAKE_GENERATOR} MATCHES "Xcode.*") OR (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles") + OR (${CMAKE_GENERATOR} STREQUAL "NMake Makefiles JOM") OR (${CMAKE_GENERATOR} STREQUAL "Ninja") ) AND ((${CMAKE_VERSION} VERSION_GREATER "3.9.0") OR (${CMAKE_VERSION} @@ -107,32 +86,27 @@ else() project(mxnet C CXX) endif() + if(MSVC) set(SYSTEM_ARCHITECTURE x86_64) enable_language(ASM_MASM) else() - execute_process( - COMMAND uname -m - COMMAND tr -d '\n' - OUTPUT_VARIABLE SYSTEM_ARCHITECTURE) + execute_process(COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE SYSTEM_ARCHITECTURE) endif() -set(CMAKE_MODULE_PATH - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules;${CMAKE_MODULE_PATH}") +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules;${CMAKE_MODULE_PATH}") -set(EXTRA_OPERATORS - "" - CACHE PATH "EXTRA OPERATORS PATH") +SET(EXTRA_OPERATORS "" CACHE PATH "EXTRA OPERATORS PATH") if("$ENV{VERBOSE}" STREQUAL "1") message(STATUS " Verbose Makefile ACTIVATED") set(CMAKE_VERBOSE_MAKEFILE ON) endif() -# Switch off modern thread local for dmlc-core, please see: -# https://github.com/dmlc/dmlc-core/issues/571#issuecomment-543467484 +#Switch off modern thread local for dmlc-core, please see: https://github.com/dmlc/dmlc-core/issues/571#issuecomment-543467484 add_definitions(-DDMLC_MODERN_THREAD_LOCAL=0) + if(MSVC) add_definitions(-DWIN32_LEAN_AND_MEAN) add_definitions(-DDMLC_USE_CXX11) @@ -153,14 +127,13 @@ else(MSVC) if(USE_CXX14_IF_AVAILABLE) check_cxx_compiler_flag("-std=c++14" SUPPORT_CXX14) endif() - check_cxx_compiler_flag("-std=c++11" SUPPORT_CXX11) - check_cxx_compiler_flag("-std=c++0x" SUPPORT_CXX0X) - # For cross compilation, we can't rely on the compiler which accepts the flag, - # but mshadow will add platform specific includes not available in other - # arches + check_cxx_compiler_flag("-std=c++11" SUPPORT_CXX11) + check_cxx_compiler_flag("-std=c++0x" SUPPORT_CXX0X) + # For cross compilation, we can't rely on the compiler which accepts the flag, but mshadow will + # add platform specific includes not available in other arches if(USE_SSE) - check_cxx_compiler_flag("-msse3" SUPPORT_MSSE3) - check_cxx_compiler_flag("-msse2" SUPPORT_MSSE2) + check_cxx_compiler_flag("-msse3" SUPPORT_MSSE3) + check_cxx_compiler_flag("-msse2" SUPPORT_MSSE2) else() set(SUPPORT_MSSE2 FALSE) endif() @@ -179,9 +152,8 @@ else(MSVC) add_definitions(-DMSHADOW_USE_F16C=0) endif() set(CMAKE_POSITION_INDEPENDENT_CODE ON) - set(CMAKE_C_FLAGS - "${CMAKE_C_FLAGS} -Wall -Wno-unknown-pragmas -Wno-sign-compare") - if("${CMAKE_CXX_COMPILER_ID}" MATCHES ".*Clang$") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-unknown-pragmas -Wno-sign-compare") + if ("${CMAKE_CXX_COMPILER_ID}" MATCHES ".*Clang$") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-braced-scalar-init") endif() if(CMAKE_BUILD_TYPE STREQUAL "Debug") @@ -253,46 +225,28 @@ if(USE_TENSORRT) find_package(Protobuf REQUIRED) - find_library( - ONNX_LIBRARY - NAMES libonnx.so REQUIRED - PATHS ${ONNX_PATH} - DOC "Path to onnx library.") - find_library( - ONNX_PROTO_LIBRARY - NAMES libonnx_proto.so REQUIRED - PATHS ${ONNX_PATH} - DOC "Path to onnx_proto library.") - find_library( - ONNX_TRT_RUNTIME_LIBRARY - NAMES libnvonnxparser_runtime.so REQUIRED - PATHS ${ONNX_TRT_PATH} - DOC "Path to onnx_proto library.") - find_library( - ONNX_TRT_PARSER_LIBRARY - NAMES libnvonnxparser.so REQUIRED - PATHS ${ONNX_TRT_PATH} - DOC "Path to onnx_proto library.") - - list( - APPEND mxnet_LINKER_LIBS - libnvinfer.so - ${ONNX_TRT_PARSER_LIBRARY} - ${ONNX_TRT_RUNTIME_LIBRARY} - ${ONNX_PROTO_LIBRARY} - ${ONNX_LIBRARY} - ${PROTOBUF_LIBRARY}) -endif() - -# please note that when you enable this, you might run into an linker not being -# able to work properly due to large code injection. you can find more -# information here https://github.com/apache/incubator-mxnet/issues/15971 + find_library(ONNX_LIBRARY NAMES libonnx.so REQUIRED + PATHS ${ONNX_PATH} + DOC "Path to onnx library.") + find_library(ONNX_PROTO_LIBRARY NAMES libonnx_proto.so REQUIRED + PATHS ${ONNX_PATH} + DOC "Path to onnx_proto library.") + find_library(ONNX_TRT_RUNTIME_LIBRARY NAMES libnvonnxparser_runtime.so REQUIRED + PATHS ${ONNX_TRT_PATH} + DOC "Path to onnx_proto library.") + find_library(ONNX_TRT_PARSER_LIBRARY NAMES libnvonnxparser.so REQUIRED + PATHS ${ONNX_TRT_PATH} + DOC "Path to onnx_proto library.") + + list(APPEND mxnet_LINKER_LIBS libnvinfer.so ${ONNX_TRT_PARSER_LIBRARY} ${ONNX_TRT_RUNTIME_LIBRARY} + ${ONNX_PROTO_LIBRARY} ${ONNX_LIBRARY} ${PROTOBUF_LIBRARY}) +endif() + +# please note that when you enable this, you might run into an linker not being able to work properly due to large code injection. +# you can find more information here https://github.com/apache/incubator-mxnet/issues/15971 if(ENABLE_TESTCOVERAGE) - message( - STATUS - "Compiling with test coverage support enabled. This will result in additional files being written to your source directory!" - ) - find_program(GCOV_PATH gcov) + message(STATUS "Compiling with test coverage support enabled. This will result in additional files being written to your source directory!") + find_program( GCOV_PATH gcov ) if(NOT GCOV_PATH) message(FATAL_ERROR "gcov not found! Aborting...") endif() # NOT GCOV_PATH @@ -311,21 +265,11 @@ if(USE_MKLDNN) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /EHsc /Gy /MT") endif() - set(MKLDNN_BUILD_TESTS - OFF - CACHE INTERNAL "" FORCE) - set(MKLDNN_BUILD_EXAMPLES - OFF - CACHE INTERNAL "" FORCE) - set(MKLDNN_ARCH_OPT_FLAGS - "" - CACHE INTERNAL "" FORCE) - set(MKLDNN_ENABLE_JIT_PROFILING - OFF - CACHE INTERNAL "" FORCE) - set(MKLDNN_LIBRARY_TYPE - STATIC - CACHE INTERNAL "" FORCE) + set(MKLDNN_BUILD_TESTS OFF CACHE INTERNAL "" FORCE) + set(MKLDNN_BUILD_EXAMPLES OFF CACHE INTERNAL "" FORCE) + set(MKLDNN_ARCH_OPT_FLAGS "" CACHE INTERNAL "" FORCE) + set(MKLDNN_ENABLE_JIT_PROFILING OFF CACHE INTERNAL "" FORCE) + set(MKLDNN_LIBRARY_TYPE STATIC CACHE INTERNAL "" FORCE) add_subdirectory(3rdparty/mkldnn) @@ -378,7 +322,7 @@ else() add_definitions(-DMXNET_USE_NCCL=0) endif() -if(USE_INT64_TENSOR_SIZE) +if (USE_INT64_TENSOR_SIZE) message(STATUS "Using 64-bit integer for tensor size") add_definitions(-DMSHADOW_INT64_TENSOR_SIZE=1) else() @@ -403,10 +347,8 @@ else() endif() if(USE_ASAN) - set(CMAKE_C_FLAGS - "${CMAKE_C_FLAGS} -fno-omit-frame-pointer -fsanitize=address") - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer -fsanitize=address") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address") set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fsanitize=address") set(GTEST_LIBRARIES "${GTEST_LIBRARIES} -fsanitize=address") list(APPEND mxnet_LINKER_LIBS asan) @@ -415,7 +357,7 @@ endif() list(APPEND mxnet_LINKER_LIBS ${mshadow_LINKER_LIBS}) foreach(var ${C_CXX_INCLUDE_DIRECTORIES}) - include_directories(${var}) + include_directories(${var}) endforeach() include_directories("include") @@ -426,9 +368,10 @@ include_directories("3rdparty/tvm/include") include_directories("3rdparty/dmlc-core/include") include_directories("3rdparty/dlpack/include") -# commented out until PR goes through if(EXISTS -# ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dlpack) add_subdirectory(3rdparty/dlpack) -# endif() +# commented out until PR goes through +#if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dlpack) +# add_subdirectory(3rdparty/dlpack) +#endif() # Prevent stripping out symbols (operator registrations, for example) if(NOT MSVC AND NOT APPLE) @@ -446,9 +389,7 @@ if(UNIX) endif() endif() -set(ALT_MALLOC_FLAGS - "-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free" -) +set(ALT_MALLOC_FLAGS "-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free") # ---[ gperftools if(USE_GPERFTOOLS) @@ -466,9 +407,7 @@ endif() # ---[ jemalloc if(USE_JEMALLOC) if(GPERFTOOLS_FOUND) - message( - ERROR - " Only one of USE_JEMALLOC and USE_GPERFTOOLS can be defined at once") + message(ERROR " Only one of USE_JEMALLOC and USE_GPERFTOOLS can be defined at once") endif() find_package(JeMalloc) if(JEMALLOC_FOUND) @@ -501,8 +440,8 @@ endif() # ---[ OpenMP 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? + # 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(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/openmp/CMakeLists.txt AND SYSTEM_ARCHITECTURE STREQUAL "x86_64" AND NOT MSVC @@ -524,10 +463,8 @@ if(USE_OPENMP) if(OPENMP_FOUND) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") - set(CMAKE_SHARED_LINKER_FLAGS - "${CMAKE_SHARED_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") - set(CMAKE_EXE_LINKER_FLAGS - "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") add_definitions(-DMXNET_USE_OPENMP=1) endif() endif() @@ -535,15 +472,17 @@ elseif(UNIX AND NOT ANDROID) list(APPEND mxnet_LINKER_LIBS pthread) endif() + # ---[ LAPack if(USE_LAPACK) message("USE_LAPACK is ON") add_definitions(-DMXNET_USE_LAPACK=1) - if(NOT MSVC) + if (NOT MSVC) list(APPEND mxnet_LINKER_LIBS lapack) endif() endif() + # ---[ jemalloc if(USE_JEMALLOC) find_package(JeMalloc) @@ -557,7 +496,7 @@ endif() include(CTest) set(GTEST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/googletest/googletest") set(GTEST_INCLUDE_DIR ${GTEST_ROOT}/include) -# set(GTEST_BOTH_LIBRARIES gtest gtest_main) +#set(GTEST_BOTH_LIBRARIES gtest gtest_main) set(GTEST_LIBRARIES gtest gtest_main) set(GTEST_MAIN_LIBRARY gtest_main) set(GTEST_LIBRARY gtest) @@ -567,12 +506,12 @@ find_package(GTest REQUIRED) # cudnn detection if(USE_CUDNN AND USE_CUDA) - detect_cudnn() + detect_cuDNN() if(HAVE_CUDNN) add_definitions(-DUSE_CUDNN) include_directories(SYSTEM ${CUDNN_INCLUDE}) list(APPEND mxnet_LINKER_LIBS ${CUDNN_LIBRARY}) - add_definitions(-DMSHADOW_USE_CUDNN=1) + add_definitions(-DMSHADOW_USE_CUDNN=1) endif() endif() @@ -583,13 +522,11 @@ endif() if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/mshadow/cmake) add_subdirectory("3rdparty/mshadow") endif() -file(GLOB_RECURSE SOURCE "src/*.cc" "src/*.h" "include/*.h") -file(GLOB_RECURSE CUDA "src/*.cu" "src/*.cuh") +FILE(GLOB_RECURSE SOURCE "src/*.cc" "src/*.h" "include/*.h") +FILE(GLOB_RECURSE CUDA "src/*.cu" "src/*.cuh") # add nnvm to source -file( - GLOB_RECURSE - NNVMSOURCE +FILE(GLOB_RECURSE NNVMSOURCE 3rdparty/tvm/nnvm/src/c_api/*.cc 3rdparty/tvm/nnvm/src/core/*.cc 3rdparty/tvm/nnvm/src/pass/*.cc @@ -600,45 +537,30 @@ file( list(APPEND SOURCE ${NNVMSOURCE}) # add mshadow file -file(GLOB_RECURSE MSHADOWSOURCE "3rdparty/mshadow/mshadow/*.h") -file(GLOB_RECURSE MSHADOW_CUDASOURCE "3rdparty/mshadow/mshadow/*.cuh") +FILE(GLOB_RECURSE MSHADOWSOURCE "3rdparty/mshadow/mshadow/*.h") +FILE(GLOB_RECURSE MSHADOW_CUDASOURCE "3rdparty/mshadow/mshadow/*.cuh") list(APPEND SOURCE ${MSHADOWSOURCE}) list(APPEND CUDA ${MSHADOW_CUDASOURCE}) # add source group -file(GLOB_RECURSE GROUP_SOURCE "src/*.cc" "3rdparty/tvm/nnvm/*.cc" - "plugin/*.cc") -file(GLOB_RECURSE GROUP_Include "src/*.h" "3rdparty/tvm/nnvm/*.h" - "3rdparty/mshadow/mshadow/*.h" "plugin/*.h") -file( - GLOB_RECURSE - GROUP_CUDA - "src/*.cu" - "src/*.cuh" - "3rdparty/mshadow/mshadow/*.cuh" - "plugin/*.cu" - "plugin/*.cuh" - "3rdparty/nvidia_cub/cub/*.cuh") +FILE(GLOB_RECURSE GROUP_SOURCE "src/*.cc" "3rdparty/tvm/nnvm/*.cc" "plugin/*.cc") +FILE(GLOB_RECURSE GROUP_Include "src/*.h" "3rdparty/tvm/nnvm/*.h" "3rdparty/mshadow/mshadow/*.h" "plugin/*.h") +FILE(GLOB_RECURSE GROUP_CUDA "src/*.cu" "src/*.cuh" "3rdparty/mshadow/mshadow/*.cuh" "plugin/*.cu" + "plugin/*.cuh" "3rdparty/nvidia_cub/cub/*.cuh") assign_source_group("Source" ${GROUP_SOURCE}) assign_source_group("Include" ${GROUP_Include}) assign_source_group("CUDA" ${GROUP_CUDA}) if(USE_PLUGINS_WARPCTC) - set(WARPCTC_INCLUDE - "" - CACHE PATH "WARPCTC include") - set(WARPCTC_LIB_DEBUG - "" - CACHE FILEPATH "WARPCTC lib") - set(WARPCTC_LIB_RELEASE - "" - CACHE FILEPATH "WARPCTC lib") - include_directories(SYSTEM ${WARPCTC_INCLUDE}) - list(APPEND mxnet_LINKER_LIBS ${WARPCTC_LIB}) - file(GLOB_RECURSE PLUGINS_SOURCE "plugin/warpctc/*.cc" "plugin/warpctc/*.h") - file(GLOB_RECURSE PLUGINS_CUSRC "plugin/warpctc/*.cu") - list(APPEND SOURCE ${PLUGINS_SOURCE}) - list(APPEND CUDA ${PLUGINS_CUSRC}) + set(WARPCTC_INCLUDE "" CACHE PATH "WARPCTC include") + set(WARPCTC_LIB_DEBUG "" CACHE FILEPATH "WARPCTC lib") + set(WARPCTC_LIB_RELEASE "" CACHE FILEPATH "WARPCTC lib") + include_directories(SYSTEM ${WARPCTC_INCLUDE}) + list(APPEND mxnet_LINKER_LIBS ${WARPCTC_LIB}) + FILE(GLOB_RECURSE PLUGINS_SOURCE "plugin/warpctc/*.cc" "plugin/warpctc/*.h") + FILE(GLOB_RECURSE PLUGINS_CUSRC "plugin/warpctc/*.cu") + list(APPEND SOURCE ${PLUGINS_SOURCE}) + list(APPEND CUDA ${PLUGINS_CUSRC}) endif() if(USE_OPERATOR_TUNING AND USE_OPENMP) @@ -665,40 +587,33 @@ if(USE_PLUGIN_CAFFE) include_directories(${CMAKE_BINARY_DIR}/caffe/include) link_directories(${CAFFE_PATH}/build/lib) if(NOT DEFINED CAFFE_PATH) - message( - FATAL_ERROR - "Please set CAFFE_PATH to point to the caffe source installation") + message(FATAL_ERROR "Please set CAFFE_PATH to point to the caffe source installation") endif() - file(GLOB_RECURSE PLUGINS_SOURCE "plugin/caffe/*.cc" "plugin/caffe/*.h") - file(GLOB_RECURSE PLUGINS_CUSRC "plugin/caffe/*.cu") + FILE(GLOB_RECURSE PLUGINS_SOURCE "plugin/caffe/*.cc" "plugin/caffe/*.h") + FILE(GLOB_RECURSE PLUGINS_CUSRC "plugin/caffe/*.cu") list(APPEND SOURCE ${PLUGINS_SOURCE}) list(APPEND CUDA ${PLUGINS_CUSRC}) include_directories(${CMAKE_BINARY_DIR}/include) add_definitions(-DMXNET_USE_CAFFE=1) - list( - APPEND mxnet_LINKER_LIBS - protobuf - boost_system - boost_thread - boost_filesystem - gflags - glog - caffe - ${Caffe_LINKER_LIBS}) + list(APPEND mxnet_LINKER_LIBS + protobuf boost_system boost_thread boost_filesystem + gflags glog caffe + ${Caffe_LINKER_LIBS} +) endif() -if(NOT (EXTRA_OPERATORS STREQUAL "")) - mxnet_source_group("Extra" GLOB_RECURSE "${EXTRA_OPERATORS}/*.cc") - mxnet_source_group("Extra\\Cuda" GLOB_RECURSE "${EXTRA_OPERATORS}/*.cu") - file(GLOB_RECURSE EXTRA_SRC "${EXTRA_OPERATORS}/*.cc") - file(GLOB_RECURSE EXTRA_CUSRC "${EXTRA_OPERATORS}/*.cu") - list(APPEND SOURCE ${EXTRA_SRC} ${EXTRA_CUSRC}) +if (NOT (EXTRA_OPERATORS STREQUAL "")) + mxnet_source_group("Extra" GLOB_RECURSE "${EXTRA_OPERATORS}/*.cc") + mxnet_source_group("Extra\\Cuda" GLOB_RECURSE "${EXTRA_OPERATORS}/*.cu") + FILE(GLOB_RECURSE EXTRA_SRC "${EXTRA_OPERATORS}/*.cc") + FILE(GLOB_RECURSE EXTRA_CUSRC "${EXTRA_OPERATORS}/*.cu") + list(APPEND SOURCE ${EXTRA_SRC} ${EXTRA_CUSRC}) endif() if(MSVC) foreach(flag_var - CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) if(${flag_var} MATCHES "/MD") string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") endif(${flag_var} MATCHES "/MD") @@ -712,100 +627,84 @@ if(USE_CUDA) # set(CMAKE_CUDA_FLAGS "${NVCC_FLAGS_ARCH}") list(APPEND mxnet_LINKER_LIBS cublas cufft cusolver curand) if(ENABLE_CUDA_RTC) - list(APPEND mxnet_LINKER_LIBS nvrtc cuda) - add_definitions(-DMXNET_ENABLE_CUDA_RTC=1) + list(APPEND mxnet_LINKER_LIBS nvrtc cuda) + add_definitions(-DMXNET_ENABLE_CUDA_RTC=1) endif() list(APPEND SOURCE ${CUDA}) add_definitions(-DMXNET_USE_CUDA=1) - link_directories(${CUDA_TOOLKIT_ROOT_DIR}/lib64) + link_directories(${CUDA_TOOLKIT_ROOT_DIR}/lib/x64) else() list(APPEND CUDA_INCLUDE_DIRS ${INCLUDE_DIRECTORIES}) - # define preprocessor macro so that we will not include the generated - # forcelink header + # define preprocessor macro so that we will not include the generated forcelink header if(ENABLE_CUDA_RTC) add_definitions(-DMXNET_ENABLE_CUDA_RTC=1) endif() # Create '.cmake' files for cuda compiles given definitions added thus far mshadow_cuda_compile(cuda_objs ${CUDA}) if(MSVC) - if(ENABLE_CUDA_RTC) - find_library( - CUDA_nvrtc_LIBRARY nvrtc "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" - "${CUDA_TOOLKIT_ROOT_DIR}/lib/win32") - list(APPEND mxnet_LINKER_LIBS ${CUDA_nvrtc_LIBRARY}) - set(CUDA_cuda_LIBRARY "${CUDA_nvrtc_LIBRARY}/../cuda.lib") - list(APPEND mxnet_LINKER_LIBS ${CUDA_cuda_LIBRARY}) - endif() - find_library(CUDA_cufft_LIBRARY nvrtc "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" - "${CUDA_TOOLKIT_ROOT_DIR}/lib/win32") - list(APPEND mxnet_LINKER_LIBS "${CUDA_cufft_LIBRARY}/../cufft.lib" - )# For fft operator - find_library( - CUDA_cusolver_LIBRARY nvrtc "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" - "${CUDA_TOOLKIT_ROOT_DIR}/lib/win32") - list(APPEND mxnet_LINKER_LIBS "${CUDA_cusolver_LIBRARY}/../cusolver.lib" - )# For cusolver - link_directories(${CUDA_TOOLKIT_ROOT_DIR}/lib/win32) - link_directories(${CUDA_TOOLKIT_ROOT_DIR}/lib/x64) + if(ENABLE_CUDA_RTC) + FIND_LIBRARY(CUDA_nvrtc_LIBRARY nvrtc "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" "${CUDA_TOOLKIT_ROOT_DIR}/lib/win32") + list(APPEND mxnet_LINKER_LIBS ${CUDA_nvrtc_LIBRARY}) + set(CUDA_cuda_LIBRARY "${CUDA_nvrtc_LIBRARY}/../cuda.lib") + list(APPEND mxnet_LINKER_LIBS ${CUDA_cuda_LIBRARY}) + endif() + FIND_LIBRARY(CUDA_cufft_LIBRARY nvrtc "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" "${CUDA_TOOLKIT_ROOT_DIR}/lib/win32") + list(APPEND mxnet_LINKER_LIBS "${CUDA_cufft_LIBRARY}/../cufft.lib") # For fft operator + FIND_LIBRARY(CUDA_cusolver_LIBRARY nvrtc "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" "${CUDA_TOOLKIT_ROOT_DIR}/lib/win32") + list(APPEND mxnet_LINKER_LIBS "${CUDA_cusolver_LIBRARY}/../cusolver.lib") # For cusolver + link_directories(${CUDA_TOOLKIT_ROOT_DIR}/lib/win32) + link_directories(${CUDA_TOOLKIT_ROOT_DIR}/lib/x64) else(MSVC) - list(APPEND mxnet_LINKER_LIBS cufft cusolver) - if(ENABLE_CUDA_RTC) - list(APPEND mxnet_LINKER_LIBS nvrtc cuda) - endif() - link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64") + list(APPEND mxnet_LINKER_LIBS cufft cusolver) + if(ENABLE_CUDA_RTC) + list(APPEND mxnet_LINKER_LIBS nvrtc cuda) + endif() + link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64") endif() list(APPEND SOURCE ${cuda_objs} ${CUDA}) add_definitions(-DMXNET_USE_CUDA=1) if(CUDA_LIBRARY_PATH) - if(IS_CONTAINER_BUILD) - # In case of building on a production-like build container which may not - # have Cuda installed + if(IS_CONTAINER_BUILD) + # In case of building on a production-like build container which may not have Cuda installed if(NOT CMAKE_SYSTEM_HAS_CUDA) - # Assuming building in a container that doesn't have CUDA installed - # (ie CPU-only build machine) so use the stub cuda driver shared - # library - if(EXISTS ${CUDA_LIBRARY_PATH}/stubs/libcuda.so) + # Assuming building in a container that doesn't have CUDA installed (ie CPU-only build machine) + # so use the stub cuda driver shared library + if(EXISTS ${CUDA_LIBRARY_PATH}/stubs/libcuda.so) link_directories(${CUDA_LIBRARY_PATH}/stubs) - endif() + endif() + endif() endif() - endif() endif() - endif() + endif() endif() -# unsupported: if caffe is a subdirectory of mxnet, load its CMakeLists.txt as -# well +# unsupported: if caffe is a subdirectory of mxnet, load its CMakeLists.txt as well if(USE_PLUGIN_CAFFE) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/caffe) add_subdirectory(caffe) endif() endif() -if(MSVC) - - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /EHsc") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /EHsc /Gy") - set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /EHsc /Gy") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO - "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /EHsc /Gy") - set(CMAKE_SHARED_LINKER_FLAGS_RELEASE - "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /OPT:REF /OPT:ICF") - set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL - "${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL} /OPT:REF /OPT:ICF") - set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO - "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /OPT:REF /OPT:ICF") -else() +if(NOT MSVC) # Only add c++11 flags and definitions after cuda compiling add_definitions(-DDMLC_USE_CXX11) add_definitions(-DMSHADOW_IN_CXX11) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") +else() + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /EHsc") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /EHsc /Gy") + set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /EHsc /Gy") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /EHsc /Gy") + set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /OPT:REF /OPT:ICF") + set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL} /OPT:REF /OPT:ICF") + set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /OPT:REF /OPT:ICF") + endif() add_library(sample_lib SHARED ${CMAKE_CURRENT_SOURCE_DIR}/example/extensions/lib_custom_op/gemm_lib.cc) target_include_directories(sample_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/mxnet) set(MXNET_INSTALL_TARGETS mxnet) - if(UNIX) # Create dummy file since we want an empty shared library before linking set(DUMMY_SOURCE ${CMAKE_BINARY_DIR}/dummy.c) @@ -813,9 +712,7 @@ if(UNIX) list(APPEND MXNET_INSTALL_TARGETS mxnet_static) add_library(mxnet_static STATIC ${SOURCE}) add_library(mxnet SHARED ${DUMMY_SOURCE}) - target_link_libraries( - mxnet PRIVATE ${BEGIN_WHOLE_ARCHIVE} $ - ${END_WHOLE_ARCHIVE}) + target_link_libraries(mxnet PRIVATE ${BEGIN_WHOLE_ARCHIVE} $ ${END_WHOLE_ARCHIVE}) target_link_libraries(mxnet PRIVATE mxnet_static) target_link_libraries(mxnet_static PUBLIC ${CMAKE_DL_LIBS}) target_compile_options(sample_lib PUBLIC -shared) @@ -829,32 +726,31 @@ elseif(MSVC) add_executable(gen_warp tools/gen_warp.cpp) add_library(mxnet SHARED tools/warp_dll.cpp tools/warp_gen_cpp.cpp tools/warp_gen.asm) - - - target_link_libraries(mxnet PRIVATE cudart) + list(GET cuda_arch 0 mxnet_first_arch) foreach(arch ${cuda_arch}) add_library(mxnet_${arch} SHARED ${SOURCE}) target_compile_options( mxnet_${arch} - PUBLIC - "$<$:-gencode=arch=compute_${arch},code=sm_${arch},code=compute_${arch}>" + PRIVATE + "$<$:--gpu-architecture=compute_${arch}>" ) target_compile_options( mxnet_${arch} - PUBLIC - "$<$:-gencode=arch=compute_${arch},code=sm_${arch},code=compute_${arch}>" + PRIVATE + "$<$:--gpu-code=sm_${arch},compute_${arch}>" ) target_compile_options( - mxnet_${arch} PUBLIC "$<$:-Xcompiler=-MTd -Gy /bigobj>") + mxnet_${arch} + PRIVATE "$<$,$>:-Xcompiler=-MTd -Gy /bigobj>") target_compile_options( mxnet_${arch} - PUBLIC "$<$:-Xcompiler=-MT -Gy /bigobj>") + PRIVATE "$<$,$>:-Xcompiler=-MT -Gy /bigobj>") endforeach() add_custom_command( OUTPUT ${CMAKE_SOURCE_DIR}/tools/warp_gen_cpp.cpp ${CMAKE_SOURCE_DIR}/tools/warp_gen.asm - COMMAND gen_warp $ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tools DEPENDS $) + COMMAND gen_warp $ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tools DEPENDS $) else() add_library(mxnet SHARED ${SOURCE}) @@ -878,38 +774,28 @@ if(USE_DIST_KVSTORE) endif() if(USE_TVM_OP) - list(APPEND mxnet_LINKER_LIBS - ${CMAKE_CURRENT_BINARY_DIR}/3rdparty/tvm/libtvm_runtime.so) + list(APPEND mxnet_LINKER_LIBS ${CMAKE_CURRENT_BINARY_DIR}/3rdparty/tvm/libtvm_runtime.so) include(cmake/BuildTVM.cmake) add_subdirectory("3rdparty/tvm") if(NOT Python3_EXECUTABLE) find_package(PythonInterp 3 REQUIRED) - set(Python3_EXECUTABLE - ${PYTHON_EXECUTABLE} - CACHE FILEPATH "Path to the python3 executable") + set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "Path to the python3 executable") if(NOT Python3_EXECUTABLE) message(FATAL_ERROR "No python3 interpreter found to build TVM operators") endif() endif() - set(TVM_OP_COMPILE_OPTIONS - "-o${CMAKE_CURRENT_BINARY_DIR}/libtvmop.so" "--config" - "${CMAKE_CURRENT_BINARY_DIR}/tvmop.conf") + set(TVM_OP_COMPILE_OPTIONS "-o${CMAKE_CURRENT_BINARY_DIR}/libtvmop.so" "--config" "${CMAKE_CURRENT_BINARY_DIR}/tvmop.conf") if(CUDA_ARCH_BIN) - set(TVM_OP_COMPILE_OPTIONS "${TVM_OP_COMPILE_OPTIONS}" "--cuda-arch" - "${CUDA_ARCH_BIN}") + set(TVM_OP_COMPILE_OPTIONS "${TVM_OP_COMPILE_OPTIONS}" "--cuda-arch" "${CUDA_ARCH_BIN}") endif() - add_custom_command( - TARGET mxnet - POST_BUILD - COMMAND - ${CMAKE_COMMAND} -E env - PYTHONPATH="${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/tvm/python:${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/tvm/topi/python:${CMAKE_CURRENT_SOURCE_DIR}/contrib" - LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_CURRENT_BINARY_DIR}/3rdparty/tvm:$ENV{LD_LIBRARY_PATH} - ${Python3_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/contrib/tvmop/compile.py - ${TVM_OP_COMPILE_OPTIONS}) + add_custom_command(TARGET mxnet POST_BUILD + COMMAND ${CMAKE_COMMAND} -E env + PYTHONPATH="${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/tvm/python:${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/tvm/topi/python:${CMAKE_CURRENT_SOURCE_DIR}/contrib" + LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_CURRENT_BINARY_DIR}/3rdparty/tvm:$ENV{LD_LIBRARY_PATH} + ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/contrib/tvmop/compile.py ${TVM_OP_COMPILE_OPTIONS} + ) endif() if(USE_PLUGINS_WARPCTC) @@ -917,12 +803,18 @@ if(USE_PLUGINS_WARPCTC) endif() if(MSVC) - - foreach(arch ${cuda_arch}) - target_link_libraries(mxnet_${arch} PUBLIC ${mxnet_LINKER_LIBS}) - endforeach() + if(FIRST_CUDA) + foreach(arch ${cuda_arch}) + target_link_libraries(mxnet_${arch} PUBLIC ${mxnet_LINKER_LIBS}) + target_link_libraries(mxnet_${arch} PUBLIC dmlc) + endforeach() + else() + target_link_libraries(mxnet PUBLIC ${mxnet_LINKER_LIBS}) + target_link_libraries(mxnet PUBLIC dmlc) + endif() else() target_link_libraries(mxnet PUBLIC ${mxnet_LINKER_LIBS}) + target_link_libraries(mxnet PUBLIC dmlc) endif() if(USE_OPENCV AND OpenCV_VERSION_MAJOR GREATER 2) @@ -930,20 +822,19 @@ if(USE_OPENCV AND OpenCV_VERSION_MAJOR GREATER 2) if(MSVC) target_link_libraries(im2rec mxnet) else() - target_link_libraries(im2rec ${BEGIN_WHOLE_ARCHIVE} mxnet_static - ${END_WHOLE_ARCHIVE}) - endif() - target_link_libraries(im2rec ${mxnet_LINKER_LIBS} ${OpenCV_LIBS} dmlc - ${pslite_LINKER_LIBS}) + target_link_libraries(im2rec ${BEGIN_WHOLE_ARCHIVE} mxnet_static ${END_WHOLE_ARCHIVE}) + endif() + target_link_libraries(im2rec + ${mxnet_LINKER_LIBS} + ${OpenCV_LIBS} + dmlc + ${pslite_LINKER_LIBS} + ) else() - message( - WARNING - "OpenCV_VERSION_MAJOR: ${OpenCV_VERSION_MAJOR}, version 3 with imgcodecs \ + message(WARNING "OpenCV_VERSION_MAJOR: ${OpenCV_VERSION_MAJOR}, version 3 with imgcodecs \ is required for im2rec, im2rec will not be available") endif() -foreach(arch ${cuda_arch}) - target_link_libraries(mxnet_${arch} PUBLIC dmlc) -endforeach() + if(MSVC AND USE_MXNET_LIB_NAMING) set_target_properties(mxnet PROPERTIES OUTPUT_NAME "libmxnet") @@ -952,67 +843,55 @@ endif() add_subdirectory(tests) include(GNUInstallDirs) -install( - TARGETS ${MXNET_INSTALL_TARGETS} +install(TARGETS ${MXNET_INSTALL_TARGETS} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) -# NOTE: Public headers will be installed into -# ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}, see -# https://cmake.org/cmake/help/v3.0/variable/CMAKE_INSTALL_PREFIX.html -# https://cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html +# NOTE: Public headers will be installed into ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}, see +# https://cmake.org/cmake/help/v3.0/variable/CMAKE_INSTALL_PREFIX.html +# https://cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dlpack/include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dmlc-core/include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dlpack/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dmlc-core/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) if(USE_MKLDNN) - install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/mkldnn/include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/mkldnn/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) endif() -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/mshadow/mshadow/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mshadow) -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/mxnet/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mxnet) -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/tvm/nnvm/include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -if(INSTALL_EXAMPLES) - install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/example - DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/mshadow/mshadow/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mshadow) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/mxnet/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mxnet) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/tvm/nnvm/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +if (INSTALL_EXAMPLES) + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/example DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}) endif() -if(USE_SIGNAL_HANDLER) - add_definitions(-DMXNET_USE_SIGNAL_HANDLER=1) +if (USE_SIGNAL_HANDLER) + add_definitions(-DMXNET_USE_SIGNAL_HANDLER=1) endif() # AUTO_INSTALL_DIR -> Optional: specify post-build install direcory if(AUTO_INSTALL_DIR) # ---[ Install Includes - add_custom_command( - TARGET mxnet - POST_BUILD + add_custom_command(TARGET mxnet POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_CURRENT_SOURCE_DIR}/include ${AUTO_INSTALL_DIR}/include) + ${CMAKE_CURRENT_SOURCE_DIR}/include ${AUTO_INSTALL_DIR}/include + ) # ---[ Install Examples - add_custom_command( - TARGET mxnet - POST_BUILD + add_custom_command(TARGET mxnet POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_CURRENT_SOURCE_DIR}/example ${AUTO_INSTALL_DIR}/example) + ${CMAKE_CURRENT_SOURCE_DIR}/example ${AUTO_INSTALL_DIR}/example + ) endif() if(INSTALL_PYTHON_VERSIONS) message(STATUS "Installing for python versions: ${INSTALL_PYTHON_VERSIONS}") foreach(version ${INSTALL_PYTHON_VERSIONS}) - set(outdir - ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/python${version}/site-packages/mxnet) - add_custom_command( - TARGET mxnet - POST_BUILD + set(outdir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/python${version}/site-packages/mxnet) + add_custom_command(TARGET mxnet POST_BUILD COMMAND mkdir -p ${outdir} - COMMAND cp -ru ${CMAKE_CURRENT_SOURCE_DIR}/python/mxnet/* ${outdir}) + COMMAND cp -ru ${CMAKE_CURRENT_SOURCE_DIR}/python/mxnet/* ${outdir} + ) endforeach() endif() @@ -1027,19 +906,11 @@ endif() # ---[ Linter target if(MSVC) find_package(PythonInterp) - set(PYTHON_EXECUTABLE - ${PYTHON_EXECUTABLE} - CACHE FILEPATH "Path to the python executable") + set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "Path to the python executable") endif() set(LINT_DIRS "include src plugin cpp-package tests") set(EXCLUDE_PATH "src/operator/contrib/ctc_include") -add_custom_target( - mxnet_lint - COMMAND - ${CMAKE_COMMAND} -DMSVC=${MSVC} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} - -DLINT_DIRS=${LINT_DIRS} -DPROJECT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} - -DPROJECT_NAME=mxnet -DEXCLUDE_PATH=${EXCLUDE_PATH} -P - ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dmlc-core/cmake/lint.cmake) +add_custom_target(mxnet_lint COMMAND ${CMAKE_COMMAND} -DMSVC=${MSVC} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DLINT_DIRS=${LINT_DIRS} -DPROJECT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DPROJECT_NAME=mxnet -DEXCLUDE_PATH=${EXCLUDE_PATH} -P ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dmlc-core/cmake/lint.cmake) if(BUILD_CYTHON_MODULES) include(cmake/BuildCythonModules.cmake) diff --git a/ci/build_windows.py b/ci/build_windows.py index ce77c316ab20..98264bf4cdae 100755 --- a/ci/build_windows.py +++ b/ci/build_windows.py @@ -115,6 +115,7 @@ class BuildFlavour(Enum): '-DCUDA_ARCH_NAME=Manual ' '-DCUDA_ARCH_BIN=52 ' '-DCUDA_ARCH_PTX=52 ' + '-DCUDA_ARCH_LIST=5.2 ' '-DCMAKE_CXX_FLAGS="/FS /MD /O2 /Ob2" ' '-DUSE_MKL_IF_AVAILABLE=OFF ' '-DCMAKE_BUILD_TYPE=Release') @@ -131,6 +132,7 @@ class BuildFlavour(Enum): '-DCUDA_ARCH_NAME=Manual ' '-DCUDA_ARCH_BIN=52 ' '-DCUDA_ARCH_PTX=52 ' + '-DCUDA_ARCH_LIST=5.2 ' '-DUSE_MKLDNN=ON ' '-DCMAKE_CXX_FLAGS="/FS /MD /O2 /Ob2" ' '-DCMAKE_BUILD_TYPE=Release') diff --git a/tools/build_gen_warp.py b/tools/build_gen_warp.py deleted file mode 100644 index 6479adfc7f97..000000000000 --- a/tools/build_gen_warp.py +++ /dev/null @@ -1,8 +0,0 @@ -from distutils.core import setup -from Cython.Build import cythonize -from Cython.Compiler import Options - -Options.embed = "main" -setup( - ext_modules=cythonize("gen_warp.pyx") -) diff --git a/tools/gen_warp.cpp b/tools/gen_warp.cpp index e0955bff3de5..b0afd40b8986 100644 --- a/tools/gen_warp.cpp +++ b/tools/gen_warp.cpp @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + #include #include #include diff --git a/tools/gen_warp.py b/tools/gen_warp.py index d6584722b26b..a1ad2e297a96 100644 --- a/tools/gen_warp.py +++ b/tools/gen_warp.py @@ -1,3 +1,21 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. import re import subprocess diff --git a/tools/warp_dll.cpp b/tools/warp_dll.cpp index e6ee972683d3..954e85bd7007 100644 --- a/tools/warp_dll.cpp +++ b/tools/warp_dll.cpp @@ -1,3 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + #include #include #include