Skip to content

Commit

Permalink
SIMD 256: use const
Browse files Browse the repository at this point in the history
  • Loading branch information
lamphamsy committed Dec 20, 2018
1 parent 3bd2d46 commit ed82ce8
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions src/simd_256.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,32 @@ typedef __m128i HalfVecType;

/* ============= Constant variable ============ */

#define F4_U32 _mm256_set1_epi32(65537)
#define F4_MINUS_ONE_U32 _mm256_set1_epi32(65536)
#define F3_U32 _mm256_set1_epi32(257)
#define F3_MINUS_ONE_U32 _mm256_set1_epi32(256)

#define F3_U16 _mm256_set1_epi16(257)
#define F3_MINUS_ONE_U16 _mm256_set1_epi16(256)

#define ZERO (_mm256_setzero_si256())
#define ONE_U16 (_mm256_set1_epi16(1))
#define ONE_U32 (_mm256_set1_epi32(1))

#define MASK8_LO (_mm256_set1_epi16(0x80))
// @note: using const leads to an lint error of initialization of 'variable'
// with static storage duration may throw an exception that cannot be caught

// NOLINTNEXTLINE(cert-err58-cpp)
const VecType F4_U32 = _mm256_set1_epi32(65537);
// NOLINTNEXTLINE(cert-err58-cpp)
const VecType F4_MINUS_ONE_U32 = _mm256_set1_epi32(65536);
// NOLINTNEXTLINE(cert-err58-cpp)
const VecType F3_U32 = _mm256_set1_epi32(257);
// NOLINTNEXTLINE(cert-err58-cpp)
const VecType F3_MINUS_ONE_U32 = _mm256_set1_epi32(256);

// NOLINTNEXTLINE(cert-err58-cpp)
const VecType F3_U16 = _mm256_set1_epi16(257);
// NOLINTNEXTLINE(cert-err58-cpp)
const VecType F3_MINUS_ONE_U16 = _mm256_set1_epi16(256);

// NOLINTNEXTLINE(cert-err58-cpp)
const VecType ZERO = _mm256_setzero_si256();
// NOLINTNEXTLINE(cert-err58-cpp)
const VecType ONE_U16 = _mm256_set1_epi16(1);
// NOLINTNEXTLINE(cert-err58-cpp)
const VecType ONE_U32 = _mm256_set1_epi32(1);

// NOLINTNEXTLINE(cert-err58-cpp)
const VecType MASK8_LO = _mm256_set1_epi16(0x80);

/* ============= Essential Operations for AVX2 w/ both u16 & u32 ============ */

Expand Down

0 comments on commit ed82ce8

Please sign in to comment.