Skip to content

Commit 77ef1a5

Browse files
authored
fix warnings generated at compile time (#69)
* fix warnings generated at compile time * complete the modifition for while loop logic
1 parent 28903bf commit 77ef1a5

File tree

2 files changed

+34
-42
lines changed

2 files changed

+34
-42
lines changed

CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ if(WIN32)
4545
string(CONCAT PRECISION_FLAGS
4646
"/fp:fast=2 "
4747
"/Qimf-precision=high "
48-
"/Qprec-sqrt "
4948
"/Qprotect-parens "
5049
)
5150
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Ox ${WARNING_FLAGS} ${SDL_FLAGS} ${PRECISION_FLAGS}")
@@ -82,7 +81,6 @@ elseif(UNIX)
8281
"${SDL_FLAGS}"
8382
)
8483
string(CONCAT PRECISION_FLAGS
85-
"-prec-sqrt "
8684
"-fprotect-parens "
8785
"-fimf-precision=high "
8886
"-fp-model fast=2 "

mkl_umath/src/mkl_umath_loops.c.src

+34-40
Original file line numberDiff line numberDiff line change
@@ -73,40 +73,36 @@
7373

7474
#define MKL_INT_MAX ((npy_intp) ((~((MKL_UINT) 0)) >> 1))
7575

76-
#define CHUNKED_VML_CALL2(vml_func, n, type, in1, op1) \
77-
do { \
78-
npy_intp _n_ = (n); \
79-
const npy_intp _chunk_size = MKL_INT_MAX; \
80-
type *in1p = (type *) (in1); \
81-
type *op1p = (type *) (op1); \
82-
while (_n_ > _chunk_size) { \
83-
vml_func((MKL_INT) _chunk_size, in1p, op1p); \
84-
_n_ -= _chunk_size; \
85-
in1p += _chunk_size; \
86-
op1p += _chunk_size; \
87-
} \
88-
if (_n_) { \
89-
vml_func((MKL_INT) _n_, in1p, op1p); \
90-
} \
76+
#define CHUNKED_VML_CALL2(vml_func, n, type, in1, op1) \
77+
do { \
78+
npy_intp _n_ = (n); \
79+
const npy_intp _chunk_size = MKL_INT_MAX; \
80+
type *in1p = (type *) (in1); \
81+
type *op1p = (type *) (op1); \
82+
while (_n_ > 0) { \
83+
npy_intp _current_chunk = (_n_ > _chunk_size) ? _chunk_size : _n_; \
84+
vml_func((MKL_INT) _current_chunk, in1p, op1p); \
85+
_n_ -= _current_chunk; \
86+
in1p += _current_chunk; \
87+
op1p += _current_chunk; \
88+
} \
9189
} while (0)
9290

93-
#define CHUNKED_VML_CALL3(vml_func, n, type, in1, in2, op1) \
94-
do { \
95-
npy_intp _n_ = (n); \
96-
const npy_intp _chunk_size = MKL_INT_MAX; \
97-
type *in1p = (type *) (in1); \
98-
type *in2p = (type *) (in2); \
99-
type *op1p = (type *) (op1); \
100-
while (_n_ > _chunk_size) { \
101-
vml_func((MKL_INT) _chunk_size, in1p, in2p, op1p); \
102-
_n_ -= _chunk_size; \
103-
in1p += _chunk_size; \
104-
in2p += _chunk_size; \
105-
op1p += _chunk_size; \
106-
} \
107-
if (_n_) { \
108-
vml_func((MKL_INT)_n_, in1p, in2p, op1p); \
109-
} \
91+
#define CHUNKED_VML_CALL3(vml_func, n, type, in1, in2, op1) \
92+
do { \
93+
npy_intp _n_ = (n); \
94+
const npy_intp _chunk_size = MKL_INT_MAX; \
95+
type *in1p = (type *) (in1); \
96+
type *in2p = (type *) (in2); \
97+
type *op1p = (type *) (op1); \
98+
while (_n_ > 0) { \
99+
npy_intp _current_chunk = (_n_ > _chunk_size) ? _chunk_size : _n_; \
100+
vml_func((MKL_INT) _current_chunk, in1p, in2p, op1p); \
101+
_n_ -= _current_chunk; \
102+
in1p += _current_chunk; \
103+
in2p += _current_chunk; \
104+
op1p += _current_chunk; \
105+
} \
110106
} while(0)
111107

112108

@@ -120,14 +116,12 @@
120116
const type _shiftA = (shiftA); \
121117
const type _scaleB = (scaleB); \
122118
const type _shiftB = (shiftB); \
123-
while (_n_ > _chunk_size) { \
124-
vml_func(_chunk_size, in1p, in1p, _scaleA, _shiftA, _scaleB, _shiftB, op1p); \
125-
_n_ -= _chunk_size; \
126-
in1p += _chunk_size; \
127-
op1p += _chunk_size; \
128-
} \
129-
if (_n_) { \
130-
vml_func((MKL_INT)_n_, in1p, in1p, _scaleA, _shiftA, _scaleB, _shiftB, op1p); \
119+
while (_n_ > 0) { \
120+
npy_intp _current_chunk = (_n_ > _chunk_size) ? _chunk_size : _n_; \
121+
vml_func(_current_chunk, in1p, in1p, _scaleA, _shiftA, _scaleB, _shiftB, op1p); \
122+
_n_ -= _current_chunk; \
123+
in1p += _current_chunk; \
124+
op1p += _current_chunk; \
131125
} \
132126
} while(0)
133127

0 commit comments

Comments
 (0)