Scientific computing and parallel computing C++23/C++26

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Jan 13 01:19:07 UTC 2022


On Thu, Jan 13, 2022 at 12:41:25AM +0000, forkit via Digitalmars-d wrote:
[...]
> I've had 8 cores available on my pc for well over 10 years now. I
> don't think anything running on my pc has the slighest clue that they
> even exist ;-)  (except the o/s).

Recently, I wanted to use POVRay to render frames for a short video
clip. It was taking far too long because it was running on a single core
at a time, so I wrote this:

	import std.parallellism, std.process;
	foreach (frame; frames.parallel) {
		execute([ "povray" ] ~ povrayOpts ~ [
			"+I", frame.infile,
			"+O", frame.outfile ]);
	}

Instant 8x render speedup. (Well, almost 8x... there's of course a
little bit of overhead. But you get the point.)


> I expect 'explicitly' coding parallelism will continue to be relegated
> to a niche subset of programmers/developers, due to the very
> considerable knowledge/skillset needed, to design/develop/test/debug
> parallel code.

For simple cases, the above example serves as a counterexample. ;-)

Of course, for more complex situations things may not be quite so
simple.  But still, it doesn't have to be as complex as languages like
C++ make it seem.  In the above example I literally just added
".parallel" to the code and it Just Worked(tm).


T

-- 
The best way to destroy a cause is to defend it poorly.


More information about the Digitalmars-d mailing list