Kate Gregory's Blog
Thursday, 15 September 2011
Did you notice C++ AMP? You really need to
Word is starting to get out about C++ AMP, which appeared out of nowhere at a conference remarkably few Microsoft developers were paying attention to, because it was a hardware conference. There was information available in June, enough to get some of us excited:
on the VC++ team blog
from Herb Sutter
deep dive video
from Daniel Moth (it's hard to see the slides, so
I got into this right away and have been playing with code and doing a little writing. This is the kind of technology that changes things more than you might think. By leveraging the GPU, your code might run 10x faster, 50x faster, or even 100x faster. And for you to be able to do that from C++, using familiar C++ constructs, and a debugger and profiler in Visual Studio? That means everyone can do it.
Well, not quite everyone. You do have to learn how to parallelize your algorithms. The syntax of using the GPU (or some other heterogeneous computing resource) is not hard at all. The computer science of knowing your work is data parallel can be hard. But let me show you "not hard". Consider this code to add a pair of one-dimensional array:
void AddArrays(int n, int* pA, int* pB, int* pC)
for (int i=0; i<n; i++)
pC[i] = pA[i] + pB[i];
Compare that to this:
using namespace concurrency;
void AddArrays(int n, int * pA, int * pB, int * pC)
array_view<int,1> a(n, pA);
array_view<int,1> b(n, pB);
array_view<int,1> c(n, pC);
[=](index<1> idx) restrict(direct3d)
c[idx] = a[idx] + b[idx];
It's all C++ and it's all pretty readable. And this code runs on the GPU and can be WAY faster (and use less power, meaning your data centre is cheaper or your battery lasts longer) just like that.
has published ten blog posts drilling into some details. They will help if you've decided to start using AMP and want to know how. But before you do that, you might like to read a little background on why heterogeneous computing matters, what other options you might have for doing it, and why C++ AMP is what you want to use. I've done
a small whitepaper
on just that and would love you to read it and let me know what you think.
Seen and Recommended
Thursday, 15 September 2011 09:15:16 (Eastern Daylight Time, UTC-04:00)
Monday, 19 September 2011 18:23:50 (Eastern Daylight Time, UTC-04:00)
Excellent introduction to GPGPU for a newbie like me.
Just one comment - perhaps you should spell out that AMP stands for Accelerated Massive Parallelism when you start your AMP section.
Keep up the good work and look forward to reading more (or buying the book?)
Wednesday, 21 September 2011 00:52:41 (Eastern Daylight Time, UTC-04:00)
This is great stuff. Usually introductory chapters go on and on without actually saying anything substantive, but this text is different. Keep 'em coming!
Comments are closed.
© Copyright 2018 Kate Gregory
Theme design by
newtelligence dasBlog 2.3.9074.18820
| Page rendered at Thursday, 21 June 2018 19:54:52 (Eastern Daylight Time, UTC-04:00)
On this page....
Pluralsight Free Trial
Click Start a FREE 10-Day trial
Home - Gregory Consulting Limited
Visual C++ on MSDN
Office 12 and VSTO
Seen and Recommended
Visual Studio 11
Visual Studio 2008
Visual Studio 2010
Visual Studio 2013
Visual Studio 2015
Visual Studio 2017