4 ms·
C++AMP: Accelerated Massive Parallelism
- malkia 15y agoIf it something like OpenMP (meta language on top of general purpose one) then I can see it, but if it's something that forces one to write always AMP code in the same language, then it would get messy very fast. I much preffer #pragma opm parallel for, rather than parallel_for<> and some syntax that would try to get into the original language. Why Microsoft can't reuse OpeNCL?
- sc68cal 15y agoThe same reason they introduced DirectX to compete with OpenGL. Lock-in.
- chaffy 15y agoMaybe, but to be fair, that's only part of it. OpenCL is C99-based, and MS wants a C++ solution. OpenCL introduces more problems than it solves, primarily because the standards body mandated C99 and a low-level, driver-style interface. Have you ever seen an OpenCL Hello World program [1]? It's miserable. [1] http://developer.apple.com/library/mac/#documentation/Performance/Conceptual/OpenCL_MacProgGuide/Example:Hello,World/Example:Hello,World.html http://developer.apple.com/library/mac/#documentation/Perfor...
- malkia 15y agoCan you show us a DirectCompute one? Btw, introducing C++ introduces problems too: RTTI, exceptions, and the fact that templates are to be used (would tend to create bigger code).
- chaffy 15y agoDirectCompute suffers much of the same problems as OpenCL. Folks who want to program GPUs productively use Thrust [1]. [1] http://code.google.com/p/thrust/ http://code.google.com/p/thrust/
- palish 15y agoSlides: http://ecn.channel9.msdn.com/content/DanielMoth_CppAMP_Intro.pdf http://ecn.channel9.msdn.com/content/DanielMoth_CppAMP_Intro... === 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.
- deleted 15y ago[deleted]
- DocSavage 15y agoSeems like it's more focused on multidimensional data compared to Thrust (http://code.google.com/p/thrust/ http://code.google.com/p/thrust/), a C++/STL-like language also for GPU computing. == Compare to Thrust below == #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <thrust/generate.h> #include <thrust/sort.h> #include <thrust/copy.h> #include <cstdlib> int main(void) { // generate 32M random numbers on the host thrust::host_vector<int> h_vec(32 << 20); thrust::generate(h_vec.begin(), h_vec.end(), rand); // transfer data to the device thrust::device_vector<int> d_vec = h_vec; // sort data on the device (846M keys per second on GeForce GTX 480) thrust::sort(d_vec.begin(), d_vec.end()); // transfer data back to host thrust::copy(d_vec.begin(), d_vec.end(), h_vec.begin()); return 0; }
- wlievens 15y agoWith some decent DFA you can automate this stuff.
- deleted 15y ago[deleted]
- deleted 15y ago[deleted]
- georgieporgie 15y agoWhile I really like the quality and features of the VC++ compiler, I really wish they would do something about the IDE that's gotten worse for C++ devs over time...