Skip to content

Commit

Permalink
Remove the unnecessary carrier vector
Browse files Browse the repository at this point in the history
  • Loading branch information
coezmaden committed Nov 17, 2021
1 parent 2a24f7d commit eab881c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
17 changes: 5 additions & 12 deletions src/downconvert_and_correlate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ function downconvert_and_correlate_kernel(
res_im,
signal_re,
signal_im,
carrier_re,
carrier_im,
codes,
code_frequency,
correlator_sample_shifts,
Expand All @@ -59,16 +57,16 @@ function downconvert_and_correlate_kernel(
iq_offset = blockDim().x
cache_index = threadIdx().x - 1

code_phase = accum_re = accum_im = dw_re = dw_im = 0.0f0
code_phase = accum_re = accum_im = dw_re = dw_im = carrier_re = carrier_im = 0.0f0
mod_floor_code_phase = Int(0)

if sample_idx <= num_samples && antenna_idx <= num_ants && corr_idx <= num_corrs
# generate carrier
carrier_im[sample_idx], carrier_re[sample_idx] = CUDA.sincos(2π * ((sample_idx - 1) * carrier_frequency / sampling_frequency + carrier_phase))
carrier_im, carrier_re = CUDA.sincos(2π * ((sample_idx - 1) * carrier_frequency / sampling_frequency + carrier_phase))

# downconvert with the conjugate of the carrier
dw_re = signal_re[sample_idx, antenna_idx] * carrier_re[sample_idx] + signal_im[sample_idx, antenna_idx] * carrier_im[sample_idx]
dw_im = signal_im[sample_idx, antenna_idx] * carrier_re[sample_idx] - signal_re[sample_idx, antenna_idx] * carrier_im[sample_idx]
dw_re = signal_re[sample_idx, antenna_idx] * carrier_re + signal_im[sample_idx, antenna_idx] * carrier_im
dw_im = signal_im[sample_idx, antenna_idx] * carrier_re - signal_re[sample_idx, antenna_idx] * carrier_im

# calculate the code phase
code_phase = code_frequency / sampling_frequency * ((sample_idx - 1) + correlator_sample_shifts[corr_idx]) + start_code_phase
Expand Down Expand Up @@ -109,11 +107,8 @@ function downconvert_and_correlate_kernel_wrapper(
system,
signal,
correlator,
code_replica,
code_phase,
carrier_replica,
carrier_phase,
downconverted_signal,
code_frequency,
correlator_sample_shifts,
carrier_frequency,
Expand All @@ -138,9 +133,7 @@ function downconvert_and_correlate_kernel_wrapper(
res_re,
res_im,
signal.re,
signal.im,
carrier_replica.re,
carrier_replica.im,
signal.im,
system.codes,
Float32(code_frequency),
correlator_sample_shifts,
Expand Down
8 changes: 1 addition & 7 deletions src/tracking_loop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,8 @@ function downconvert_and_correlate!(
system,
view(signal, signal_start_sample:signal_start_sample - 1 + num_samples_left,:),
correlator,
code_replica,
code_phase,
carrier_replica,
carrier_phase,
downconverted_signal,
code_frequency,
correlator_sample_shifts,
carrier_frequency,
Expand Down Expand Up @@ -341,11 +338,8 @@ function downconvert_and_correlate!(
system,
view(signal, signal_start_sample:signal_start_sample - 1 + num_samples_left),
correlator,
code_replica,
code_phase,
carrier_replica,
carrier_phase,
downconverted_signal,
code_frequency,
correlator_sample_shifts,
carrier_frequency,
Expand All @@ -364,7 +358,7 @@ end
function choose(replica::CarrierReplicaCPU, signal::AbstractArray{Complex{T}}) where T <: Number
replica.carrier_f32
end
function choose(replica::StructVector{ComplexF32, NamedTuple{(:re, :im), Tuple{CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}, CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}}, Int64}, signal::AbstractArray)
function choose(replica::Nothing, signal::AbstractArray)
nothing
end
function choose(replica::DownconvertedSignalCPU, signal::AbstractArray{Complex{Float64}})
Expand Down
6 changes: 3 additions & 3 deletions src/tracking_state.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct TrackingState{
COLF <: AbstractLoopFilter,
CN <: AbstractCN0Estimator,
DS <: Union{DownconvertedSignalCPU, Nothing},
CAR <: Union{CarrierReplicaCPU, StructVector{ComplexF32, NamedTuple{(:re, :im), Tuple{CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}, CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}}, Int64}},
CAR <: Union{CarrierReplicaCPU, Nothing},
COR <: Union{Vector{Int8}, Nothing}
}
prn::Int
Expand Down Expand Up @@ -191,10 +191,10 @@ function TrackingState(
code_phase = mod(code_phase, get_code_length(system))
end
downconverted_signal = nothing
carrier = gen_blank_carrier_gpu(system, num_samples)
carrier = nothing
code = nothing

TrackingState{S, C, CALF, COLF, CN, Nothing, typeof(carrier), Nothing}(
TrackingState{S, C, CALF, COLF, CN, Nothing, Nothing, Nothing}(
prn,
system,
carrier_doppler,
Expand Down

0 comments on commit eab881c

Please sign in to comment.