setting the number of IM threads on a task by task basis
Posted: 2012-03-11T20:53:42-07:00
Suppose that one has determined that, on one's machine, a certain convert task runs faster with OpenMP off, but that another convert task runs faster with, say, four threads.
How can one fix things so that both tasks run fast?
One way would be to have two differently compiled versions of ImageMagick floating around, using one for each task.
Now, what if three different key tasks have different ideal number of threads?
Dead simple solution
Assuming ImageMagick was compiled with OpenMP support, run the first task prefixing with the environment variable determining the number of threads set so that only 1 is usedand do the same with the other task, setting it's number of threads to a different value
Of course, if you have not taken the time to figure out the ideal number of threads for a task, or you are happy with the default, just leave the prefix out.
How can one fix things so that both tasks run fast?
One way would be to have two differently compiled versions of ImageMagick floating around, using one for each task.
Now, what if three different key tasks have different ideal number of threads?
Dead simple solution
Assuming ImageMagick was compiled with OpenMP support, run the first task prefixing with the environment variable determining the number of threads set so that only 1 is used
Code: Select all
MAGICK_THREAD_LIMIT=1 convert small.png -resize 40x40^ -gravity center -extent 40x40 -quality 75 -sample 2x2 smallthumb.jpg
Code: Select all
MAGICK_THREAD_LIMIT=4 convert big.png -resize 40x40^ -gravity center -extent 40x40 -quality 75 -sample 2x2 bigthumb.jpg