Let's face it.  CPU's just aren't getting any faster anymore.  CPU's have hit a ceiling in terms of processor speed, and that ceiling seems to be at about 3Ghz.  The new thing now is packaging multiple processors in a single CPU known as multi-core processors.  Now that the cheapest of PC's include dual core's applications, it's time for developers to do their part and develop applications that take advantage of these multiple cores.  Unlike increases in processor speed, applications don't benefit for free when introducting more cores.

Atalasoft is working hard on our next version of DotImage, and one of the new features is the ability to process images in multiple threads, taking advantage of multi-core processors.  We've added a new interface that enables any command to be processed in parallel.  We have run a number of benchmarks, and the results have been very promising with speed gains of up to 2.5 times that of processing a single thread.  Great!!

On my Pentium D desktop workstation, applying a fairly complicated image processing algorithm on a fairly large image gives me these results:

Single Thread: 1901ms
Multiple Threads: 909ms

That's a whopping 109% improvement with a command that's already heavily optimized.  How does this work?  Simple.  We break up processing the image in N sections.  For the purpose of explaining this, N will equal 4 which seems to be a really good number for dual core systems.  So we divide the image up into 4 sections as shown below.

Each section is then processed simultaniously in it's own thread.  When all threads are completed, the method returns with the newly processed image.  And in this case it's accomplished more than twice as fast, thanks to my dual core processor.

After testing a few systems at the office including a dual processor Xenon, and a handful of other makes and models, we were pretty satisfied with the results.  That is until I tested my 2Ghz Centrino Dual Core laptop.  To my dismay, the same image yielded these results:

Single Thread: 685ms
Multiple Threads: 831ms

This demonstrates that multiple threads are 18% slower on my dual core laptop.  Interesting.  I honetly have no idea why this happens.  It's also interesting that my 2Ghz laptop is quite a bit faster at processing than my 3Ghz desktop.  The single threaded laptop is faster than the multi-threaded desktop.  I honestly thought something was wrong with my CPU.  But I have tested it on 2 other laptops with Intel Core Duo's with similar results. 

Hats off to Intel for making a very fast processor, but PLEASE explain to me WHY is it slower when we optimize for dual core?  Comments are welcome, because I'm stumped.  Here are my results when running other CPU's under the same conditions with 2 different image processing commands.  The instances where the command is slower is with the Centrino Duo.  All other CPU's are considerably faster.

Adaptive Threshold Simple Threshold
Cores 1 Thread 4 Threads 1 Thread 4 Threads
Intel T2400 @ 1.83Ghz Centrino Duo 2 753 981 77% 395 332 119%
Intel T2400 @ 1.83Ghz Centrino Duo 2 778 840 93% 412 270 153%
Intel T7200 @ 2.00Ggz Centrino Duo 2 685 831 82% 279 284 98%
Intel Xenon 3Ghz (dual hyperthreaded CPU) 4 901 687 131% 301 220 137%
AMD Athlon 64 X2 Dual 4600+ x86 2 2284 1137 201% 756 512 148%
AMD Athlon 64 X2 Dual 4600+ x64 2 2248 931 241% 764 415 184%
AMD Turion 64 X2 Mobile TL-56 2 2732 1204 227% 1064 662 161%
Intel Pentium D 3Ghz 2 1901 909 209% 301 262 115%
Intel Pentium 4 2.5Ghz 1 3784 1586 239% 594 492 121%