Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvements #30

Merged
merged 5 commits into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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 Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Tracking"
uuid = "10b2438b-ffd4-5096-aa58-44041d5c8f3b"
authors = ["Soeren Zorn <soeren.zorn@nav.rwth-aachen.de>"]
version = "0.14.7"
version = "0.14.8"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Expand Down
2 changes: 1 addition & 1 deletion src/code_replica.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function gen_code_replica!(
start_code_phase::AbstractFloat,
start_sample::Integer,
num_samples::Integer,
correlator_sample_shifts::SVector,
correlator_sample_shifts::AbstractVector,
prn::Integer
)
most_early_sample_shift = correlator_sample_shifts[end]
Expand Down
30 changes: 17 additions & 13 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 All @@ -297,21 +296,26 @@ function correlate(
start_sample,
num_samples,
) where {N}
accumulators = zero(MMatrix{N, length(correlator_sample_shifts), eltype(downconverted_signal)})
a_re = real.(accumulators)
a_im = imag.(accumulators)
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
@avx for i = start_sample:num_samples + start_sample - 1
for k = 1:size(accumulators, 2)
for j = 1:size(accumulators, 1)
for k = 1:size(a_re, 2)
for j = 1:size(a_re, 1)
shift = correlator_sample_shifts[k] - correlator_sample_shifts[1]
a_re[j,k] += d_re[i,j] * code[shift + i]
a_im[j,k] += d_im[i,j] * code[shift + i]
end
end
end

accumulators_new = SVector(eachcol(complex.(SMatrix(a_re), SMatrix(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}
zeros(MMatrix{NA, NC, real(eltype(signal))})
end
function zero_accumulators(accumulators::Vector{<:SVector{NA}}, signal) where NA
zeros(real(eltype(signal)), NA, length(accumulators))
end