Microsoft brings GPU computing to C++ with C++ AMP

Look out, OpenCL. Microsoft has set its sights on the democratization of development for heterogeneous systems, and it's pulled out the big guns. At the AMD Fusion Developer Summit today, Microsoft's Herb Sutter announced an extension to the C++ language designed to let programmers tap into any DirectCompute-capable graphics hardware for general-purpose tasks. Microsoft calls the new extension C++ Accelerated Massive Parallelism, or C++ AMP for short, and it aims to make it an open spec that can be implemented on non-Microsoft platforms with non-Microsoft compilers.

Sutter presented C++ AMP as a way to cut through what he called the "jungle of heterogeneity." The PowerPoint slide below illustrates the full extent of that jungle as Sutter sees it, with processors in increasing order of specialization on the Y axis and memory systems in increasing order of non-uniformity and disjointedness mapped to the X axis. It's definitely not pretty:

C++ currently gives developers free reign in the bottom left corner of that jungle, Sutter said, but C++ AMP expands the roaming area dramatically. Not only that, but Microsoft hopes to support other specialized processors with future releases of C++ AMP, thus extending its domain over time.

So, what does C++ AMP entail? Sutter bills it as "minimal," and indeed, the list of additions is a short one:

The additions on which Sutter dwelt the most are array_view and restrict(). The former was described in the PowerPoint presentation as a "portable view that works like an N-dimensional 'iterator range'" and billed as a way to deal with memory that may not be uniform. The restrict() function was easier to grasp for a non-coder like me. If I understand correctly, it simply allows developers to create functions that execute on DirectCompute devices exclusively—all you have to do is toss "restrict(direct3d)" in there, like so:

(The code on the left is regular C++, while the code on the right is C++ AMP. That man in the bottom right corner is Microsoft's Daniel Moth, who got into the nitty-gritty details of C++ AMP during a technical session after Sutter's keynote.)

Now, there will be restrictions on what can go inside, er, restrict()-ed functions, since DirectCompute-capable GPUs can only support a subset of the C++ language. Nevertheless, programs written with C++ AMP will be compiled as single executables capable of making use of DirectCompute-capable hardware if it's there. (I'm guessing developers will be able to include fallback code paths so systems without DirectCompute GPUs can just use the CPU to do the work.)

Microsoft said it will include C++ AMP support in the next version of Visual Studio. Of course, since C++ AMP is an open spec, Visual Studio won't be the only way to write C++ AMP code and compile it. In fact, Sutter said Microsoft and AMD are already working together on non-Windows compilers. (Lest you think Nvidia is being left out, a post on Nvidia's blog says the firm "continues to work closely with Microsoft to help make C++ AMP a success.")

Tip: You can use the A/Z keys to walk threads.
View options

This discussion is now closed.