-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
167611b
commit faa2fb6
Showing
7 changed files
with
155 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ author = ["Tim Holy <[email protected]>", "Jan Weidner <[email protected]>"] | |
version = "0.7.8" | ||
|
||
[deps] | ||
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c" | ||
CatIndices = "aafaddc9-749c-510e-ac4f-586e18779b91" | ||
ComputationalResources = "ed09eef8-17a6-5b46-8889-db040fac31e3" | ||
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" | ||
|
@@ -13,8 +14,9 @@ ImageBase = "c817782e-172a-44cc-b673-b171935fbb9e" | |
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534" | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" | ||
Reexport = "189a3867-3050-52da-a836-e630ba90ab69" | ||
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" | ||
Reexport = "189a3867-3050-52da-a836-e630ba90ab69" | ||
RFFT = "3bd9afcd-55df-531a-9b34-dc642dce7b95" | ||
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" | ||
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" | ||
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" | ||
|
@@ -29,8 +31,9 @@ FFTW = "0.3, 1" | |
ImageBase = "0.1.5" | ||
ImageCore = "0.10" | ||
OffsetArrays = "1.9" | ||
Reexport = "1.1" | ||
PrecompileTools = "1" | ||
Reexport = "1.1" | ||
RFFT = "0.1.1" | ||
StaticArrays = "0.10, 0.11, 0.12, 1.0" | ||
TiledIteration = "0.2, 0.3, 0.4, 0.5" | ||
julia = "1.6" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using ImageFiltering, FFTW, LinearAlgebra, Profile, Random | ||
# using ProfileView | ||
using ComputationalResources | ||
|
||
FFTW.set_num_threads(parse(Int, get(ENV, "FFTW_NUM_THREADS", "1"))) | ||
BLAS.set_num_threads(parse(Int, get(ENV, "BLAS_NUM_THREADS", string(Threads.nthreads() ÷ 2)))) | ||
|
||
function benchmark(mats) | ||
kernel = ImageFiltering.factorkernel(Kernel.LoG(1)) | ||
Threads.@threads for mat in mats | ||
frame_filtered = deepcopy(mat[:, :, 1]) | ||
r_cached = CPU1(ImageFiltering.planned_fft(frame_filtered, kernel)) | ||
for i in axes(mat, 3) | ||
frame = @view mat[:, :, i] | ||
imfilter!(r_cached, frame_filtered, frame, kernel) | ||
end | ||
return | ||
end | ||
end | ||
|
||
function test(mats) | ||
kernel = ImageFiltering.factorkernel(Kernel.LoG(1)) | ||
for mat in mats | ||
f1 = deepcopy(mat[:, :, 1]) | ||
r_cached = CPU1(ImageFiltering.planned_fft(f1, kernel)) | ||
f2 = deepcopy(mat[:, :, 1]) | ||
r_noncached = CPU1(Algorithm.FFT()) | ||
for i in axes(mat, 3) | ||
frame = @view mat[:, :, i] | ||
@info "imfilter! noncached" | ||
imfilter!(r_noncached, f2, frame, kernel) | ||
@info "imfilter! cached" | ||
imfilter!(r_cached, f1, frame, kernel) | ||
@show f1[1:4] f2[1:4] | ||
f1 ≈ f2 || error("f1 !≈ f2") | ||
end | ||
return | ||
end | ||
end | ||
|
||
function profile() | ||
Random.seed!(1) | ||
nmats = 10 | ||
mats = [rand(Float32, rand(80:100), rand(80:100), rand(2000:3000)) for _ in 1:nmats] | ||
GC.gc(true) | ||
|
||
# benchmark(mats) | ||
|
||
# for _ in 1:3 | ||
# @time "warm run of benchmark(mats)" benchmark(mats) | ||
# end | ||
|
||
test(mats) | ||
|
||
# Profile.clear() | ||
# @profile benchmark(mats) | ||
|
||
# Profile.print(IOContext(stdout, :displaysize => (24, 200)); C=true, combine=true, mincount=100) | ||
# # ProfileView.view() | ||
# GC.gc(true) | ||
end | ||
|
||
profile() | ||
|
||
using ImageFiltering | ||
using ImageFiltering.RFFT | ||
|
||
function mwe() | ||
a = rand(Float64, 10, 10) | ||
out1 = rfft(a) | ||
|
||
buf = RFFT.RCpair{Float64}(undef, size(a)) | ||
rfft_plan = RFFT.plan_rfft!(buf) | ||
copy!(buf, a) | ||
out2 = complex(rfft_plan(buf)) | ||
|
||
return out1 ≈ out2 | ||
end | ||
mwe() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters