Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ endif()

# Release flags
set(RELEASE_CXX_FLAGS
-O3 -DNDEBUG
-O3 -DNDEBUG -flto=full
)
foreach(flag ${RELEASE_CXX_FLAGS})
check_cxx_compiler_flag(${flag} has_flag_${flag})
Expand Down
32 changes: 15 additions & 17 deletions scripts/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,22 @@ fi

chunk_size=51200
# for rs-fnt with different packet sizes
word_size=2
for word_size in 1 2; do
for type_size in 2 4; do
max_len=$((256**word_size))
if ((type_size>word_size)); then
for ec_type in rs-fnt rs-fnt-sys; do
for k in 16 64; do
for n in 32 256 1024; do
if ((n<max_len)) && ((n>k)); then
m=$((n-k))
for pkt_size in 512; do
${bin} -e ${ec_type} -w ${word_size} -t ${type_size} -k ${k} -m ${m} -c ${chunk_size} -s ${sce_type} -g ${threads_nb} -f ${show_type} -p ${pkt_size} -n ${samples_nb}
show_type=0
done
fi
type_size=$((word_size*2))
max_len=$((256**word_size))
if ((type_size>word_size)); then
for ec_type in rs-fnt rs-fnt-sys; do
for k in 16 64; do
for n in 32 256 1024; do
if ((n<max_len)) && ((n>k)); then
m=$((n-k))
for pkt_size in 32 64 128 256 512 1024; do
${bin} -e ${ec_type} -w ${word_size} -t ${type_size} -k ${k} -m ${m} -c ${chunk_size} -s ${sce_type} -g ${threads_nb} -f ${show_type} -p ${pkt_size} -n ${samples_nb}
show_type=0
done
done
fi
done
fi
done
done
done
fi
done
1 change: 0 additions & 1 deletion scripts/test_ec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ do
fec_type=$(echo $i|cut -d_ -f1)
word_size=$(echo $i|cut -d_ -f2)

do_test enconly ${fec_type} ${word_size} 50 50 "" ""
do_test all ${fec_type} ${word_size} 3 3 "" ""
do_test all ${fec_type} ${word_size} 3 3 "0 1" "0"
do_test all ${fec_type} ${word_size} 3 5 "0 1" "0"
Expand Down
11 changes: 10 additions & 1 deletion src/quadiron_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,16 @@ int quadiron_fnt32_decode(
if (!res)
return -1;

// reset metadata of data
for (unsigned i = 0; i < fec->n_data; i++) {
parities_props[i].clear();
uint32_t* metadata = reinterpret_cast<uint32_t*>(data[i]);
int ret = parities_props[i].fnt_serialize(metadata, metadata_size / 4);
if (ret == -1) {
return -1;
}
}

return 0;
}

