Skip to content

Commit bd97c9c

Browse files
author
Roman Dubtsov
committed
cpu: fix a few compiler warnings
1 parent a3bb2ba commit bd97c9c

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

cmake/platform.cmake

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,8 @@ elseif(UNIX OR MINGW)
110110
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
111111
set(DEF_ARCH_OPT_FLAGS "-march=native -mtune=native")
112112
endif()
113-
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
114-
# suppress warning on assumptions made regarding overflow (#146)
115-
append(CMAKE_CCXX_NOWARN_FLAGS "-Wno-strict-overflow")
116-
endif()
113+
# suppress warning on assumptions made regarding overflow (#146)
114+
append(CMAKE_CCXX_NOWARN_FLAGS "-Wno-strict-overflow")
117115
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
118116
set(DEF_ARCH_OPT_FLAGS "-xHOST")
119117
# workaround for Intel Compiler 16.0 that produces error caused

src/cpu/gemm/ref_gemm.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,12 @@ void gemm_ithr(const int M, const int N, const int K, const data_t alpha,
138138
return;
139139

140140
if ((K <= 0) || (alpha == static_cast<data_t>(0))) {
141+
ptrdiff_t MN = (ptrdiff_t)N * M;
141142
if (beta == static_cast<data_t>(0.)) {
142-
for (int j = 0; j < N * M; j++)
143+
for (ptrdiff_t j = 0; j < MN; j++)
143144
C[j] = static_cast<data_t>(0.);
144145
} else if (beta != static_cast<data_t>(1.)) {
145-
for (int j = 0; j < N * M; j++)
146+
for (ptrdiff_t j = 0; j < MN; j++)
146147
C[j] *= beta;
147148
}
148149
return;

src/cpu/jit_avx512_common_conv_winograd_kernel_f32.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ struct prefetcher_t {
9191
int cache_latency;
9292
switch (cache_type_) {
9393
case L1: cache_latency = 14; break;
94-
case L2: cache_latency = 250; break;
95-
case L3: cache_latency = 250; break;
94+
case L2:
95+
case L3:
96+
default: cache_latency = 250; break;
9697
}
9798

9899
prefetch_distance_ = div_up(cache_latency, nb_cache_lines_to_prefetch_);

src/cpu/jit_avx512_core_u8s8s32x_wino_convolution.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,22 +237,22 @@ struct jit_avx512_core_u8s8s32x_wino_conv_dst_trans_t: public jit_generator {
237237
}
238238
Zmm vreg_stg(int id) { // 8
239239
const int id_reg_stg = jcp.alpha * jcp.alpha + id;
240-
assert(id_reg_stg < jcp.alpha * jcp.alpha + 8);
240+
assert(id < 8);
241241
return Zmm(31 - id_reg_stg);
242242
}
243243
Zmm vreg_out(int id) { // 4
244244
const int id_reg_out = jcp.alpha * jcp.alpha + 8 + id;
245-
assert(id_reg_out < jcp.alpha * jcp.alpha + 12);
245+
assert(id < 4);
246246
return Zmm(31 - id_reg_out);
247247
}
248248
Xmm xmm_out(int id) { // 4
249249
const int id_reg_out = jcp.alpha * jcp.alpha + 8 + id;
250-
assert(id_reg_out < jcp.alpha * jcp.alpha + 12);
250+
assert(id < 4);
251251
return Xmm(31 - id_reg_out);
252252
}
253253
Zmm vreg_tmp(int id) { // 2
254254
const int id_reg_tmp = jcp.alpha * jcp.alpha + 12 + id;
255-
assert(id_reg_tmp < jcp.alpha * jcp.alpha + 14);
255+
assert(id < 2);
256256
return Zmm(31 - id_reg_tmp);
257257
}
258258

src/cpu/simple_concat.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ struct simple_concat_t: public cpu_primitive_t {
114114
private:
115115
static void format_perm(
116116
const int ndims, const stride_t *strides, int *perm, int *iperm) {
117+
assert(ndims >= 0);
117118
bool swapped;
118119
strides_t strides_tmp;
119120
utils::array_copy(strides_tmp, strides, ndims);

tests/benchdnn/reorder/bench_reorder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ void check(const prb_t *p) {
6767
void run() {
6868
for (auto &idt: v_idt)
6969
for (auto &odt: v_odt)
70-
for (int swap_dt = 0; swap_dt < 1 + both_dir_dt * (idt != odt); ++swap_dt)
70+
for (int swap_dt = 0; swap_dt < (both_dir_dt && idt != odt ? 2 : 1); ++swap_dt)
7171
for (auto &ifmt: v_ifmt)
7272
for (auto &ofmt: v_ofmt)
73-
for (int swap_fmt = 0; swap_fmt < 1 + both_dir_fmt * (ifmt != ofmt); ++swap_fmt)
73+
for (int swap_fmt = 0; swap_fmt < (both_dir_fmt && ifmt != ofmt ? 2 : 1); ++swap_fmt)
7474
for (auto &dims: v_dims)
7575
{
7676
reorder_conf_t reorder_conf{dims,

0 commit comments

Comments
 (0)