Skip to content

Commit

Permalink
Remove unnecessary structs
Browse files Browse the repository at this point in the history
  • Loading branch information
Can Ozmaden committed Nov 17, 2021
1 parent ccb75f0 commit 2a24f7d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 57 deletions.
4 changes: 2 additions & 2 deletions src/downconvert_and_correlate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ function downconvert_and_correlate_kernel_wrapper(
res_im,
signal.re,
signal.im,
carrier_replica.carrier.re,
carrier_replica.carrier.im,
carrier_replica.re,
carrier_replica.im,
system.codes,
Float32(code_frequency),
correlator_sample_shifts,
Expand Down
12 changes: 6 additions & 6 deletions src/tracking_loop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -364,17 +364,17 @@ end
function choose(replica::CarrierReplicaCPU, signal::AbstractArray{Complex{T}}) where T <: Number
replica.carrier_f32
end
function choose(replica::CarrierReplicaGPU, signal::AbstractArray)
replica.carrier
function choose(replica::StructVector{ComplexF32, NamedTuple{(:re, :im), Tuple{CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}, CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}}, Int64}, signal::AbstractArray)
nothing
end
function choose(replica::DownconvertedSignalCPU, signal::AbstractArray{Complex{Float64}})
replica.downconverted_signal_f64
end
function choose(replica::DownconvertedSignalCPU, signal::AbstractArray{Complex{T}}) where T <: Number
replica.downconverted_signal_f32
end
function choose(replica::DownconvertedSignalGPU, signal::AbstractArray)
replica.downconverted_signal
function choose(replica::Nothing, signal::AbstractArray)
nothing
end

"""
Expand Down Expand Up @@ -509,10 +509,10 @@ function resize!(ds::DownconvertedSignalCPU, b::Integer, signal::AbstractMatrix{
end

# No need for resizing when dealing with GPU signals
function resize!(ds::DownconvertedSignalGPU, b::Integer, signal::AbstractArray)
function resize!(ds::Nothing, b::Integer, signal::AbstractArray)
return ds
end
# No need for resizing the GPU GNSS codes
function resize!(codes::typeof(nothing), b::Integer)
function resize!(codes::Nothing, b::Integer)
return codes
end
56 changes: 7 additions & 49 deletions src/tracking_state.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,6 @@ function CarrierReplicaCPU()
StructArray{Complex{Float64}}(undef, 0)
)
end

"""
$(SIGNATURES)
CarrierReplicaCPU that holds possible carrier representations.
The type is unknown, when TrackingState is initialized.
It is determined based on the signal, which is given in the track
function.
"""
struct CarrierReplicaGPU{
CF32 <: StructArray{ComplexF32}
}
carrier::CF32
end

function CarrierReplicaGPU(num_samples)
CarrierReplicaGPU(StructArray{ComplexF32}((CuArray{Float32}(undef, num_samples),CuArray{Float32}(undef, num_samples))))
end

"""
$(SIGNATURES)
Expand Down Expand Up @@ -69,31 +50,7 @@ function DownconvertedSignalCPU(num_ants::NumAnts{N}) where N
)
end

"""
$(SIGNATURES)
DownconvertedSignalGPU that holds possible downconverted signal representations.
The type is unknown, when TrackingState is initialized.
It is determined based on the signal, which is given in the track
function.
"""
struct DownconvertedSignalGPU{
DSF32 <: StructArray{ComplexF32}
}
downconverted_signal::DSF32
end

function DownconvertedSignalGPU(num_samples, num_ants::NumAnts{1})
DownconvertedSignalGPU(
StructArray{ComplexF32}((CuArray{Float32}(undef, num_samples), CuArray{Float32}(undef, num_samples)))
)
end

function DownconvertedSignalGPU(num_samples, num_ants::NumAnts{N}) where N
DownconvertedSignalGPU(
StructArray{ComplexF32}((CuArray{Float32}(undef, (num_samples, N)),CuArray{Float32}(undef, (num_samples, N))))
)
end
@inline gen_blank_carrier_gpu(system::S, num_samples) where {CO <: CuMatrix,S <: AbstractGNSS{CO}} = StructArray{ComplexF32}((CuArray{Float32}(undef, num_samples), CuArray{Float32}(undef, num_samples)))

"""
$(SIGNATURES)
Expand All @@ -106,8 +63,8 @@ struct TrackingState{
CALF <: AbstractLoopFilter,
COLF <: AbstractLoopFilter,
CN <: AbstractCN0Estimator,
DS <: Union{DownconvertedSignalCPU, DownconvertedSignalGPU},
CAR <: Union{CarrierReplicaCPU, CarrierReplicaGPU},
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}},
COR <: Union{Vector{Int8}, Nothing}
}
prn::Int
Expand Down Expand Up @@ -233,10 +190,11 @@ function TrackingState(
else
code_phase = mod(code_phase, get_code_length(system))
end
downconverted_signal = DownconvertedSignalGPU(num_samples, num_ants)
carrier = CarrierReplicaGPU(num_samples) #nothing
downconverted_signal = nothing
carrier = gen_blank_carrier_gpu(system, num_samples)
code = nothing
TrackingState{S, C, CALF, COLF, CN, typeof(downconverted_signal), typeof(carrier), Nothing}(

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

0 comments on commit 2a24f7d

Please sign in to comment.