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

Commit

Permalink
CI: Re-enable code coverage for CPU builds (#17889)
Browse files Browse the repository at this point in the history
  • Loading branch information
leezu committed Apr 4, 2020
1 parent 792011e commit b6edefb
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 49 deletions.
25 changes: 6 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ 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)
cmake_dependent_option(ENABLE_TESTCOVERAGE "Enable compilation with test coverage metric output" OFF "NOT MSVC" 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)
option(LOG_FATAL_THROW "Log exceptions but do not abort" ON)
Expand Down Expand Up @@ -256,22 +256,6 @@ if(USE_TENSORRT)
${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 )
if(NOT GCOV_PATH)
message(FATAL_ERROR "gcov not found! Aborting...")
endif() # NOT GCOV_PATH

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} --coverage")
set(GTEST_LIBRARIES "${GTEST_LIBRARIES} --coverage")
link_libraries(gcov)
endif()

if(USE_MKLDNN)
# CPU architecture (e.g., C5) can't run on another architecture (e.g., g3).
if(MSVC)
Expand Down Expand Up @@ -478,8 +462,6 @@ 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_LIBRARIES gtest gtest_main)
set(GTEST_MAIN_LIBRARY gtest_main)
set(GTEST_LIBRARY gtest)

Expand Down Expand Up @@ -709,6 +691,11 @@ if(UNIX)
string(APPEND CMAKE_CUDA_FLAGS " -Werror=cross-execution-space-call")
endif()
endif()
if(ENABLE_TESTCOVERAGE)
find_program(GCOV_PATH gcov REQUIRED)
target_compile_options(mxnet_static PUBLIC "--coverage")
target_link_libraries(mxnet_static PUBLIC gcov)
endif()
elseif(MSVC)
if(USE_CUDA)
if(USE_SPLIT_ARCH_DLL)
Expand Down
24 changes: 14 additions & 10 deletions ci/docker/runtime_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ build_centos7_cpu() {
cd /work/build
cmake \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DENABLE_TESTCOVERAGE=ON \
-DUSE_MKL_IF_AVAILABLE=OFF \
-DUSE_MKLDNN=OFF \
-DUSE_DIST_KVSTORE=ON \
Expand Down Expand Up @@ -372,7 +373,6 @@ build_centos7_mkldnn() {
set -ex
cd /work/build
cmake \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DUSE_MKL_IF_AVAILABLE=OFF \
-DUSE_MKLDNN=ON \
-DUSE_CUDA=OFF \
Expand Down Expand Up @@ -401,8 +401,9 @@ build_ubuntu_cpu() {
build_ubuntu_cpu_openblas() {
set -ex
cd /work/build
cmake \
CXXFLAGS="-Wno-error=strict-overflow" cmake \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DENABLE_TESTCOVERAGE=ON \
-DUSE_TVM_OP=ON \
-DUSE_CPP_PACKAGE=ON \
-DUSE_MKL_IF_AVAILABLE=OFF \
Expand Down Expand Up @@ -437,6 +438,7 @@ build_ubuntu_cpu_mkl() {
cd /work/build
cmake \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DENABLE_TESTCOVERAGE=ON \
-DUSE_MKLDNN=OFF \
-DUSE_CUDA=OFF \
-DUSE_TVM_OP=ON \
Expand All @@ -450,13 +452,14 @@ build_ubuntu_cpu_cmake_debug() {
set -ex
cd /work/build
cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DENABLE_TESTCOVERAGE=ON \
-DUSE_CUDA=OFF \
-DUSE_TVM_OP=ON \
-DUSE_MKL_IF_AVAILABLE=OFF \
-DUSE_OPENMP=OFF \
-DUSE_OPENCV=ON \
-DUSE_SIGNAL_HANDLER=ON \
-DCMAKE_BUILD_TYPE=Debug \
-G Ninja \
/work/mxnet
ninja
Expand Down Expand Up @@ -639,12 +642,13 @@ build_ubuntu_cpu_mkldnn() {
cd /work/build
cmake \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DUSE_MKL_IF_AVAILABLE=OFF \
-DUSE_TVM_OP=ON \
-DUSE_MKLDNN=ON \
-DUSE_CUDA=OFF \
-DUSE_CPP_PACKAGE=ON \
-G Ninja /work/mxnet
-DENABLE_TESTCOVERAGE=ON \
-DUSE_MKL_IF_AVAILABLE=OFF \
-DUSE_TVM_OP=ON \
-DUSE_MKLDNN=ON \
-DUSE_CUDA=OFF \
-DUSE_CPP_PACKAGE=ON \
-G Ninja /work/mxnet
ninja
}

Expand All @@ -653,6 +657,7 @@ build_ubuntu_cpu_mkldnn_mkl() {
cd /work/build
cmake \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DENABLE_TESTCOVERAGE=ON \
-DUSE_MKLDNN=ON \
-DUSE_CUDA=OFF \
-DUSE_TVM_OP=ON \
Expand Down Expand Up @@ -922,7 +927,6 @@ build_ubuntu_cpu_large_tensor() {
-DUSE_CUDA=OFF \
-DUSE_CUDNN=OFF \
-DUSE_MKLDNN=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_INT64_TENSOR_SIZE=ON \
-G Ninja \
/work/mxnet
Expand Down
38 changes: 18 additions & 20 deletions ci/jenkins/Jenkins_steps.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def compile_unix_cpu_openblas() {
timeout(time: max_time, unit: 'MINUTES') {
utils.init_git()
utils.docker_run('ubuntu_cpu', 'build_ubuntu_cpu_openblas', false)
utils.pack_lib('cpu', mx_lib_cython)
utils.pack_lib('cpu', mx_lib_cython, true)
}
}
}
Expand Down Expand Up @@ -125,7 +125,7 @@ def compile_unix_openblas_debug_cpu() {
timeout(time: max_time, unit: 'MINUTES') {
utils.init_git()
utils.docker_run('ubuntu_cpu', 'build_ubuntu_cpu_cmake_debug', false)
utils.pack_lib('cpu_debug', mx_cmake_lib_debug)
utils.pack_lib('cpu_debug', mx_cmake_lib_debug, true)
}
}
}
Expand Down Expand Up @@ -153,7 +153,6 @@ def compile_unix_int64_cpu() {
timeout(time: max_time, unit: 'MINUTES') {
utils.init_git()
utils.docker_run('ubuntu_cpu', 'build_ubuntu_cpu_large_tensor', false)
utils.pack_lib('ubuntu_cpu_int64', mx_cmake_lib)
}
}
}
Expand Down Expand Up @@ -181,7 +180,7 @@ def compile_unix_mkl_cpu() {
timeout(time: max_time, unit: 'MINUTES') {
utils.init_git()
utils.docker_run('ubuntu_cpu', 'build_ubuntu_cpu_mkl', false)
utils.pack_lib('cpu_mkl', mx_lib)
utils.pack_lib('cpu_mkl', mx_lib, true)
}
}
}
Expand All @@ -195,7 +194,7 @@ def compile_unix_mkldnn_cpu() {
timeout(time: max_time, unit: 'MINUTES') {
utils.init_git()
utils.docker_run('ubuntu_cpu', 'build_ubuntu_cpu_mkldnn', false)
utils.pack_lib('mkldnn_cpu', mx_mkldnn_lib)
utils.pack_lib('mkldnn_cpu', mx_mkldnn_lib, true)
}
}
}
Expand Down Expand Up @@ -223,7 +222,7 @@ def compile_unix_mkldnn_mkl_cpu() {
timeout(time: max_time, unit: 'MINUTES') {
utils.init_git()
utils.docker_run('ubuntu_cpu', 'build_ubuntu_cpu_mkldnn_mkl', false)
utils.pack_lib('mkldnn_mkl_cpu', mx_mkldnn_lib)
utils.pack_lib('mkldnn_mkl_cpu', mx_mkldnn_lib, true)
}
}
}
Expand Down Expand Up @@ -375,7 +374,7 @@ def compile_centos7_cpu() {
timeout(time: max_time, unit: 'MINUTES') {
utils.init_git()
utils.docker_run('centos7_cpu', 'build_centos7_cpu', false)
utils.pack_lib('centos7_cpu', mx_lib)
utils.pack_lib('centos7_cpu', mx_lib, true)
}
}
}
Expand Down Expand Up @@ -403,7 +402,6 @@ def compile_centos7_cpu_mkldnn() {
timeout(time: max_time, unit: 'MINUTES') {
utils.init_git()
utils.docker_run('centos7_cpu', 'build_centos7_mkldnn', false)
utils.pack_lib('centos7_mkldnn', mx_mkldnn_lib)
}
}
}
Expand Down Expand Up @@ -806,7 +804,7 @@ def test_unix_python3_cpu() {
node(NODE_LINUX_CPU) {
ws('workspace/ut-python3-cpu') {
try {
utils.unpack_and_init('cpu', mx_lib)
utils.unpack_and_init('cpu', mx_lib, true)
python3_ut('ubuntu_cpu')
utils.publish_test_coverage()
} finally {
Expand All @@ -823,7 +821,7 @@ def test_unix_python3_mkl_cpu() {
node(NODE_LINUX_CPU) {
ws('workspace/ut-python3-cpu') {
try {
utils.unpack_and_init('cpu_mkl', mx_lib)
utils.unpack_and_init('cpu_mkl', mx_lib, true)
python3_ut('ubuntu_cpu')
utils.publish_test_coverage()
} finally {
Expand Down Expand Up @@ -890,7 +888,7 @@ def test_unix_python3_debug_cpu() {
node(NODE_LINUX_CPU) {
ws('workspace/ut-python3-cpu-debug') {
try {
utils.unpack_and_init('cpu_debug', mx_cmake_lib_debug)
utils.unpack_and_init('cpu_debug', mx_cmake_lib_debug, true)
python3_ut('ubuntu_cpu')
} finally {
utils.collect_test_results_unix('nosetests_unittest.xml', 'nosetests_python3_cpu_debug_unittest.xml')
Expand Down Expand Up @@ -922,7 +920,7 @@ def test_unix_python3_mkldnn_cpu() {
node(NODE_LINUX_CPU) {
ws('workspace/ut-python3-mkldnn-cpu') {
try {
utils.unpack_and_init('mkldnn_cpu', mx_mkldnn_lib)
utils.unpack_and_init('mkldnn_cpu', mx_mkldnn_lib, true)
python3_ut_mkldnn('ubuntu_cpu')
utils.publish_test_coverage()
} finally {
Expand All @@ -939,7 +937,7 @@ def test_unix_python3_mkldnn_mkl_cpu() {
node(NODE_LINUX_CPU) {
ws('workspace/ut-python3-mkldnn-mkl-cpu') {
try {
utils.unpack_and_init('mkldnn_mkl_cpu', mx_lib)
utils.unpack_and_init('mkldnn_mkl_cpu', mx_lib, true)
python3_ut_mkldnn('ubuntu_cpu')
utils.publish_test_coverage()
} finally {
Expand Down Expand Up @@ -1132,7 +1130,7 @@ def test_unix_r_cpu() {
node(NODE_LINUX_CPU) {
ws('workspace/ut-r-cpu') {
timeout(time: max_time, unit: 'MINUTES') {
utils.unpack_and_init('cpu', mx_lib)
utils.unpack_and_init('cpu', mx_lib, true)
utils.docker_run('ubuntu_cpu', 'unittest_ubuntu_cpu_R', false)
utils.publish_test_coverage()
}
Expand All @@ -1146,7 +1144,7 @@ def test_unix_r_mkldnn_cpu() {
node(NODE_LINUX_CPU) {
ws('workspace/ut-r-mkldnn-cpu') {
timeout(time: max_time, unit: 'MINUTES') {
utils.unpack_and_init('mkldnn_cpu', mx_mkldnn_lib)
utils.unpack_and_init('mkldnn_cpu', mx_mkldnn_lib, true)
utils.docker_run('ubuntu_cpu', 'unittest_ubuntu_minimal_R', false)
utils.publish_test_coverage()
}
Expand Down Expand Up @@ -1188,7 +1186,7 @@ def test_unix_cpp_cpu() {
node(NODE_LINUX_CPU) {
ws('workspace/ut-cpp-cpu') {
timeout(time: max_time, unit: 'MINUTES') {
utils.unpack_and_init('cpu_debug', mx_cmake_lib_debug)
utils.unpack_and_init('cpu_debug', mx_cmake_lib_debug, true)
utils.docker_run('ubuntu_cpu', 'unittest_cpp', false)
utils.publish_test_coverage()
}
Expand Down Expand Up @@ -1230,7 +1228,7 @@ def test_unix_julia07_cpu() {
node(NODE_LINUX_CPU) {
ws('workspace/ut-it-julia07-cpu') {
timeout(time: max_time, unit: 'MINUTES') {
utils.unpack_and_init('cpu', mx_lib)
utils.unpack_and_init('cpu', mx_lib, true)
utils.docker_run('ubuntu_cpu', 'unittest_ubuntu_cpu_julia07', false)
}
}
Expand All @@ -1243,7 +1241,7 @@ def test_unix_julia10_cpu() {
node(NODE_LINUX_CPU) {
ws('workspace/ut-it-julia10-cpu') {
timeout(time: max_time, unit: 'MINUTES') {
utils.unpack_and_init('cpu', mx_lib)
utils.unpack_and_init('cpu', mx_lib, true)
utils.docker_run('ubuntu_cpu', 'unittest_ubuntu_cpu_julia10', false)
}
}
Expand All @@ -1270,7 +1268,7 @@ def test_unix_distributed_kvstore_cpu() {
node(NODE_LINUX_CPU) {
ws('workspace/it-dist-kvstore') {
timeout(time: max_time, unit: 'MINUTES') {
utils.unpack_and_init('cpu', mx_lib)
utils.unpack_and_init('cpu', mx_lib, true)
utils.docker_run('ubuntu_cpu', 'integrationtest_ubuntu_cpu_dist_kvstore', false)
utils.publish_test_coverage()
}
Expand Down Expand Up @@ -1299,7 +1297,7 @@ def test_centos7_python3_cpu() {
ws('workspace/build-centos7-cpu') {
timeout(time: max_time, unit: 'MINUTES') {
try {
utils.unpack_and_init('centos7_cpu', mx_lib)
utils.unpack_and_init('centos7_cpu', mx_lib, true)
utils.docker_run('centos7_cpu', 'unittest_centos7_cpu', false)
utils.publish_test_coverage()
} finally {
Expand Down

0 comments on commit b6edefb

Please sign in to comment.