Microsoft juices C++ for massively parallel computing
Plug in the AMP
Fusion Summit Microsoft has announced a new technology designed to help C++ developers build massively parallel applications. Known as C++ Accelerated Massive Parallelism – or C++ AMP for short – the technology will be included in the next version of the company's Visual C++ compiler, and Microsoft plans to open up the specification for others to use.
Microsoft principal native-languages architect Herb Sutter unveiled the technology Wednesday morning at AMD's Fusion Developer Summit. Initially, C++ AMP will help devs take advantage of general purpose GPU computing (GPGPU), but in the future, Microsoft will extend the technology to multi-core architectures and beyond.
The goal of C++ AMP, Sutter said, is to take the ability to access the power of massively parallel computing out of the hands of the "priesthood" of expert programmers and bring it into the mainstream. Of course, C++ was never designed to be suited to the average guy on the street.
Taming the exotic
"Everything in the 'mainstream' starts out with the 'exotic'," read one slide from Sutter's presentation. The current exotic world is what Sutter calls "the jungle of heterogeneity." There are multiple types of processing cores roaming this jungle: complex out-of-order CPUs, simple in-order CPUs, various flavors of GPUs, and more-specialized cores. Each type of core excels at certain types of workloads.
The problem, Sutter explains, is that writing code in which one app can take advantage of each of these disparate units' strengths is exceptionally difficult, if not impossible, for mainstream programmers. "[But] as developers," he said, "it's no good if we can't write the code" for heterogeneous systems.
Enter C++ AMP.
"We think it's important for [massively parallel code] to be mainstream," he said, "so that you don't have to write 'Hello World' in a page and a half like you did with Windows 1.0, or like you do with parallel-processing 1.0 today."
Sutter noted that a lot of existing GPGPU methods use C, but Microsoft still went with C++. "We felt C++ was important – to use the strong typing [and] to use the strong, powerful abstractions while still being close to the metal," he said, also citing templates and exceptions as reasons the company chose C++.
The idea is to enhance the language without changing it too much. "We also think that it's important not to mess with a language more than you have to. And if you can do it without changing the language at all, so much the better."
According to Sutter's presentation and a demo by Daniel Moth – who also provides an introductory blog post – the jump to C++ AMP is minimal: a single language extension, in its first iteration.
"If you can use STL," Sutter said, "you can use C++ AMP, as well."
Portability is also key to C++ AMP's goals – mixing and matching hardware from any vendor, and writing just one executable that you can run on a wide range of hardware. And Microsoft is intent on "future-proofing" the technology. The first release will be GPU-centric, but Sutter said that in future releases, "[with] little or no code changes, we can spread it across multi-core and the cloud, as well."
For Sutter, the age of parallelism is here. "If you look at from, oh, about the last ice age until now," he said, "we've been making a single-threaded execution go faster and faster – until about 2005 when the free lunch was over, and we made this turn to more and more out-of-order CPUs."
Since 2005, things have changed further. Some vendors, he noted, are going to lots of in-order CPUs. Massively parallel GPUs have been "in the market for general-purpose computation for a couple of years," Sutter said. "We talking easily thousands of cores – and I could without lying make that number higher."
Then he uttered the inevitable C-word. "But cloud also matters," he said. "It's hard to get numbers on how big the largest cloud applications actually are, but it's fair to say that they at least approach 100,000 cores."
If those cloud apps run on what Sutter calls "cloud plus GPU", the number of cores addressable in such a massive heterogeneous system skyrockets – to roughly 100 million cores, according to Sutter. "You can write this code today," he said. "[But] it's not easy. It's not for the mainstream". C++ AMP aims to make it easier.
"And if you don't think that's game-changing," Sutter said, "how long is your password? And how long will it take 100 million GPU cores running at – what? – a million attempts per second to crack your password, just by brute force?
"We're almost at the point where a kid could write that. And that is just the tiniest example of how game-changing this is."
Playing long ball
Naturally, Microsoft has all this in mind. "Our eye on the longer ball," Sutter said. "We're doing this today because it adds great value just doing the GPU. But that's only one facet of the trend to heterogeneous parallel computing. It also includes multi-core and cloud, and compute devices at all scales."
Of course, Microsoft is not alone in its effort to provide programming support for massively parallel computing, heterogeneous computing, or whatever you may choose to call it.
Nvidia's CUDA, for example, is tuned to its own GPUs, and Sutter admitted in a post-keynote Q&A that "if you want to get the absolute best performance from one vendor's GPU, you will hardly be able to do better than that vendor's GPU stack". Then there's open-source OpenCL – hardly a vendor-specific approach to GPGPU computing.
Google's open source Go programming language comes at the distributed-computing challenge from another angle: It's built specifically for concurrency, providing a form of parallelism from the bottom up.
But C++ AMP has the advantage of being an outgrowth of a high-performing veteran. C++ may have its complexity issues, but it's widely used – and even Google admits that C++ is faster than the current iteration of Go.
But don't expect to dig deep into C++ AMP anytime soon. The non-heterogeneous C++0x – the first major upgrade to C++ since it was ISO-certified 13 years ago – was only recently finalized and is due to be published this summer.
Sutter told his keyote crowd that C++ AMP would be part of the next version of Visual Studio, but when The Reg asked him after his talk whether we'd all have to wait until then to bang away on it, he said that later this year the company will provide "bits" of it for developers to try out.
But when we pressed him whether he could make a projection as to when the next version of Visual Studio itself will appear, he demurred. "I can make a projection: sometime after today." ®
Sponsored: RAID: End of an era?