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 improvement in channel processing #2

Merged
Merged
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
56 changes: 30 additions & 26 deletions src/Channel/getChannel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -312,16 +312,10 @@ function getChannel(nbSamples::Int,channelModel::ChannelModel,randSeed=-1)
freq = channelModel.samplingFreq;
# --- Ensuring additional delay for proper interpolation
delay = channelModel.delayProfile .+ fdGap;
cir = zeros(Complex{Float64}, nbSamples, delaySpread + sS);
for indexTime = 1 : 1: nbSamples
for k = 1 : 1 : delaySpread + sS
# --- Each index is superimposition of all timed compondent
for ∂ = 1 : 1 : nbTaps
# --- Shannon interpolation with sinc. on sincSupport
cir[indexTime,k] += powerLin[∂] * raylAmpl[indexTime,∂] * sinc.(pi*(k/freq - delay[∂]) * freq);
end
end
end
# --- Shannon interpolation with sinc. on sincSupport
shannonInterp = sinc.(pi.*(transpose(1:delaySpread+sS)./freq .- delay) .* freq);
# --- Each index is superimposition of all timed compondent
cir = transpose(powerLin) .* raylAmpl[1:nbSamples] * shannonInterp;
return ChannelImpl(1,cir,channelModel,powerLin,randSeed);
else
# ----------------------------------------------------
Expand Down Expand Up @@ -356,7 +350,9 @@ sigChan : applyChannel(sigId,channelImpl)
# ---
# v 1.0 - Robin Gerzaguet.
"""

function applyChannel(sigId,channelImpl)

if !Bool(channelImpl.timeVarying)
# --- Classic convolution
return sigChan = conv(sigId,channelImpl.cir);
Expand All @@ -370,26 +366,34 @@ function applyChannel(sigId,channelImpl)
nbTaps =size(channelImpl.cir,2);
nbOut =length(sigId)+nbTaps
sigChan = zeros(Complex{Float64},nbOut)
# n is time index of output, δ is lag index
for n = 1 : 1 : length(sigId)
# --- At beginning, not possible to have all index
nbMaxTap = min(n,nbTaps);
# --- Classic time domain convolution
for δ = 1 : 1 : nbMaxTap
sigChan[n] += channelImpl.cir[n,δ] * sigId[n-δ+1];
end
end
# At the end we have zero
timeVaryingConv!(sigChan, channelImpl.cir, sigId, nbTaps)

# At the end we have zero
buffEnd = zeros(Complex{Float64},nbTaps *2);
buffEnd[1:nbTaps] = sigChan[1:nbTaps];
for n = 1:nbTaps
# --- Classic time domain convolution
for δ = 1 : 1 : nbTaps
sigChan[length(sigId)+n] += channelImpl.cir[end,δ] * buffEnd[n+nbTaps-δ+1];
end
end
timeVaryingConvTail!(sigChan, channelImpl.cir, buffEnd, length(sigId), nbTaps)

return sigChan;
end
end

function timeVaryingConv!(sigChan, cir, sigId, nbTaps)
# n is time index of output, δ is lag index
for n = 1:length(sigId)
# --- At beginning, not possible to have all index
nbMaxTap = min(n,nbTaps);
# --- Classic time domain convolution
for δ = 1:nbMaxTap
@inbounds sigChan[n] += cir[n,δ] * sigId[n-δ+1];
end
end
end

function timeVaryingConvTail!(sigChan, cir, buffEnd, nbSigSamples, nbTaps)
for n = 1:nbTaps
# --- Classic time domain convolution
for δ = 1 : 1 : nbTaps
@inbounds sigChan[nbSigSamples+n] += cir[end,δ] * buffEnd[n+nbTaps-δ+1];
end
end
end