Bug 413972 - align_image_stack and enfuse use only 1 CPU core if called by digiKam plugin, 4 CPU core on command line
Summary: align_image_stack and enfuse use only 1 CPU core if called by digiKam plugin,...
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-Generic-ExpoBlending (show other bugs)
Version: 6.3.0
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-09 12:52 UTC by Frerk Meyer
Modified: 2019-11-10 14:51 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 7.0.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frerk Meyer 2019-11-09 12:52:05 UTC
SUMMARY
align_image_stack and enfuse command line tools take to long because they only use 1 core if called from the Plugin-Generic-Expoblending. If OMP_NUM_THREADS=4 is set, they are using 4 cores if called from the command line.

STEPS TO REPRODUCE
1. export OMP_NUM_THREADS=4 (number of core your CPU has)
2. start digiKam from the same command line
3. use ksysguard to monitor how many cpu cores are used
4. align and enfuse 2 or more pictures with Expoblending Plugin

OBSERVED RESULT
5. only the first CPU core is used 100%, the others are idle (<5%)

EXPECTED RESULT
6. all cores are up to 100% usage most of the time like when called without digiKam.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: openLEAP 15.1
(available in About System)
KDE Plasma Version: 5.12.8
KDE Frameworks Version: 5.55.0
Qt Version: 5.9.7

ADDITIONAL INFORMATION

Called from the digiKam Exposure Blending Plugin this always takes the time of a 1 Core System, even when I have a 4 core Intel i7. This is my benchmark with calls from the command line and different OMP_NUM_THREADS setting.
Both tools are linked with the openMP library libgomp.so.1.
I had to install enfuse-enblend from the KDE:graphics Repo because the one that is default in openLEAP 15.1 is to old and not linked to openMP.
Problem could be upstream. I would like to know if this is a problem on other Linux distributions or SUSE Versions as well.

time align_image_stack -v -c 16 -a aligned IMGP1842.JPG IMGP1843.JPG IMGP1844.JPG

OMP_NUM_THREADS=4
real    0m17,917s
user    0m56,392s
sys     0m0,208s

OMP_NUM_THREADS=1
real    0m35,746s
user    0m35,521s
sys     0m0,172s

enfuse -c --exposure-weight=1 --saturation-weight=0.2 --contrast-weight=0.2 -v -o hdr.jpg aligned0000.tif aligned0001.tif aligned0002.tif

OMP_NUM_THREADS=4
real    1m52,775s
user    6m18,861s
sys     0m0,172s

OMP_NUM_THREADS=1
real    3m54,044s
user    3m53,403s
sys     0m0,120s

Thanks in advance,

Frerk
Comment 1 Maik Qualmann 2019-11-09 14:06:48 UTC
from the Enfuse Help:
----
The OMP_NUM_THREADS environment variable sets the number of threads to use in OpenMP parallel regions. If unset Enfuse uses as many threads as there are CPUs.
----

If the variable is not set, all available CPU cores will be used. I can confirm that here on openSUSE Tumbleweed, with me all CPU cores are used. Gilles, can you do a test under Mageia?

Maik
Comment 2 Frerk Meyer 2019-11-09 14:45:31 UTC
I only introduced the environment variable OMP_NUM_THREADS after I noticed that only 1 core was used without. It was my try to remedy the situation.

So the bug was there on my machine without any environment variables with 'OMP' set.

It may be specific to LEAP 15.1 or to my machine.

But OMP_NUM_THREADS influences both, align_image_stack and enfuse if called from the command line as expected.
Comment 3 caulier.gilles 2019-11-09 16:18:45 UTC
Maik, yes i confirm, same behavior under Mageia...

Gilles
Comment 4 Maik Qualmann 2019-11-09 17:40:49 UTC
Git commit bdada4d927635f4aa5ee9579a2964a00382eb87c by Maik Qualmann.
Committed on 09/11/2019 at 17:39.
Pushed by mqualmann into branch 'master'.

set OMP_NUM_THREADS environment variable
FIXED-IN: 7.0.0

M  +2    -1    NEWS
M  +10   -2    core/dplugins/generic/tools/expoblending/manager/expoblendingthread.cpp
M  +10   -1    core/dplugins/generic/tools/panorama/tasks/commandtask.cpp

https://invent.kde.org/kde/digikam/commit/bdada4d927635f4aa5ee9579a2964a00382eb87c
Comment 5 Frerk Meyer 2019-11-10 14:51:14 UTC
(In reply to Maik Qualmann from comment #4)
Hello Maik Qualmann,

Many thanks for this blazing fast response.
I hope this will solve it, cant wait to try 7.0.0 then.

Frerk