Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[CI] Test CMake builds instead of Makefile builds #17645

Merged
merged 1 commit into from Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/os_x_staticbuild.yml
Expand Up @@ -10,7 +10,7 @@ jobs:
uses: actions/checkout@v2
- name: Install Dependencies
run: |
brew install nasm automake ninja libtool
brew install nasm automake ninja libtool cmake pkgconfig protobuf
- name: Build project
run: |
git --version
Expand Down
9 changes: 8 additions & 1 deletion 3rdparty/mshadow/CMakeLists.txt
Expand Up @@ -13,6 +13,12 @@ add_library(mshadow INTERFACE)
file(GLOB_RECURSE MSHADOWSOURCE "mshadow/*.h")
target_include_directories(mshadow INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}")
target_sources(mshadow INTERFACE ${MSHADOWSOURCE})
if(UNIX)
target_compile_options(mshadow INTERFACE
"$<$<COMPILE_LANGUAGE:CXX>:-Wno-unused-parameter>"
"$<$<COMPILE_LANGUAGE:CXX>:-Wno-unknown-pragmas>"
"$<$<COMPILE_LANGUAGE:CXX>:-Wno-unused-local-typedefs>")
endif()

if(USE_CUDA)
enable_language(CUDA)
Expand Down Expand Up @@ -67,7 +73,8 @@ else()
endif()

set(mshadow_LINT_DIRS mshadow mshadow-ps)
find_package(Python3)
add_custom_target(mshadow_lint COMMAND ${CMAKE_COMMAND} -DMSVC=${MSVC}
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DLINT_DIRS=${mshadow_LINT_DIRS}
-DPYTHON_EXECUTABLE=${Python3_EXECUTABLE} -DLINT_DIRS=${mshadow_LINT_DIRS}
-DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} -DPROJECT_NAME=mshadow
-P ${PROJECT_SOURCE_DIR}/../dmlc-core/cmake/lint.cmake)
9 changes: 5 additions & 4 deletions 3rdparty/mshadow/mshadow/base.h
Expand Up @@ -18,12 +18,13 @@
#define NOMINMAX
#endif
#endif
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <limits>
#include <sstream>
#include <string>

