Multi core system much slower than single core

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
robert
Posts: 2
Joined: 2013-01-08T03:55:02-07:00
Authentication code: 6789

Multi core system much slower than single core

Post by robert »

Hello,
A few years ago I made a trend graph program using ImageMagic++ under linux. For years I used this program on a redhat 7.2 multi core system. Now I am upgrading to a newer OS: RHEL 6.3. I can compile the trend graph program and it still works the same as on the old system but I have a performance problem: when I use more than 1 cpu in the system and run de program twice at the same time the performance is 100 times as slow as on the old system……
I compile the program with the follwing command:
c++ -o grafiek grafiek.cpp `Magick++-config --cxxflags --cppflags --ldflags --libs`

--> When I run the program just once it is ok:
time ./grafiek TEMP1.PV.txt
filenaam input file: TEMP1.PV.txt
Standaard paramameters
aantal meetpunten: 1440 / aantal punten tonen : -1
Datum is: 2013-01-06
MIN_MINCALC_MAX_MAXCALC_PUNT_TOT_GEM 16.4633 16.4633 17.8624 17.8624 1440 24553.9 17.0513
max x-as: 800 max y-as: 600
gereserveerd voor x/y as: 30 / 40
Font: FLAR821L.TTF size: 11 / lengte as dot: 6 / aantal pixels per x coordinaat: 0.527778 / plaats yas tekst: 123
filenaam output jpg: TEMP1.PV.txt.jpg

real 0m0.147s
user 0m0.253s
sys 0m0.012s

--> When I run it twice at the same time:
time ./grafiek TEMP1.PV.txt& time ./grafiek TEMP2.PV.txt
[1] 8696
filenaam input file: TEMP1.PV.txt
filenaam input file: TEMP2.PV.txt
Standaard paramameters
Standaard paramameters
aantal meetpunten: 1440 / aantal punten tonen : -1
Datum is: 2013-01-06
aantal meetpunten: 1440 / aantal punten tonen : -1
Datum is: 2013-01-06
MIN_MINCALC_MAX_MAXCALC_PUNT_TOT_GEM 16.0638 16.0638 17.7779 17.7779 1440 24201.8 16.8068
max x-as: 800 max y-as: 600
gereserveerd voor x/y as: 30 / 40
MIN_MINCALC_MAX_MAXCALC_PUNT_TOT_GEM 16.4633 16.4633 17.8624 17.8624 1440 24553.9 17.0513
max x-as: 800 max y-as: 600
gereserveerd voor x/y as: 30 / 40
Font: FLAR821L.TTF size: 11 / lengte as dot: 6 / aantal pixels per x coordinaat: 0.527778 / plaats yas tekst: 123
Font: FLAR821L.TTF size: 11 / lengte as dot: 6 / aantal pixels per x coordinaat: 0.527778 / plaats yas tekst: 123
filenaam output jpg: TEMP2.PV.txt.jpg
filenaam output jpg: TEMP1.PV.txt.jpg

real 0m18.944s
user 0m18.878s
sys 0m0.005s
[1]+ Done time ./grafiek TEMP1.PV.txt

real 0m18.977s
user 0m37.809s
sys 0m0.014s

If I run the command twice on the old system it is fast and when I only put 1 cpu in the system it also is very vast. I like to use a multi core system because there also run a lot of other processes.
Doe anybody know how to tackle this problem? Use other compile options?
Regards,
Robert.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Multi core system much slower than single core

Post by magick »

Set this environment variable, how is performance now?
  • export OMP_NUM_THREADS=1
robert
Posts: 2
Joined: 2013-01-08T03:55:02-07:00
Authentication code: 6789

Re: Multi core system much slower than single core

Post by robert »

Great!
$export OMP_NUM_THREADS=1
$time ./grafiek TEMP1.PV.txt& time ./grafiek TEMP2.PV.txt
[1] 13534
filenaam input file: TEMP1.PV.txt
filenaam input file: TEMP2.PV.txt
Standaard paramameters
Standaard paramameters
aantal meetpunten: 1440 / aantal punten tonen : -1
Datum is: 2013-01-06
aantal meetpunten: 1440 / aantal punten tonen : -1
Datum is: 2013-01-06
MIN_MINCALC_MAX_MAXCALC_PUNT_TOT_GEM 16.0638 16.0638 17.7779 17.7779 1440 24201.8 16.8068
max x-as: 800 max y-as: 600
gereserveerd voor x/y as: 30 / 40
MIN_MINCALC_MAX_MAXCALC_PUNT_TOT_GEM 16.4633 16.4633 17.8624 17.8624 1440 24553.9 17.0513
max x-as: 800 max y-as: 600
gereserveerd voor x/y as: 30 / 40
Font: FLAR821L.TTF size: 11 / lengte as dot: 6 / aantal pixels per x coordinaat: 0.527778 / plaats yas tekst: 123
Font: FLAR821L.TTF size: 11 / lengte as dot: 6 / aantal pixels per x coordinaat: 0.527778 / plaats yas tekst: 123
filenaam output jpg: TEMP2.PV.txt.jpg
filenaam output jpg: TEMP1.PV.txt.jpg

real 0m0.152s
user 0m0.138s
sys 0m0.013s
[1]+ Done time ./grafiek TEMP1.PV.txt

real 0m0.158s
user 0m0.284s
sys 0m0.024s

Thanks for your help!
Can you tell me why the performance is so poor without this option?
Regards,
Robert.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Multi core system much slower than single core

Post by magick »

It appears to be a problem in certain release of libgomp, particularly on some virtual systems. In general, threading support in ImageMagick boosts performance significantly. See Threading Performance, near the bottom of this section @ http://www.imagemagick.org/script/archi ... hp#threads.

You can avoid the environment variable by setting the thread policy in policy.xml. That will ensure all ImageMagick command lines only run on one core.
Post Reply