Skip to content

Commit

Permalink
Memory reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
dominformant committed Sep 10, 2021
1 parent eb4aa63 commit a8d4278
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/correlator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,12 @@ function correlate(
start_sample,
num_samples
) where {T <: AbstractCorrelator}
accumulators = zero_accumulators(get_accumulators(correlator), downconverted_signal)
a_re = zero_accumulators(get_accumulators(correlator), downconverted_signal)
a_im = zero_accumulators(get_accumulators(correlator), downconverted_signal)
d_re = downconverted_signal.re
d_im = downconverted_signal.im
a_re = real.(accumulators)
a_im = imag.(accumulators)
@avx for i = start_sample:num_samples + start_sample - 1
for j = 1:length(accumulators)
for j = 1:length(a_re)
sample_shift = correlator_sample_shifts[j] - correlator_sample_shifts[1]
a_re[j] += d_re[i] * code[i + sample_shift]
a_im[j] += d_im[i] * code[i + sample_shift]
Expand All @@ -278,10 +277,10 @@ function correlate(
end

function zero_accumulators(accumulators::SVector, signal)
zeros(MVector{length(accumulators), eltype(signal)})
zeros(MVector{length(accumulators), real(eltype(signal))})
end
function zero_accumulators(accumulators::Vector, signal)
zeros(eltype(signal), length(accumulators))
zeros(real(eltype(signal)), length(accumulators))
end

"""
Expand Down Expand Up @@ -311,8 +310,7 @@ function correlate(
end
end

accumulators_new = SVector{N}.(eachcol(complex.(a_re, a_im)))
typeof(correlator)(map(+, get_accumulators(correlator), accumulators_new))
typeof(correlator)(map(+, get_accumulators(correlator), eachcol(complex.(a_re, a_im))))
end

function zero_accumulators(accumulators::SVector{NC, <:SVector{NA}}, signal) where {NC, NA}
Expand Down

0 comments on commit a8d4278

Please sign in to comment.