Skip to content

Commit

Permalink
Merge pull request #226 from slaperche-scality/fix/fix_compilation
Browse files Browse the repository at this point in the history
Fix compilation
  • Loading branch information
slaperche-scality authored Aug 3, 2018
2 parents 922eaf6 + 576727f commit 6f2c65f
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 19 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ endforeach(flag)
# Debug flags
set(DEBUG_CXX_FLAGS
-O0 -g3 -ggdb3 -fno-limit-debug-info
-ftrapv
)
foreach(flag ${DEBUG_CXX_FLAGS})
check_cxx_compiler_flag(${flag} has_flag_${flag})
Expand All @@ -162,6 +161,11 @@ foreach(flag ${DEBUG_CXX_FLAGS})
endif(has_flag_${flag})
endforeach(flag)

# Seems buggy on Clang: see https://bugs.llvm.org/show_bug.cgi?id=16404
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ftrapv")
endif()

# Release flags
set(RELEASE_CXX_FLAGS
-O3 -DNDEBUG
Expand Down
13 changes: 5 additions & 8 deletions src/fec_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ void FecCode<T>::decode_prepare(
vec::Vector<T>* words)
{
const vec::Vector<T>& fragments_ids = context.get_fragments_id();
for (int i = 0; i < this->n_data; ++i) {
for (unsigned i = 0; i < this->n_data; ++i) {
const int j = fragments_ids.get(i);
auto data = props[j].get(ValueLocation(offset, j));

Expand Down Expand Up @@ -814,7 +814,7 @@ void FecCode<T>::decode_apply(

// compute N(x) and stored in vec1_n
vec1_n.zero_fill();
for (int i = 0; i <= k - 1; ++i) {
for (unsigned i = 0; i <= k - 1; ++i) {
vec1_n.set(
fragments_ids.get(i),
this->gf->mul(words->get(i), inv_A_i.get(fragments_ids.get(i))));
Expand Down Expand Up @@ -927,11 +927,6 @@ bool FecCode<T>::decode_packet(

decode_build();

int n_words = code_len;
if (type == FecType::SYSTEMATIC) {
n_words = n_data;
}

// vector of buffers storing data read from chunk
vec::Buffers<uint8_t> words_char(n_data, buf_size);
std::vector<uint8_t*>* words_mem_char = words_char.get_mem();
Expand Down Expand Up @@ -1109,10 +1104,12 @@ void FecCode<T>::decode_apply(

unsigned k = this->n_data; // number of fragments received

assert(k != 0);

// compute N'(x) = sum_i{n_i * x^z_i}
// where n_i=v_i/A'_i(x_i)
buf1_n.zero_fill();
for (int i = 0; i <= k - 1; ++i) {
for (unsigned i = 0; i <= k - 1; ++i) {
this->gf->mul_coef_to_buf(
inv_A_i.get(fragments_ids.get(i)),
words->get(i),
Expand Down
13 changes: 11 additions & 2 deletions src/fec_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ class DecodeContext {
return *vec1_2k;
case CtxVec::V2K2:
return *vec2_2k;
// To quell an overzealous `Wreturn-type` from GCC.
default:
throw InvalidArgument("invalid Vec type");
}
}

Expand All @@ -170,6 +173,9 @@ class DecodeContext {
return *A;
case CtxPoly::S:
return *S;
// To quell an overzealous `Wreturn-type` from GCC.
default:
throw InvalidArgument("invalid Poly type");
}
}

Expand All @@ -186,6 +192,9 @@ class DecodeContext {
return *buf2_2k;
case CtxBuf::B2KMK:
return *buf1_len2k_minus_k;
// To quell an overzealous `Wreturn-type` from GCC.
default:
throw InvalidArgument("invalid Buf type");
}
}

Expand Down Expand Up @@ -222,7 +231,7 @@ class DecodeContext {
A->set(0, 1);
}

for (int i = 0; i < k; ++i) {
for (unsigned i = 0; i < k; ++i) {
A->mul_to_x_plus_coef(this->gf->sub(0, vx.get(i)));
}

Expand All @@ -239,7 +248,7 @@ class DecodeContext {

// compute 1/(x_i * A_i(x_i))
// we care only about elements corresponding to fragments_ids
for (unsigned i = 0; i < k; ++i) {
for (int i = 0; i < static_cast<int>(k); ++i) {
unsigned j = fragments_ids->get(i);
if (i != vx_zero) {
inv_A_i->set(
Expand Down
3 changes: 2 additions & 1 deletion src/fec_rs_fnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ class RsFnt : public FecCode<T> {
// vector stores r^{i} for i = 0, ... , n-1
this->r_powers = std::unique_ptr<vec::Vector<T>>(
new vec::Vector<T>(*(this->gf), this->n));
for (int i = 0; i < this->n; i++)
for (unsigned i = 0; i < this->n; i++) {
this->r_powers->set(i, this->gf->exp(this->r, i));
}
}

int get_n_outputs() override
Expand Down
3 changes: 2 additions & 1 deletion src/fec_rs_gf2n_fft.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ class RsGf2nFft : public FecCode<T> {
// vector stores r^{i} for i = 0, ... , k
this->r_powers = std::unique_ptr<vec::Vector<T>>(
new vec::Vector<T>(*(this->gf), this->n));
for (int i = 0; i < this->n; i++)
for (unsigned i = 0; i < this->n; i++) {
this->r_powers->set(i, this->gf->exp(this->r, i));
}
}

int get_n_outputs() override
Expand Down
4 changes: 2 additions & 2 deletions src/fec_rs_gf2n_fft_add.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class RsGf2nFftAdd : public FecCode<T> {
vec::Vector<T> vx(*(this->gf), k);

int vx_zero = -1;
for (int i = 0; i < this->n_data; ++i) {
for (unsigned i = 0; i < this->n_data; ++i) {
T val = betas->get(fragments_ids.get(i));
vx.set(i, val);
if (val == 0) {
Expand Down Expand Up @@ -191,7 +191,7 @@ class RsGf2nFftAdd : public FecCode<T> {

// FIXME: split this step in decode_init as multiplicative FFT
vec::Vector<T> vx(*(this->gf), k);
for (int i = 0; i < this->n_data; ++i) {
for (unsigned i = 0; i < this->n_data; ++i) {
vx.set(i, this->betas->get(fragments_ids.get(i)));
}

Expand Down
3 changes: 2 additions & 1 deletion src/fec_rs_gfp_fft.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ class RsGfpFft : public FecCode<T> {
// vector stores r^{i} for i = 0, ... , k
this->r_powers = std::unique_ptr<vec::Vector<T>>(
new vec::Vector<T>(*(this->gf), this->n));
for (int i = 0; i < this->n; i++)
for (unsigned i = 0; i < this->n; i++) {
this->r_powers->set(i, this->gf->exp(this->r, i));
}
}

int get_n_outputs() override
Expand Down
3 changes: 2 additions & 1 deletion src/fec_rs_nf4.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ class RsNf4 : public FecCode<T> {
// vector stores r^{i} for i = 0, ... , k
this->r_powers = std::unique_ptr<vec::Vector<T>>(
new vec::Vector<T>(*ngff4, this->n));
for (int i = 0; i < this->n; i++)
for (unsigned i = 0; i < this->n; i++) {
this->r_powers->set(i, ngff4->exp(this->r, i));
}
}

int get_n_outputs() override
Expand Down
2 changes: 1 addition & 1 deletion src/gf_ring.h
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ template <typename T>
void RingModN<T>::neg(size_t n, T* x) const
{
// add y to the first half of `x`
for (int i = 0; i < n; i++) {
for (size_t i = 0; i < n; i++) {
x[i] = sub(0, x[i]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/simd_256_u32.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ inline aint128 m256i_to_uint128(m256i v)
{
aint128 hi, lo;
_mm256_storeu2_m128i((m128i*)&hi, (m128i*)&lo, v);
return lo;
return lo; // NOLINT(clang-analyzer-core.uninitialized.UndefReturn)
}

inline __uint128_t add(__uint128_t a, __uint128_t b)
Expand Down

0 comments on commit 6f2c65f

Please sign in to comment.