News for hackers. Stuff that matters.
Re:DCompute: GPGPU with Native D for OpenCL and CUDA by WalterBright on Monday July 17, 2017 @03:38PM (#14791691)
D has array expressions, which look like:

   a[] = c * b[];
The idea of them is they are parallelizable, and do not require an auto-vectoring loop optimizer. Auto-vectorizing is fraught with problems, like the user not being aware if the auto-vectorizing succeeded or not.

Another aspect of D that enables parallization is the use of ranges + algorithms. Although currently unexploited, it has the potential to be able to express parallel algorithms, and then take advantage of that.

Re:DCompute: GPGPU with Native D for OpenCL and CUDA by Athas on Monday July 17, 2017 @03:57PM (#14791838)
This can be vectorised for CPU execution (which is nice!), but it will not solve the problem for GPUs. Moving just that scalar-vector multiplication to a GPU would be detrimental to performance, because the run-time would be dominated by the cost of moving the 'b' array to the GPU, followed by moving the 'a' array back. You get into all kinds of issues with where to leave data that has no obvious right answer.

It also does not help with problems that are not as embarrassingly parallel, but could still benefit from vectorisation, such as summations (or reductions in general), or things that contain their own inner control flow (think a Mandelbrot set, where you have a larger outer parallel loop with an inner serial while-loop).

Re:DCompute: GPGPU with Native D for OpenCL and CUDA by yarg on Monday July 17, 2017 @04:30PM (#14792034)
That actually depends upon the architecture. If you have shared memory between GPU and CPU the copy latency is reduced by orders of magnitude - you're only waiting on the values to be populated in GPU's caches.

It'll be interesting to see what sort of context-switch performance comes out of the Zen APU devices when they are released (next year I believe).

I'd be somewhat surprised if Intel and NVidia aren't working on similar things.

Re:DCompute: GPGPU with Native D for OpenCL and CUDA by Athas on Monday July 17, 2017 @04:46PM (#14792135)
> If you have shared memory between GPU and CPU the copy latency is reduced by orders of magnitude - you're only waiting on the values to be populated in GPU's caches.

Shared memory by itself will not have a significant performance impact here (although it simplifies the data movement substantially). For a scalar-vector multiplication, you are strongly memory bound, and so you still have to wait for all the memory to be retrieved over the bus. You are correct if both CPU and GPU are behind the same bus (such as if the GPU is on the same die), but modern GPUs support shared virtual memory even for non-integrated GPUs.

Re:DCompute: GPGPU with Native D for OpenCL and CUDA by VHRanger on Monday July 17, 2017 @03:47PM (#14791762)
> Another aspect of D that enables parallization is the use of ranges + algorithms.

Is that similar to the C++ std::algorithm execution policy features introduced in C++17?

Re:DCompute: GPGPU with Native D for OpenCL and CUDA by nicwilson on Monday July 17, 2017 @08:07PM (#14793356)
No. What Walter is talking about in D is if you have

Foo[] foo = ...;

foreach(f; foo) { f.bar.baz.quux; }

and the computation is parallelisable then you can write

import std.parallelism; foreach(f; parallel(foo)) { f.bar.baz.quux; }

and it will parallelised across threads.

I guess std.parallelism's parallel might be more analogous to an "instance" of an executor.

Re:DCompute: GPGPU with Native D for OpenCL and CUDA by VHRanger on Thursday July 20, 2017 @03:05PM (#14815386)
So that's similar to OpenMP parallel for looping?
Re:DCompute: GPGPU with Native D for OpenCL and CUDA by WalterBright on Monday July 17, 2017 @04:07PM (#14791897)
I'm not familiar with that aspect of C++17.
Re:DCompute: GPGPU with Native D for OpenCL and CUDA by nicwilson on Monday July 17, 2017 @08:11PM (#14793371)
Its the tag based dispatching for the `par` in

std::sort(par,a.begin(),a.end());

to call a parallel implementation of sort on `a`.