Parallel resampling columnwise

FWIW, after setting in VS Code the Julia Num Threads variable (= 14 for my Windows laptop), the following code using Threads.@threads seems to run 5x faster than the pmap version:

function test2(signal::Matrix{Float32}, rate::Real)
    rows, cols = size(signal)
    new_rows = Int(floor(rows * rate))
    result = Matrix{Float32}(undef, new_rows - 1, cols)
    Threads.@threads for i in axes(signal,2)
        @views @inbounds result[:, i] = resample(signal[:,i], rate, dims=1)
    end
    return result
end
1 Like