Created
February 21, 2022 00:14
-
-
Save tk3369/07303d75abb59183095a9cab56735c27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BenchmarkTools | |
function apply_filter_jl(E, wx) | |
Xest = 0.0 + 0.0im | |
@inbounds for j = 1:size(E, 2) | |
for i = 1:size(E, 1) | |
Xest += E[i, j] * wx[i, j]' | |
end | |
end | |
return Xest | |
end | |
function cma_jl(E, wxy, mu, R, os) | |
L, pols = size(E) | |
ntaps = size(wxy, 1) | |
N = Int(floor((L / os / ntaps - 1) * ntaps)) | |
err = Matrix{ComplexF64}(undef, L, pols) | |
@inbounds @views for k = 1:pols | |
for i = 1:N | |
X = E[i*os-1:i*os+ntaps-2, :] | |
Xest = apply_filter_jl(X, wxy[:, :, k]) | |
err[i, k] = (R - abs2(Xest)) * Xest | |
wxy[:, :, k] .+= mu .* err[i, k]' .* X | |
end | |
end | |
return err, wxy | |
end | |
function perftest() | |
L = 10^5 # number of symbols | |
SNR = 10 | |
sig = 1 / sqrt(2) .* rand((1 + 1im, 1 - 1im, -1 - 1im, -1 + 1im), L, 2) | |
sigPower = sum(abs2, sig) / L | |
noisePower = sigPower / SNR | |
noise = sqrt(noisePower) .* randn(ComplexF64, L, 2) | |
s4 = sig .+ noise | |
wxy0 = zeros(ComplexF64, 21, 2, 2) | |
wxy0[22÷2, 1, 1] = 1 | |
wxy0[22÷2, 2, 2] = 1 | |
wxyin = copy(wxy0) | |
@benchmark cma_jl($s4, $wxyin, 1e-3, 1, 2) | |
end | |
#= | |
julia> perftest() | |
BenchmarkTools.Trial: 653 samples with 1 evaluation. | |
Range (min … max): 7.393 ms … 9.689 ms ┊ GC (min … max): 0.00% … 21.32% | |
Time (median): 7.588 ms ┊ GC (median): 0.00% | |
Time (mean ± σ): 7.665 ms ± 393.178 μs ┊ GC (mean ± σ): 1.26% ± 4.16% | |
▇▇▆▄██▆▅▂ | |
▆█████████▁█▇▅▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▅▅▄▅▆▄▁▆▄▅▅▄▄▄▁▅▄▅▇▅ █ | |
7.39 ms Histogram: log(frequency) by time 9.41 ms < | |
Memory estimate: 3.05 MiB, allocs estimate: 2. | |
julia> versioninfo() | |
Julia Version 1.8.0-DEV.1437 | |
Commit a0093d2ffb* (2022-02-01 00:11 UTC) | |
Platform Info: | |
OS: macOS (arm64-apple-darwin20.6.0) | |
CPU: Apple M1 | |
WORD_SIZE: 64 | |
LIBM: libopenlibm | |
LLVM: libLLVM-13.0.0 (ORCJIT, cyclone) | |
Environment: | |
JULIA_NUM_THREADS = 8 | |
JULIA_PKG_SERVER = | |
=# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment