I profiled some code that I've been running quite a bit, and noticed that it was spending most of its time in IM line drawing routines, specifically GetPixelOpacity(). So, I finally took it upon myself to get the code running a bit faster. After two days of work, I have 30-40% speedup, which would have saved me a month of time on the cluster (and will save me a month soon). Patch:
http://pricepages.org/magick/opti_magick.diff

Speedup will be most pronounced when you are drawing long lines.

The slowest part of the code was fetching the bounds in the beginning of each loop in the if statements like "p->bounds.y1;". Prefetching the data didn't seem to work, so I ended up with one main loop which also computed the 'winding number', so it only needed to be fetched in one pass, instead of two.

The rest of the stuff that I did was basic, like computing invariants outside of the loop(s). Cast values only once. Avoid following pointers. Reorder instructions to take pipelining into account, etc.

I tried to keep things readable, and not lengthen code. I wasn't sure exactly _what_ was being computed, so I kept the logick of the code identical. The only place the output was altered didn't make sense, and I believe it's the optimizer doing funky things. While the output does change, I visually don't see a difference. I put a comment there, so you can see how it acts on your system.

Thoughts? Does it pass your test(s)?
~Seth

_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to