# HG changeset patch # User Tuomo Valkonen # Date 1577475633 -7200 # Node ID 0b25d9ef7af91b719fef833ecbf7e5df15ce9591 # Parent 05b11c96ef4587c62b4528dbcd9bde6653c0fca6 Better @inbounds placements etc. diff -r 05b11c96ef45 -r 0b25d9ef7af9 src/ImFilter.jl --- 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 diff -r 05b11c96ef45 -r 0b25d9ef7af9 src/Translate.jl --- 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