Skip to content

Commit

Permalink
Refactoring: remove clang warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
L3P3 committed May 11, 2023
1 parent 37fb9c8 commit 6a78e90
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ in this release or in an earlier release:
- GCC 9.3.0 (Ubuntu) verified @v207fix1
- clang 8.0.0-3 (Lubuntu) verified @v187fix1
- clang 10.0.0-4 (ubuntu) verified @v207fix1
- clang 15.0.6 (debian) @v208
- aarch64-linux-gnu-gcc 9.4.0 (Ubuntu) @v207fix1

Note:
Expand Down
2 changes: 2 additions & 0 deletions filter/DecAlpha.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ void DECAlpha::Shuffle(uint32_t& instruction) {
(instruction & 0x1F);
break;
}
default: break;
}
instruction = bswap(instruction);
}
Expand Down Expand Up @@ -173,5 +174,6 @@ void DECAlpha::Unshuffle(uint32_t& instruction) {
(instruction & 0x1F);
break;
}
default: break;
}
}
4 changes: 2 additions & 2 deletions lstm/Activations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Tanh :
__m256 const c1 = _mm256_set1_ps(0.03138777f);
__m256 const c2 = _mm256_set1_ps(0.276281267f);
__m256 const c_log2f = _mm256_set1_ps(1.442695022f);
size_t const limit = len & static_cast<size_t>(-static_cast<ptrdiff_t>(SIMDW));
size_t const limit = len & static_cast<size_t>(-static_cast<std::ptrdiff_t>(SIMDW));
size_t remainder = len & (SIMDW - 1);
for (size_t i = 0; i < limit; i += SIMDW) {
_mm_prefetch((char*)(f + i + SIMDW), _MM_HINT_T0);
Expand Down Expand Up @@ -83,7 +83,7 @@ class Logistic :
static __m256 const c_log2f = _mm256_set1_ps(1.442695022f);
static __m256 const c_log2f_2 = _mm256_set1_ps(0.721347511f);
static __m256 const vec_half = _mm256_set1_ps(0.5f);
size_t const limit = len & static_cast<size_t>(-static_cast<ptrdiff_t>(SIMDW));
size_t const limit = len & static_cast<size_t>(-static_cast<std::ptrdiff_t>(SIMDW));
size_t remainder = len & (SIMDW - 1);
for (size_t i = 0; i < limit; i += SIMDW) {
_mm_prefetch((char*)(f + i + SIMDW), _MM_HINT_T0);
Expand Down
2 changes: 1 addition & 1 deletion lstm/Adam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Adam :
__m256 const vec_bias_v = _mm256_set1_ps(bias_v);
__m256 const vec_lr = _mm256_set1_ps(learning_rate);
size_t const len = g->size();
size_t const limit = len & static_cast<size_t>(-static_cast<ptrdiff_t>(SIMDW));
size_t const limit = len & static_cast<size_t>(-static_cast<std::ptrdiff_t>(SIMDW));
size_t remainder = len & (SIMDW - 1);

for (size_t i = 0; i < limit; i += SIMDW) {
Expand Down
2 changes: 1 addition & 1 deletion lstm/Lstm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class Lstm {
#endif
void SoftMaxSimdAVX2() {
static constexpr size_t SIMDW = 8;
size_t const limit = output_size & static_cast<size_t>(-static_cast<ptrdiff_t>(SIMDW)), len = hidden.size();
size_t const limit = output_size & static_cast<size_t>(-static_cast<std::ptrdiff_t>(SIMDW)), len = hidden.size();
size_t remainder = output_size & (SIMDW - 1);
__m256 v_sum = _mm256_setzero_ps();
for (size_t i = 0; i < limit; i++)
Expand Down
6 changes: 3 additions & 3 deletions lstm/SimdFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ __attribute__((target("avx2,fma")))
#endif
float dot256_ps_fma3(float const* x1, float const* x2, size_t const len, float init) {
static constexpr size_t SIMDW = 8, CACHELINE = 64;
size_t const limit = len & static_cast<size_t>(-static_cast<ptrdiff_t>(SIMDW));
size_t const limit_x2 = len & static_cast<size_t>(-static_cast<ptrdiff_t>(SIMDW * 2));
size_t const limit = len & static_cast<size_t>(-static_cast<std::ptrdiff_t>(SIMDW));
size_t const limit_x2 = len & static_cast<size_t>(-static_cast<std::ptrdiff_t>(SIMDW * 2));
size_t remainder = len & (SIMDW - 1), i = SIMDW * 2;
__m256 sum0 = _mm256_setzero_ps();
__m256 sum1 = _mm256_setzero_ps();
Expand All @@ -69,7 +69,7 @@ __attribute__((target("avx2")))
#endif
float sum256_ps(float const* x, size_t const len, float init) {
static constexpr size_t SIMDW = 8;
size_t const limit = len & static_cast<size_t>(-static_cast<ptrdiff_t>(SIMDW)), remainder = len & (SIMDW - 1);
size_t const limit = len & static_cast<size_t>(-static_cast<std::ptrdiff_t>(SIMDW)), remainder = len & (SIMDW - 1);
if (limit > 0) {
__m256 sum = _mm256_loadu_ps(x);
for (size_t i = SIMDW; i < limit; i += SIMDW)
Expand Down
1 change: 1 addition & 0 deletions model/DecAlphaModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ class DECAlphaModel {
maps0[state].setDirect(count / 3);
break;
}
default: break;
}
}
if (count == 0) {
Expand Down
2 changes: 1 addition & 1 deletion model/MatchModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class MatchModel {
//is this position already registered?
for (uint32_t j = 0; j < numberOfActiveCandidates; j++) {
MatchInfo* oldcandidate = &matchCandidates[j];
if (isSame = oldcandidate->index == matchpos)
if ((isSame = oldcandidate->index == matchpos))
break;
}
if (!isSame) { //don't register an already registered sequence
Expand Down
6 changes: 3 additions & 3 deletions zlib/crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ unsigned long ZEXPORT crc32_z(crc, buf, len)
#endif /* DYNAMIC_CRC_TABLE */

#ifdef BYFOUR
if (sizeof(void *) == sizeof(ptrdiff_t)) {
if (sizeof(void *) == sizeof(std::ptrdiff_t)) {
z_crc_t endian;

endian = 1;
Expand Down Expand Up @@ -273,7 +273,7 @@ local unsigned long crc32_little(crc, buf, len)

c = (z_crc_t)crc;
c = ~c;
while (len && ((ptrdiff_t)buf & 3)) {
while (len && ((std::ptrdiff_t)buf & 3)) {
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
len--;
}
Expand Down Expand Up @@ -313,7 +313,7 @@ local unsigned long crc32_big(crc, buf, len)

c = ZSWAP32((z_crc_t)crc);
c = ~c;
while (len && ((ptrdiff_t)buf & 3)) {
while (len && ((std::ptrdiff_t)buf & 3)) {
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
len--;
}
Expand Down
4 changes: 2 additions & 2 deletions zlib/zutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#endif

#ifdef Z_SOLO
typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
typedef long std::ptrdiff_t; /* guess -- will be caught if guess is wrong */
#endif

#ifndef local
Expand Down Expand Up @@ -171,7 +171,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# if defined(_WIN32_WCE)
# define fdopen(fd,mode) NULL /* No fdopen() */
# ifndef _PTRDIFF_T_DEFINED
typedef int ptrdiff_t;
typedef int std::ptrdiff_t;
# define _PTRDIFF_T_DEFINED
# endif
# else
Expand Down

0 comments on commit 6a78e90

Please sign in to comment.