Expand Down Expand Up @@ -839,7 +840,7 @@ MSHADOW_XINLINE bool MaxValue<bool>(void) {
/*! \brief maximum value of uint32_t */
template<>
MSHADOW_XINLINE uint32_t MaxValue<uint32_t>(void) {
return -1;
return std::numeric_limits<uint32_t>::max();
apeforest marked this conversation as resolved.
Show resolved Hide resolved
}

/*!
Expand Down
40 changes: 25 additions & 15 deletions CMakeLists.txt
Expand Up @@ -51,6 +51,7 @@ else()
endif()
option(USE_GPERFTOOLS "Build with GPerfTools support" OFF)
option(USE_JEMALLOC "Build with Jemalloc support" OFF)
option(USE_LIBJPEG_TURBO "Use libjpeg-turbo" OFF)
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)
Expand Down Expand Up @@ -381,6 +382,16 @@ if(USE_JEMALLOC)
endif()
endif()

if(USE_LIBJPEG_TURBO)
find_package(PkgConfig REQUIRED)
pkg_search_module(TURBOJPEG REQUIRED libturbojpeg)
include_directories(SYSTEM ${TURBOJPEG_INCLUDE_DIRS})
list(APPEND mxnet_LINKER_LIBS ${TURBOJPEG_LINK_LIBRARIES})
add_definitions(-DMXNET_USE_LIBJPEG_TURBO=1)
else()
add_definitions(-DMXNET_USE_LIBJPEG_TURBO=0)
endif()

# ---[ OpenCV
if(USE_OPENCV)
find_package(OpenCV COMPONENTS core highgui imgproc imgcodecs)
Expand Down Expand Up @@ -661,7 +672,7 @@ add_subdirectory("3rdparty/mshadow")

set(MXNET_INSTALL_TARGETS mxnet)
if(UNIX)
string(APPEND CMAKE_CUDA_FLAGS "${CUDA_ARCH_FLAGS_SPACES}")
string(APPEND CMAKE_CUDA_FLAGS " ${CUDA_ARCH_FLAGS_SPACES}")
# Create dummy file since we want an empty shared library before linking
set(DUMMY_SOURCE ${CMAKE_BINARY_DIR}/dummy.c)
file(WRITE ${DUMMY_SOURCE} "")
Expand All @@ -673,6 +684,15 @@ if(UNIX)
target_link_libraries(mxnet PRIVATE mxnet_static)
target_link_libraries(mxnet_static PUBLIC ${CMAKE_DL_LIBS})
set_target_properties(mxnet_static PROPERTIES OUTPUT_NAME mxnet)
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
target_compile_options(mxnet_static PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-Werror>")
# Ignore erroneous compiler warnings:
# 1) variables used in '#pragma omp parallel' are considered unused
target_compile_options(mxnet_static PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-Wno-error=unused-variable>")
if(USE_CUDA)
string(APPEND CMAKE_CUDA_FLAGS " -Werror cross-execution-space-call")
endif()
endif()
elseif(MSVC)
if(USE_CUDA)
if(MSVC)
Expand Down Expand Up @@ -708,7 +728,7 @@ elseif(MSVC)
COMMAND gen_warp $<TARGET_FILE:mxnet_${mxnet_first_arch}> WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/ DEPENDS $<TARGET_FILE:mxnet_${mxnet_first_arch}>)
else(USE_SPLIT_ARCH_DLL)
string(REPLACE ";" " " NVCC_FLAGS_ARCH "${NVCC_FLAGS_ARCH}")
set(CMAKE_CUDA_FLAGS "${CUDA_ARCH_FLAGS_SPACES}")
set(CMAKE_CUDA_FLAGS " ${CUDA_ARCH_FLAGS_SPACES}")
add_library(mxnet SHARED ${SOURCE})
target_link_libraries(mxnet PUBLIC mshadow)
target_compile_options(
Expand Down Expand Up @@ -778,14 +798,7 @@ endfunction()
if(USE_TVM_OP)
list(APPEND mxnet_LINKER_LIBS ${CMAKE_CURRENT_BINARY_DIR}/3rdparty/tvm/libtvm_runtime.so)
BuildTVMOP()
if(NOT Python3_EXECUTABLE)
find_package(PythonInterp 3 REQUIRED)
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()

find_package(Python3 REQUIRED)
set(TVM_OP_COMPILE_OPTIONS "-o${CMAKE_CURRENT_BINARY_DIR}" "--config" "${CMAKE_CURRENT_BINARY_DIR}/tvmop.conf" "-L" "${CMAKE_CURRENT_BINARY_DIR}/3rdparty/tvm")
if(USE_CUDA)
set(TVM_OP_COMPILE_OPTIONS "${TVM_OP_COMPILE_OPTIONS}" "--cuda-arch" "\"${CUDA_ARCH_FLAGS}\"")
Expand Down Expand Up @@ -904,13 +917,10 @@ endif()
add_subdirectory(tests)

# ---[ Linter target
if(MSVC)
find_package(PythonInterp)
set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "Path to the python executable")
endif()
find_package(Python3)
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=${Python3_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)
Expand Down
2 changes: 1 addition & 1 deletion R-package/Makefile
@@ -1,5 +1,5 @@
rcpplint:
3rdparty/dmlc-core/scripts/lint.py mxnet-rcpp ${LINT_LANG} R-package/src
./3rdparty/dmlc-core/scripts/lint.py mxnet-rcpp all R-package/src

rpkg:
mkdir -p R-package/inst/libs
Expand Down
15 changes: 14 additions & 1 deletion ci/docker/install/centos7_base.sh
Expand Up @@ -27,7 +27,20 @@ yum -y install epel-release
yum -y install git
yum -y install wget
yum -y install make
yum -y install cmake
yum -y install unzip
yum -y install ninja-build
yum -y install gcc-gfortran
yum -y install protobuf-compiler
yum -y install protobuf-devel
yum -y install zeromq-devel

# Centos 7 only provides ninja-build
ln -s /usr/bin/ninja-build /usr/bin/ninja

# CMake 3.13.2+ is required
mkdir /opt/cmake && cd /opt/cmake
wget -nv https://cmake.org/files/v3.13/cmake-3.13.5-Linux-x86_64.sh
sh cmake-3.13.5-Linux-x86_64.sh --prefix=/opt/cmake --skip-license
ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
rm cmake-3.13.5-Linux-x86_64.sh
cmake --version
15 changes: 14 additions & 1 deletion ci/docker/install/centos7_core.sh
Expand Up @@ -30,10 +30,23 @@ yum -y install atlas-devel # Provide clbas headerfiles
yum -y install openblas-devel
yum -y install lapack-devel
yum -y install opencv-devel
yum -y install protobuf-compiler
yum -y install protobuf-devel
yum -y install zeromq-devel
yum -y install openssl-devel
yum -y install gcc-c++-4.8.*
yum -y install make
yum -y install cmake
yum -y install wget
yum -y install unzip
yum -y install ninja-build

# Centos 7 only provides ninja-build
ln -s /usr/bin/ninja-build /usr/bin/ninja

# CMake 3.13.2+ is required
mkdir /opt/cmake && cd /opt/cmake
wget -nv https://cmake.org/files/v3.13/cmake-3.13.5-Linux-x86_64.sh
sh cmake-3.13.5-Linux-x86_64.sh --prefix=/opt/cmake --skip-license
ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
rm cmake-3.13.5-Linux-x86_64.sh
cmake --version
2 changes: 2 additions & 0 deletions ci/docker/install/ubuntu_core.sh
Expand Up @@ -47,6 +47,8 @@ apt-get install -y \
zlib1g-dev \
libedit-dev \
libxml2-dev \
libprotobuf-dev \
protobuf-compiler \
ninja-build \
software-properties-common \
sudo \
Expand Down