Expand Down Expand Up @@ -262,7 +272,6 @@ int quadiron_fnt32_reconstruct(
return -1;
}
parities_vec[i] = data[i] + metadata_size;
data_vec[i] = data[i] + metadata_size;
}
for (unsigned i = 0; i < fec->n_parities; i++) {
if (!missing_idxs[fec->n_data + i]) {
Expand Down
80 changes: 37 additions & 43 deletions src/simd_128.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,23 @@ typedef __m128i VecType;

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

// @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 = _mm_set1_epi32(65537);
// NOLINTNEXTLINE(cert-err58-cpp)
const VecType F4_MINUS_ONE_U32 = _mm_set1_epi32(65536);
// NOLINTNEXTLINE(cert-err58-cpp)
const VecType F3_U32 = _mm_set1_epi32(257);
// NOLINTNEXTLINE(cert-err58-cpp)
const VecType F3_MINUS_ONE_U32 = _mm_set1_epi32(256);

// NOLINTNEXTLINE(cert-err58-cpp)
const VecType F3_U16 = _mm_set1_epi16(257);
// NOLINTNEXTLINE(cert-err58-cpp)
const VecType F3_MINUS_ONE_U16 = _mm_set1_epi16(256);
template <typename T>
inline VecType one();
template <>
inline VecType one<uint16_t>()
{
return _mm_set1_epi16(1);
}
template <>
inline VecType one<uint32_t>()
{
return _mm_set1_epi32(1);
}

// NOLINTNEXTLINE(cert-err58-cpp)
const VecType ZERO = _mm_setzero_si128();
// NOLINTNEXTLINE(cert-err58-cpp)
const VecType ONE_U16 = _mm_set1_epi16(1);
// NOLINTNEXTLINE(cert-err58-cpp)
const VecType ONE_U32 = _mm_set1_epi32(1);
inline VecType zero()
{
return _mm_setzero_si128();
}

// NOLINTNEXTLINE(cert-err58-cpp)
const VecType MASK8_LO = _mm_set1_epi16(0x80);
Expand All @@ -78,25 +72,25 @@ inline void store_to_mem(VecType* address, VecType reg)
_mm_store_si128(address, reg);
}

inline VecType bit_and(VecType x, VecType y)
inline VecType bit_and(const VecType& x, const VecType& y)
{
return _mm_and_si128(x, y);
}
inline VecType bit_xor(VecType x, VecType y)
inline VecType bit_xor(const VecType& x, const VecType& y)
{
return _mm_xor_si128(x, y);
}
inline uint16_t msb8_mask(VecType x)
inline uint16_t msb8_mask(const VecType& x)
{
return _mm_movemask_epi8(x);
}
inline bool and_is_zero(VecType x, VecType y)
inline bool and_is_zero(const VecType& x, const VecType& y)
{
return _mm_testz_si128(x, y);
}
inline bool is_zero(VecType x)
inline bool is_zero(const VecType& x)
{
return _mm_testc_si128(ZERO, x);
return _mm_testc_si128(zero(), x);
}

#define SHIFTR(x, imm8) (_mm_srli_si128(x, imm8))
Expand All @@ -119,66 +113,66 @@ inline VecType set_one(uint16_t val)
}

template <typename T>
inline VecType add(VecType x, VecType y);
inline VecType add(const VecType& x, const VecType& y);
template <>
inline VecType add<uint32_t>(VecType x, VecType y)
inline VecType add<uint32_t>(const VecType& x, const VecType& y)
{
return _mm_add_epi32(x, y);
}
template <>
inline VecType add<uint16_t>(VecType x, VecType y)
inline VecType add<uint16_t>(const VecType& x, const VecType& y)
{
return _mm_add_epi16(x, y);
}

template <typename T>
inline VecType sub(VecType x, VecType y);
inline VecType sub(const VecType& x, const VecType& y);
template <>
inline VecType sub<uint32_t>(VecType x, VecType y)
inline VecType sub<uint32_t>(const VecType& x, const VecType& y)
{
return _mm_sub_epi32(x, y);
}
template <>
inline VecType sub<uint16_t>(VecType x, VecType y)
inline VecType sub<uint16_t>(const VecType& x, const VecType& y)
{
return _mm_sub_epi16(x, y);
}

template <typename T>
inline VecType mul(VecType x, VecType y);
inline VecType mul(const VecType& x, const VecType& y);
template <>
inline VecType mul<uint32_t>(VecType x, VecType y)
inline VecType mul<uint32_t>(const VecType& x, const VecType& y)
{
return _mm_mullo_epi32(x, y);
}
template <>
inline VecType mul<uint16_t>(VecType x, VecType y)
inline VecType mul<uint16_t>(const VecType& x, const VecType& y)
{
return _mm_mullo_epi16(x, y);
}

template <typename T>
inline VecType compare_eq(VecType x, VecType y);
inline VecType compare_eq(const VecType& x, const VecType& y);
template <>
inline VecType compare_eq<uint32_t>(VecType x, VecType y)
inline VecType compare_eq<uint32_t>(const VecType& x, const VecType& y)
{
return _mm_cmpeq_epi32(x, y);
}
template <>
inline VecType compare_eq<uint16_t>(VecType x, VecType y)
inline VecType compare_eq<uint16_t>(const VecType& x, const VecType& y)
{
return _mm_cmpeq_epi16(x, y);
}

template <typename T>
inline VecType min(VecType x, VecType y);
inline VecType min(const VecType& x, const VecType& y);
template <>
inline VecType min<uint32_t>(VecType x, VecType y)
inline VecType min<uint32_t>(const VecType& x, const VecType& y)
{
return _mm_min_epu32(x, y);
}
template <>
inline VecType min<uint16_t>(VecType x, VecType y)
inline VecType min<uint16_t>(const VecType& x, const VecType& y)
{
return _mm_min_epu16(x, y);
}
Expand Down
Loading