Skip to content

Commit

Permalink
[CI] Test gcc8 -WError build CI (apache#17752)
Browse files Browse the repository at this point in the history
* Disable printing warnings for 3rdparty/openmp target

* Remove unused build_amzn_linux_cpu

* Ignore -Wclass-memaccess for gcc8 where needed

* Fix uninitialized variables in DeformablePSROIPoolingOp

* Update dmlc-core to ignore -Wmaybe-uninitialized in optional.h

* Test gcc8 -WError build on CI
  • Loading branch information
leezu authored and anirudh2290 committed May 29, 2020
1 parent 1bbb64c commit 268f654
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 24 deletions.
5 changes: 5 additions & 0 deletions 3rdparty/mshadow/mshadow/tensor_cpu-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ template<int dim, typename DType>
inline void Copy(Tensor<cpu, dim, DType> _dst,
const Tensor<cpu, dim, DType> &_src,
Stream<cpu> *stream) {
#pragma GCC diagnostic push
#if __GNUC__ >= 8
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
CHECK_EQ(_dst.shape_, _src.shape_)
<< "Copy:shape mismatch:" << _dst.shape_ << " vs " << _src.shape_;
if (_dst.CheckContiguous() && _src.CheckContiguous()) {
Expand All @@ -138,6 +142,7 @@ inline void Copy(Tensor<cpu, dim, DType> _dst,
memcpy(dst[y].dptr_, src[y].dptr_, sizeof(DType) * dst.size(1));
}
}
#pragma GCC diagnostic pop
}

template<typename Saver, typename R, int dim,
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,10 @@ if(USE_OPENMP)
set(CMAKE_BUILD_TYPE Release)
set(OPENMP_ENABLE_LIBOMPTARGET OFF CACHE BOOL "LLVM OpenMP offloading support") # Requires CMP0077 CMake 3.13
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/openmp)
# Disable warnings
target_compile_options(omp PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:-w>
$<$<CXX_COMPILER_ID:MSVC>:/w>)
endfunction()

# This should build on Windows, but there's some problem and I don't have a Windows box, so
Expand Down
31 changes: 14 additions & 17 deletions ci/docker/runtime_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -387,23 +387,6 @@ build_centos7_cpu_make() {
-j$(nproc)
}

build_amzn_linux_cpu() {
set -ex
cd /work/build
build_ccache_wrappers
cmake \
-DUSE_CUDA=OFF\
-DUSE_OPENCV=ON\
-DUSE_OPENMP=ON\
-DUSE_SIGNAL_HANDLER=ON\
-DCMAKE_BUILD_TYPE=RelWithDebInfo\
-DUSE_MKL_IF_AVAILABLE=OFF\
-DUSE_LAPACK=OFF\
-DUSE_DIST_KVSTORE=ON\
-G Ninja /work/mxnet
ninja
}

build_centos7_mkldnn() {
set -ex
cd /work/build
Expand Down Expand Up @@ -546,6 +529,20 @@ build_ubuntu_cpu_cmake_asan() {
make -j $(nproc) mlp_cpu
}

build_ubuntu_cpu_gcc8_werror() {
set -ex
cd /work/build
export CXX=g++-8
export CC=gcc-8
cmake \
-DUSE_CUDA=OFF \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DUSE_CPP_PACKAGE=ON \
-DMXNET_USE_CPU=ON \
-GNinja /work/mxnet
ninja
}

build_ubuntu_cpu_clang39() {
set -ex
cd /work/build
Expand Down
14 changes: 14 additions & 0 deletions ci/jenkins/Jenkins_steps.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,20 @@ def compile_unix_asan_cpu() {
}]
}

def compile_unix_gcc8_werror() {
return ['CPU: GCC8 -WError': {
node(NODE_LINUX_CPU) {
ws('workspace/build-cpu-gcc8') {
timeout(time: max_time, unit: 'MINUTES') {
utils.init_git()
utils.docker_run('ubuntu_cpu', 'build_ubuntu_cpu_gcc8_werror', false)
utils.pack_lib('cpu_gcc8', mx_lib)
}
}
}
}]
}

