From b1a11ef54ce2305e9de050a5d31bf15e427f3806 Mon Sep 17 00:00:00 2001 From: zymon Date: Sat, 30 Nov 2024 23:46:55 +0100 Subject: [PATCH] Friends with LoopVectorization once again --- Project.toml | 3 ++- src/ISM.jl | 10 +++++----- src/RoomAcoustics.jl | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Project.toml b/Project.toml index c1eb5d3..afa5d0a 100644 --- a/Project.toml +++ b/Project.toml @@ -6,12 +6,13 @@ version = "0.3.1" [deps] DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -SLEEFPirates = "476501e8-09a2-5ece-8869-fb82de89a1fa" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [compat] DSP = "0.7" +LoopVectorization = "0.12.171" StaticArrays = "1" julia = "1.6" diff --git a/src/ISM.jl b/src/ISM.jl index 04b4c41..6e46b1e 100644 --- a/src/ISM.jl +++ b/src/ISM.jl @@ -80,7 +80,7 @@ function image_source_generator( if config.isd > 0.0 && o > 0 # generate random displacement for the image source - isp .+= randn(config.lrng) * config.isd + isp = isp .+ randn(config.lrng) .* config.isd end # Distance between receiver and image source @@ -124,12 +124,12 @@ function insert_impuse!(h, A, τ, impulse_width, fs, Δt, twid, ω, N) i_e = min(floor(Int, (τ + a) * fs) + 1, N) # end # Insert yet another impulse into transfer function - for i ∈ i_s:i_e + @turbo for i ∈ i_s:i_e t = (i - 1) * Δt - τ # time signature - w = fma(cos_fast(ω*t), 0.5, 0.5) # Hann window + w = 0.5 * (1.0 + cos(ω*t)) # Hann window x = twid * t - sinc = ifelse(iszero(x), 1.0, sin_fast(x)/x) - @inbounds h[i] += w * A * sinc + sinc = ifelse(iszero(x), 1.0, sin(x)/x) + h[i] += w * A * sinc end end diff --git a/src/RoomAcoustics.jl b/src/RoomAcoustics.jl index f37abfe..260e195 100644 --- a/src/RoomAcoustics.jl +++ b/src/RoomAcoustics.jl @@ -6,7 +6,7 @@ using Statistics using Random using Random: GLOBAL_RNG -using SLEEFPirates: cos_fast, sin_fast +using LoopVectorization using DSP: conv include("TxRxModels.jl")