C++AMP: Accelerated Massive Parallelism
drdobbs.com
drdobbs.com
=== Code example ===
Original, CPU-only code:
void AddArrays(int n, int * pA, int * pB, int * pC)
{
for (int i=0; i<n; i++)
{
pC[i] = pA[i] + pB[i];
}
}
GPU optimized code: #include <amp.h>
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> sum(n, pC);
parallel_for_each(
sum.grid,
[=](index<1> idx) restrict(direct3d)
{
sum[idx] = a[idx] + b[idx];
}
);
}
First impressions: I like it.Why Microsoft can't reuse OpeNCL?
Have you ever seen an OpenCL Hello World program [1]? It's miserable.
[1] http://developer.apple.com/library/mac/#documentation/Perfor...
Btw, introducing C++ introduces problems too: RTTI, exceptions, and the fact that templates are to be used (would tend to create bigger code).
Folks who want to program GPUs productively use Thrust [1].