Learn C++ AMP
So you are a newbie to C++ AMP – you know nothing and want to quickly get started, we have you covered – keep on reading!
Step 1 – Do this first!
While it is typical for many to learn a new technology by writing your own "Hello World", if you don’t want to wander off into the minefield of GPU programming on your own, please start with what we provide in terms of articles and videos.
There are two articles specifically aimed at newcomers:
When you are done with the articles, please invest 68 minutes to sit back and watch 4 screencast videos:
- C++ AMP core API introduction
- Tiling Introduction
- Matrix Multiplication walkthrough
- GPU Debugging in Visual Studio 2012
Step 2 – optional if you are already an expert in GPU computing
At this point you’ve spent 2 hours and you understand not only how to hit the ground running with your own algorithms, but also how C++ AMP is positioned. This is important so if you skipped step 1, please go back and complete it before even reading on!
Now, if you are further familiar with other approaches, you may want to optionally browse one of our three learning guides: C++ AMP for the OpenCL Programmer, C++ AMP for the CUDA Programmer, and C++ AMP for the HLSL/DirectCompute Programmer.
Step 3 – Dive into code
This is probably the step most of you wanted to start with, and I hope you resisted until now. Now that you have the necessary theoretical background, it is time to explore our many samples and also the code in the open source libraries.
Both of these will help you internalize patterns for bringing C++ AMP into your own code base, and some of it may also be code that you can actually use as-is in your code. Go ahead and write your own algorithms, or convert your existing CPU code to use C++ AMP. If you run into situations where you need help, ask questions in our MSDN forum – given that you consumed the resources above, rest assured you won’t be asking newbie questions ;-)
Step 4 – Become an expert
After step 1 and step 3 and cutting your own code, you may feel like you are ready to take it to the next level and that you want to consume more advanced resources – here are some pointers
- Read all the blog posts that are linked from C++ AMP in a nutshell.
- If you plan to use C++ AMP in conjunction with existing DirectX code, read the blog post introducing the graphics namespace and the other blog posts it points to. You will also want to explore the blog post on DirectX Interop, and perhaps the direct3d namespace.
- Read the blog posts that help you get the best performance out of your C++ AMP code.
- Browse the official C++ AMP MSDN documentation, knowing that if you find any discrepancies between it and our blog then it means that you should trust our blog and file a bug for the documentation writer.
- Read the C++ AMP open specification.
- Read the first C++ AMP book.
- Take the first C++ AMP training course.
- Hire, and rub shoulders with, consultants who are experts on C++ AMP.
Comments
Anonymous
September 19, 2012
Thank you for this useful post! The only thing that keeps me from trying c++ amp are cross plattfrom considerations and a real advantage in compression to opencl. Maybe someone could do a blogpost about what the benefits of using c++ amp instead of opencl, cuda etc would be in the future. Thanks again!Anonymous
September 20, 2012
Thanks, we're glad you found this useful. We'll consider your suggestion about showing the competitive advantages & disadvantages compared to other platforms. However, one thing to note right up front is that this is a fast-moving space, and the advantages & disadvantages of any given platform -- including C++ AMP -- are likely to change very quickly. Rest assured that we're committed to making sure that C++ AMP fulfills its ultimate goals of being portable, productive, and performant in the coming years.Anonymous
February 17, 2013
We have found your blogs and videos excellent for showing us how to leverage the AMP system. One problem we have encountered in introducing amp code into our projects is that many of our applications need to be compiled with the /Fcwchar_t- switch turned off. When we add amp.h to this code it ultimately generates a number of linker errors. Is there a workaround for this? I suspect that this is and will be a issue for many developers.Anonymous
February 18, 2013
@Bruce, bruce, as noted in response to your query in the forum, this is a known issue and we were wondering whether you can segregate the parts of the project that use AMP to compile differently. We are more interested in knowing about your scenario and please do contact me (bobyg AT Microsoft dot com) with your scenario details. thanksAnonymous
June 30, 2013
Hi Daniel, is AMP compatible with OpenMP? For example, can I put AMP code inside a OpenMP style for loop?Anonymous
June 30, 2013
Hi Daniel, followup to my previous question about the compatible between AMP and OpenMP. Actually I have tried to put AMP code, i.e. MatAdd.cpp (example given in the artivle "A Code-Based Introduction to C++ AMP") inside a OpenMP style for loop, which preformed no problem. I wonder whether it always performs OK?Anonymous
July 16, 2013
The comment has been removedAnonymous
February 03, 2014
The comment has been removedAnonymous
March 03, 2015
hello :) can anybody give me some examples(code based) of how to use a multi-gpu platform? I am trying to perform different types of operations (like matrix summation or matrix multiplication) on a multi gpu enviroment in order to see improvement from using more than one gpu. And it's giving me a hard time because the lack of examples, documentation in this particular area of how to use multiple gpus i would be very thankful if you can help me in this area. have a good day!