Random inspiration from Accelerated Massive Parallelism

For some reason I've started looking at the sample code for Microsoft's C++ AMP: Accelerated Massive Parallelism. The temptation to offload work onto the GPU has finally proved too much. Actually, I've looked at various ways to do that in the past, but then slowly walked away...

This time I got as far as calculating the Mandelbrot set by means of C++ AMP, but I won't bore you with that, and besides, Microsoft have provided their own sample code and it's probably better than my version. But when I looked that their code for calling C++ AMP from C# code I was reminded how simple it is to call C++ code from .Net, and I started to wonder why I don't do this more often - even without any Accelerated Massive Parallelism trickery. For example, say you're doing some repetitive calculations, why not do the maths in a small bit of C++ code and get a huge speed improvement? It's not that difficult to do a simple calculation in C++ and you don't need lots more code.

So I spent a lunchbreak writing a sample project to calculate the biggest distance found between an array of points (x,y coordinates). I implemented the same calculation in both C# and C++ and then ran it on an array of 10,000 random points. Using the C++ code, without any help from AMP, it was about ten times faster - even thought I was calling it from within my C# console app:

Wow. That's quite a big difference. Note: I'm computing the distance between every combination of two points in the array and returning the biggest distance found.

Now ... I may not be able to do this type of stuff during my day job, where everything needs to be done in C# only, but I think that I may be tempted to do this type of stuff in my own time when I'm just messing around.