def compile_unix_amalgamation_min() {
return ['Amalgamation MIN': {
node(NODE_LINUX_CPU) {
Expand Down
5 changes: 3 additions & 2 deletions ci/jenkins/Jenkinsfile_miscellaneous
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ utils.main_wrapper(
core_logic: {
utils.parallel_stage('Build', [
custom_steps.compile_unix_asan_cpu(),
custom_steps.compile_unix_gcc8_werror(),
custom_steps.compile_unix_amalgamation_min(),
custom_steps.compile_unix_amalgamation()
])
])

utils.parallel_stage('Tests', [
custom_steps.misc_asan_cpu()
])
])
}
,
failure_handler: {
Expand Down
5 changes: 5 additions & 0 deletions src/common/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,12 @@ inline void ParallelCopy(DType* dst, const DType* src, index_t size) {
dst[i] = src[i];
}
} else {
#pragma GCC diagnostic push
#if __GNUC__ >= 8
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
std::memcpy(dst, src, sizeof(DType) * size);
#pragma GCC diagnostic pop
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/operator/contrib/boolean_mask-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ struct BooleanMaskForwardCPUKernel {
// i is row id already
int32_t prev = (i == 0) ? 0 : idx[i - 1];
int32_t curr = idx[i];
#pragma GCC diagnostic push
#if __GNUC__ >= 8
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
if (prev != curr) {
std::memcpy(out + prev * col_size, data + i * col_size, col_size * sizeof(DType));
}
#pragma GCC diagnostic pop
}
};

Expand Down
5 changes: 5 additions & 0 deletions src/operator/contrib/boolean_mask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,16 @@ struct BooleanMaskBackwardCPUWriteKernel {
// i is row id already
int32_t prev = (i == 0) ? 0 : idx[i - 1];
int32_t curr = idx[i];
#pragma GCC diagnostic push
#if __GNUC__ >= 8
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
if (prev != curr) {
std::memcpy(igrad + i * col_size, ograd + prev * col_size, col_size * sizeof(DType));
} else {
std::memset(igrad + i * col_size, 0, col_size * sizeof(DType));
}
#pragma GCC diagnostic pop
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/operator/contrib/deformable_psroi_pooling-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class DeformablePSROIPoolingOp : public Operator {
out = -FLT_MAX;
top_count = 0.0f;

Tensor<xpu, 4, DType> trans;
Tensor<xpu, 4, DType> trans{nullptr, mshadow::Shape4(0, 0, 0, 0)};
if (!param_.no_trans) {
trans = in_data[deformablepsroipool::kTrans].get<xpu, 4, DType>(s);
}
Expand Down Expand Up @@ -149,8 +149,8 @@ class DeformablePSROIPoolingOp : public Operator {
.get<xpu, 4, DType>(s);
Tensor<xpu, 4, DType> grad_in = in_grad[deformablepsroipool::kData].get<xpu, 4, DType>(s);
Tensor<xpu, 2, DType> grad_roi = in_grad[deformablepsroipool::kBox].get<xpu, 2, DType>(s);
Tensor<xpu, 4, DType> grad_trans;
Tensor<xpu, 4, DType> trans;
Tensor<xpu, 4, DType> grad_trans{nullptr, mshadow::Shape4(0, 0, 0, 0)};
Tensor<xpu, 4, DType> trans{nullptr, mshadow::Shape4(0, 0, 0, 0)};
if (!param_.no_trans) {
CHECK_EQ(in_grad.size(), 3);
trans = in_data[deformablepsroipool::kTrans].get<xpu, 4, DType>(s);
Expand Down
10 changes: 10 additions & 0 deletions src/operator/contrib/index_copy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ struct index_copy_fwd_cpu {
int dim_size) {
DType* out_ptr = out_tensor + static_cast<index_t>(idx[i]) * dim_size;
const DType* new_ptr = new_tensor + i * dim_size;
#pragma GCC diagnostic push
#if __GNUC__ >= 8
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
std::memcpy(out_ptr, new_ptr, sizeof(DType) * dim_size);
#pragma GCC diagnostic pop
}
};

Expand Down Expand Up @@ -95,7 +100,12 @@ struct index_copy_bwd_cpu {
} else if (orig_req == kNullOp) {
return;
} else {
#pragma GCC diagnostic push
#if __GNUC__ >= 8
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
std::memset(orig_ptr, 0, sizeof(DType) * dim_size);
#pragma GCC diagnostic pop
}
}
};
Expand Down
5 changes: 5 additions & 0 deletions src/operator/numpy/np_ediff1d_op-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ struct set_to_val {
template <typename DType>
void copyArr(DType* dest, DType* src, size_t count,
mshadow::Stream<cpu> *s) {
#pragma GCC diagnostic push
#if __GNUC__ >= 8
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
memcpy(dest, src, count);
#pragma GCC diagnostic pop
}

template <typename DType>
Expand Down
5 changes: 5 additions & 0 deletions src/operator/numpy/np_unique_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ struct UniqueComputeAuxCPUKernel {
MSHADOW_XINLINE static void Map(dim_t i, DType* out_data, const DType* in_data,
const dim_t* idx, const dim_t M) {
dim_t j = idx[i];
#pragma GCC diagnostic push
#if __GNUC__ >= 8
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
std::memcpy(out_data + i * M, in_data + j * M, M * sizeof(DType));
#pragma GCC diagnostic pop
}
};

Expand Down
5 changes: 5 additions & 0 deletions src/operator/random/shuffle_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ void ShuffleND(DType* const out, const index_t size, const index_t first_axis_le
for (index_t i = first_axis_len - 1; i > 0; --i) {
const index_t j = rand_n(i + 1);
if (i != j) {
#pragma GCC diagnostic push
#if __GNUC__ >= 8
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
std::memcpy(buf.dptr_, out + stride * i, stride_bytes);
std::memcpy(out + stride * i, out + stride * j, stride_bytes);
std::memcpy(out + stride * j, buf.dptr_, stride_bytes);
#pragma GCC diagnostic pop
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/operator/rnn_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,15 @@ void LstmForwardInferenceSingleLayer(DType* ws,
}
if (P > 0) {
linalg_gemm(h, whr, r, alpha, beta, false, true);
#pragma omp parallel for num_threads(omp_threads)
#pragma GCC diagnostic push
#if __GNUC__ >= 8
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
#pragma omp parallel for num_threads(omp_threads)
for (int j = 0; j < N; ++j) {
std::memcpy(y[t][j].dptr_ + proj_offset, r[j].dptr_, P * sizeof(DType));
}
#pragma GCC diagnostic pop
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/operator/tensor/indexing_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ struct TakeZeroAxisCPU {
j = j % K;
j += (j < 0) ? K : 0;
}
#pragma GCC diagnostic push
#if __GNUC__ >= 8
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
std::memcpy(out_data + i * M, in_data + j * M, M * sizeof(DType));
#pragma GCC diagnostic pop
}
};

Expand Down

0 comments on commit 268f654

Please sign in to comment.