Check out the new C++ AMP book by Kate Gregory and Ade Miller
The C++ AMP book by Kate Gregory and Ade Miller is available in print or online from your favorite retailer! What is in it for you? Among other things, you will discover how to:
- Gain greater code performance using graphics processing units (GPUs)
- Choose accelerators that enable you to write code for GPUs
- Apply thread tiles, tile barriers, and tile static memory
- Debug C++ AMP code with Microsoft Visual Studio®
- Use profiling tools to track the performance of your code
I was able to corner Ade Miller long enough to answer a few questions:
Q1: “C++ AMP” in 140 characters or less?
“A hardware agnostic data parallel programming model for C++.”
That’s pretty terse :). The C++ bit is important: C++ AMP is C++ not C.
Q2. How did you get interested in writing about C++ AMP?
I’ve had a longstanding interest in GPU programming. I got into it when I was writing a book about the C++ Parallel Patterns Library (PPL) that shipped with Visual Studio 2010. Like a lot of other people I was amazed by the potential for huge performance gains. At the time CUDA was the obvious choice for GPU programming so I wrote a fair bit of CUDA code. At the same time I was actually lobbying the PPL team and telling them they should go after GPUs too. I was really happy to see how C++ AMP was turning out and to get involved with the book.
Q3. What kind of research did you do for this book?
I’d been writing code for CUDA and Thrust so I was already pretty familiar with the data parallel model. I talked to the product team a lot. They were a fantastic resource and I’m really grateful to them for giving me the time. I wrote or rewrote a lot of code. I didn’t write all the book samples from scratch but I rewrote them to make sure that they not only used C++ AMP in the best possible way but also embraced the whole modern C++ style. I also ended up reading some really old papers from the 80s, stuff like “Data Parallel Algorithms” by Hollis & Steele. A few of the first big supercomputers, like the Connection Machine, were data parallel. Those guys did a lot of great thinking around how to program in a data parallel way. In that way GPUs are the old new thing.
Q4. What was the hardest part about writing C++ AMP?
I think it’s fair to say that was the work Kate and I did on performance (chapters 7-9). C++ AMP provides an abstraction over the GPU which is great for portability but occasionally it can lead to unexpected results that require more
thought to figure out. We were also working with pre-release bits. The product team were working hard to improve the performance so our numbers would change between drops and on different hardware. On the plus side I learnt a whole lot more about the inner workings of GPUs.
Q5. What are you working on now?
Some extra material for the book; some fun stuff and some stuff I think we would have put in if we had the time. It’ll start appearing in the next few weeks. You can find out about it on my blog. I’m going to be doing some more coding with C++ and C++ AMP and I have another book project in mind.
Q6. What advice would you give new C++ developers?
Don’t worry too much about some of the darker corners of the language. It’s really easy to get caught up in some of the more esoteric features of C++ like performance tweaks and template (meta-)programming. There’s good stuff there for sure, but you’d be better off getting really comfortable with the Standard Library and the new language features of C++11. If you write modern C++ using algorithms, iterators and containers and use the RAII pattern a lot of the things new C++ programmers struggle with pretty much disappear.
Q7. Do you have any favorite C++ favorite authors or books?
Hands down Scott Meyers. Right now I’m reading his “An Overview of the New C++ (C++11)”. It was reading his other books and listening to some of Herb Sutter’s talks that got me interested in C++ again after a long vacation in C#.
Q8. What question should I have asked?
What’s it like to be a famous author?
Q9. And the answer?
You’d have to ask J.K. Rowling! Although someone did recognize me on the subway in Montreal a while back, which was quite a surreal experience.
Visit the C++ AMP Book landing page for updates, retailers, and pointers to additional resources.
Should I have asked other questions? Let me know in the comments. Thanks!