-
Notifications
You must be signed in to change notification settings - Fork 78
Closed
Description
This may be the same issue as #325, but observed on Linux with threads. I should say I'm running this on a 6-physical-core machine (12 if you include hyperthreads). Copied from JuliaImages/ImageFiltering.jl#161 and specifically the test in timholy/ComputationalResources.jl#18:
$ JULIA_NUM_THREADS=4 julia
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.4.2-pre.0 (2020-04-15)
_/ |\__'_|_|_|\__'_| | release-1.4/ef4fe83698* (fork: 122 commits, 113 days)
|__/ |
julia> using ImageFiltering, BenchmarkTools, ComputationalResources
julia> function test_imfilter(; opt=1)
gk = Kernel.gaussian(2.0f0)
I = rand(Float32,1000 ,1000)
println("julia_num_threads=$(Threads.nthreads())")
for i = 1:9
start = time()
if opt == 1
J = imfilter(CPU1(Algorithm.FIR()), I, gk)
elseif opt == 2
J = imfilter(I, gk)
else
error("Wrong opt value $opt, either 1 (for CPU1), 2 CPUThreads")
end
t = round(time() - start, digits=6)
println("$i imfilter $t sec")
end
end
test_imfilter (generic function with 1 method)
julia> test_imfilter(opt=1)
julia_num_threads=4
1 imfilter 0.020989 sec
2 imfilter 0.022114 sec
3 imfilter 0.035968 sec
4 imfilter 0.020871 sec
5 imfilter 0.020997 sec
6 imfilter 0.021044 sec
7 imfilter 0.024659 sec
8 imfilter 0.018204 sec
9 imfilter 0.018081 sec
julia> test_imfilter(opt=2)
julia_num_threads=4
1 imfilter 0.320837 sec
2 imfilter 0.015825 sec
3 imfilter 0.018062 sec
4 imfilter 0.008963 sec
5 imfilter 0.009365 sec
6 imfilter 0.010428 sec
7 imfilter 0.009566 sec
8 imfilter 0.010779 sec
9 imfilter 0.013365 secAll seems well. Now load Gtk and do it again:
julia> using Gtk
Gtk-Message: 09:16:09.296: Failed to load module "canberra-gtk-module"
Gtk-Message: 09:16:09.296: Failed to load module "canberra-gtk-module"
julia> test_imfilter(opt=1)
julia_num_threads=4
1 imfilter 0.020802 sec
2 imfilter 0.019717 sec
3 imfilter 0.021034 sec
4 imfilter 0.02322 sec
5 imfilter 0.017263 sec
6 imfilter 0.020025 sec
7 imfilter 0.018188 sec
8 imfilter 0.021637 sec
9 imfilter 0.017454 sec
julia> test_imfilter(opt=2)
julia_num_threads=4
1 imfilter 5.036473 sec
2 imfilter 5.020005 sec
3 imfilter 5.04309 sec
4 imfilter 0.013518 sec
5 imfilter 5.01333 sec
6 imfilter 0.032066 sec
7 imfilter 5.016917 sec
8 imfilter 5.035067 sec
9 imfilter 5.024456 secYou can see that the multithreaded case specifically gets massively slowed down. Here are some key details:
julia> versioninfo()
Julia Version 1.4.2-pre.0
Commit ef4fe83698* (2020-04-15 16:24 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
Environment:
JULIA_NUM_THREADS = 4
JULIA_CPU_THREADS = 4
(@v1.4) pkg> st Gtk
Status `~/.julia/environments/v1.4/Project.toml`
[4c0ca9eb] Gtk v1.1.3Metadata
Metadata
Assignees
Labels
No labels