Fri, 27 Dec 2019 21:40:33 +0200
Better @inbounds placements etc.
src/ImFilter.jl | file | annotate | diff | comparison | revisions | |
src/Translate.jl | file | annotate | diff | comparison | revisions |
--- a/src/ImFilter.jl Fri Dec 27 20:59:44 2019 +0200 +++ b/src/ImFilter.jl Fri Dec 27 21:40:33 2019 +0200 @@ -39,16 +39,16 @@ res = similar(b) Threads.@threads for i=1:n - for j=1:m + @inbounds for j=1:m tmp = 0.0 it₁ = inside(i, a₁, b₁, 1, n) it₂ = inside(j, a₂, b₂, 1, m) - @inbounds for p=it₁ + for p=it₁ @simd for q=it₂ tmp += kp[p-o₁, q-o₂]*b[i+p,j+q] end end - @inbounds res[i, j] = tmp + res[i, j] = tmp end end
--- a/src/Translate.jl Fri Dec 27 20:59:44 2019 +0200 +++ b/src/Translate.jl Fri Dec 27 21:40:33 2019 +0200 @@ -99,8 +99,8 @@ function translate_image!(x, z, u::DisplacementFull) @assert(size(u, 1)==2 && size(x)==size(u)[2:end] && size(x)==size(z)) - @inbounds Threads.@threads for i=1:size(x, 1) - @simd for j=1:size(x, 2) + Threads.@threads for i=1:size(x, 1) + @inbounds for j=1:size(x, 2) pt = (i - u[1, i, j], j - u[2, i, j]) x[i, j] = interpolate2d_quadrants(z, pt) end @@ -110,10 +110,10 @@ function translate_image!(x, z, u::DisplacementConstant) @assert(size(u)==(2,) && size(x)==size(z)) - a, b = u[1], u[2] + @inbounds a, b = u[1], u[2] - @inbounds Threads.@threads for i=1:size(x, 1) - @simd for j=1:size(x, 2) + Threads.@threads for i=1:size(x, 1) + @inbounds for j=1:size(x, 2) x[i, j] = interpolate2d_quadrants(z, (i - a, j - b)) end end @@ -140,11 +140,13 @@ @inbounds begin b[1:px-1, :] .= 0 b[qx+1:bx, :] .= 0 + end - Threads.@threads for i=px:qx + Threads.@threads for i=px:qx + @inbounds begin b[i, 1:py-1] .= 0 b[i, qy+1:by] .= 0 - @simd for j=py:qy + for j=py:qy b[i, j] = interpolate2d_quadrants(im, (i+vxʹ, j+vyʹ)) end end