Skip to content
Open
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
8 changes: 8 additions & 0 deletions src/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ template <typename Type>
struct DoubleSize {
};
template <>
struct DoubleSize<uint8_t> {
typedef uint16_t T;
};
template <>
struct DoubleSize<uint16_t> {
typedef uint32_t T;
};
Expand All @@ -62,6 +66,10 @@ template <typename Type>
struct SignedDoubleSize {
};
template <>
struct SignedDoubleSize<uint8_t> {
typedef int16_t T;
};
template <>
struct SignedDoubleSize<uint16_t> {
typedef int32_t T;
};
Expand Down
2 changes: 1 addition & 1 deletion src/fec_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ void FecCode<T>::decode(
if (type == FecType::SYSTEMATIC) {
this->fft->fft(*dec_inter_codeword, output);
for (unsigned i = 0; i < this->n_data; i++) {
output.copy(i, dec_inter_codeword->get(i));
output.copy(*dec_inter_codeword, i, i);
}
}
}
Expand Down
37 changes: 7 additions & 30 deletions src/fft_2n.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class Radix2 : public FourierTransform<T> {
size_t simd_trailing_len;
size_t simd_offset;

std::unique_ptr<T[]> rev = nullptr;
std::vector<T> rev;
std::unique_ptr<vec::Vector<T>> W = nullptr;
std::unique_ptr<vec::Vector<T>> inv_W = nullptr;
T* vec_W;
Expand Down Expand Up @@ -192,7 +192,7 @@ Radix2<T>::Radix2(const gf::Field<T>& gf, int n, int data_len, size_t pkt_size)
card = this->gf->card();
card_minus_one = this->gf->card_minus_one();

rev = std::unique_ptr<T[]>(new T[n]);
rev.reserve(n);
init_bitrev();

// Indices used for accelerated functions
Expand Down Expand Up @@ -361,21 +361,7 @@ void Radix2<T>::fft(vec::Buffers<T>& output, vec::Buffers<T>& input)
const unsigned group_len =
(input_len > data_len) ? len / input_len : len / data_len;

const std::vector<T*>& i_mem = input.get_mem();
const std::vector<T*>& o_mem = output.get_mem();

for (unsigned idx = 0; idx < input_len; ++idx) {
// set output = scramble(input), i.e. bit reversal ordering
for (unsigned i = rev[idx]; i < rev[idx] + group_len; ++i) {
memcpy(o_mem[i], i_mem[idx], buf_size);
}
}
for (unsigned idx = input_len; idx < data_len; ++idx) {
// set output = scramble(input), i.e. bit reversal ordering
for (unsigned i = rev[idx]; i < rev[idx] + group_len; ++i) {
memset(o_mem[i], 0, buf_size);
}
}
output.radix2_fft_prepare(input, rev, data_len, group_len);

// ----------------------
// Two layers at a time
Expand Down Expand Up @@ -513,38 +499,29 @@ void Radix2<T>::fft_inv(vec::Buffers<T>& output, vec::Buffers<T>& input)
bit_rev_permute(output);

// copy input to output
const std::vector<T*>& i_mem = input.get_mem();
const std::vector<T*>& o_mem = output.get_mem();
unsigned i;
for (i = 0; i < input_len; ++i) {
memcpy(o_mem[i], i_mem[i], buf_size);
}
output.radix2_fft_inv_prepare(input);

unsigned m = len / 2;
unsigned doubled_m = len;

if (input_len < len) {
const unsigned input_len_power_2 = arith::ceil2<unsigned>(input_len);
for (; i < input_len_power_2; ++i) {
memset(o_mem[i], 0, buf_size);
}

// For Q are zeros only => Q = c * P
for (; m >= input_len; m /= 2) {
unsigned doubled_m = 2 * m;
for (unsigned j = 0; j < m; ++j) {
const T r = inv_W->get(j * len / doubled_m);
butterfly_gs_step_simple(output, r, j, m, doubled_m);
}
doubled_m = m;
}
}

// Next, normal butterlfy GS is performed
for (; m >= 1; m /= 2) {
unsigned doubled_m = 2 * m;
for (unsigned j = 0; j < m; ++j) {
const T r = inv_W->get(j * len / doubled_m);
butterfly_gs_step(output, r, j, m, doubled_m);
}
doubled_m = m;
}

// 2nd reversion of elements of output to return its natural order
Expand Down
8 changes: 4 additions & 4 deletions src/fft_single.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ void Single<T>::ifft(vec::Vector<T>& output, vec::Vector<T>& input)
template <typename T>
void Single<T>::fft(vec::Buffers<T>& output, vec::Buffers<T>& input)
{
T* buf = input.get(0);
for (int i = 0; i < this->n; i++)
output.copy(i, buf);
for (int i = 0; i < this->n; i++) {
output.copy(input, 0, i);
}
}

/*
Expand All @@ -109,7 +109,7 @@ template <typename T>
void Single<T>::ifft(vec::Buffers<T>& output, vec::Buffers<T>& input)
{
output.zero_fill();
output.copy(0, input.get(0));
output.copy(input, 0, 0);
}

} // namespace fft
Expand Down
4 changes: 2 additions & 2 deletions src/gf_ring.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,11 @@ inline void RingModN<T>::mul_vec_to_vecp(
if (coef > 1 && coef < h) {
this->mul_coef_to_buf(coef, src_mem[i], dest_mem[i], len);
} else if (coef == 1) {
dest.copy(i, src_mem[i]);
dest.copy(src, i, i);
} else if (coef == 0) {
dest.fill(i, 0);
} else if (coef == h) {
dest.copy(i, src_mem[i]);
dest.copy(src, i, i);
this->neg(len, dest_mem[i]);
}
}
Expand Down
Loading