Skip to content

Commit 20df36d

Browse files
tidy demo
1 parent 2670df0 commit 20df36d

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

demo.jl

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,16 @@ using ComputationalResources
55
FFTW.set_num_threads(parse(Int, ENV["FFTW_NUM_THREADS"]))
66
BLAS.set_num_threads(parse(Int, ENV["BLAS_NUM_THREADS"]))
77

8-
function do_work(mat)
9-
n_frames = size(mat, 3)
10-
frame_start = 1
11-
frame_dist = 0
12-
n_pairs = size(mat, 3)
13-
indices = Int.(round.((LinRange(frame_start, n_frames - frame_dist, n_pairs))))
14-
factored_kernel = ImageFiltering.factorkernel(Kernel.LoG(1))
15-
frame_filt = deepcopy(@view mat[:, :, frame_start])
16-
r = CPU1(ImageFiltering.planned_fft(frame_filt, factored_kernel))
17-
for i in indices
18-
frame = @view mat[:, :, i]
19-
imfilter!(r, frame_filt, frame, factored_kernel)
20-
end
21-
return
22-
end
23-
248
function benchmark(mats)
9+
kernel = ImageFiltering.factorkernel(Kernel.LoG(1))
2510
Threads.@threads for mat in mats
26-
do_work(mat)
11+
frame_filtered = similar(mat[:, :, 1])
12+
r = CPU1(ImageFiltering.planned_fft(frame_filtered, kernel))
13+
for i in axes(mat, 3)
14+
frame = @view mat[:, :, i]
15+
imfilter!(r, frame_filtered, frame, kernel)
16+
end
17+
return
2718
end
2819
end
2920

0 commit comments

Comments
 (0)