Skip to content

Commit

Permalink
tidy demo
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Jan 13, 2024
1 parent 2670df0 commit 20df36d
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions demo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,16 @@ using ComputationalResources
FFTW.set_num_threads(parse(Int, ENV["FFTW_NUM_THREADS"]))
BLAS.set_num_threads(parse(Int, ENV["BLAS_NUM_THREADS"]))

function do_work(mat)
n_frames = size(mat, 3)
frame_start = 1
frame_dist = 0
n_pairs = size(mat, 3)
indices = Int.(round.((LinRange(frame_start, n_frames - frame_dist, n_pairs))))
factored_kernel = ImageFiltering.factorkernel(Kernel.LoG(1))
frame_filt = deepcopy(@view mat[:, :, frame_start])
r = CPU1(ImageFiltering.planned_fft(frame_filt, factored_kernel))
for i in indices
frame = @view mat[:, :, i]
imfilter!(r, frame_filt, frame, factored_kernel)
end
return
end

function benchmark(mats)
kernel = ImageFiltering.factorkernel(Kernel.LoG(1))
Threads.@threads for mat in mats
do_work(mat)
frame_filtered = similar(mat[:, :, 1])
r = CPU1(ImageFiltering.planned_fft(frame_filtered, kernel))
for i in axes(mat, 3)
frame = @view mat[:, :, i]
imfilter!(r, frame_filtered, frame, kernel)
end
return
end
end

Expand Down

0 comments on commit 20df36d

Please sign in to comment.