Page 1 of 1

Multi core system much slower than single core

Posted: 2013-01-08T05:12:41-07:00
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.

Re: Multi core system much slower than single core

Posted: 2013-01-08T05:30:19-07:00
by magick
Set this environment variable, how is performance now?
  • export OMP_NUM_THREADS=1

Re: Multi core system much slower than single core

Posted: 2013-01-08T05:53:25-07:00
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.

Re: Multi core system much slower than single core

Posted: 2013-01-08T06:33:00-07:00
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.