DConf '22 Talk: Structured Concurrency
max haughton
maxhaton at gmail.com
Wed Oct 12 16:07:33 UTC 2022
On Wednesday, 12 October 2022 at 09:28:07 UTC, Markk wrote:
> Hi,
>
> having watched the [Structured Concurrency
> talk](https://youtu.be/hJhNhIeq29U), and very likely missing
> something, I wondered if **@Sebastiaan Koppe**, or anybody
> else, has ever compared this to
> [OpenMP](https://www.openmp.org/). If I'm not mistaken (and
> after just having [watched the very nice Intel
> tutorial](https://www.youtube.com/playlist?list=PLLX-Q6B8xqZ8n8bwjGdzBJ25X2utwnoEG) to refresh my limited knowledge), OpenMP seems to use the same kind of scoping/structuring, and allowing composition.
>
> So, again unless I'm missing something, I guess the term
> "Structured Concurrency" and "Composability" would equally
> apply to the much older (1997) OpenMP solution, right? If true,
> it was _not_ missed for 30 years, [as Walter Bright wondered,
> during
> Q&A](https://www.youtube.com/watch?v=hJhNhIeq29U&t=3134s) 😉
>
> Note: Most OpenMP examples just obsess about `for` loops and
> plain parallelism, but make no mistake, there is much more to
> it. One must also understand the `section` and `task`
> directives, to grasp the full capabilities.
>
> IMHO this is all extremely elegant:
> - [Parallelize a program without breaking the serial
> version](https://youtu.be/EaX8efKce9M?t=408).
> - Going from [this problem](https://youtu.be/I0c9-W0MBqw?t=99)
> (and after a very inelegant manual detour), you get [this
> solution using `task`](https://youtu.be/mNPmylnhYYQ?t=66)
> (amazing!).
>
> It seems to me that such a language integrated and mostly
> _declarative_ solution, would be very "D"-ish. _Declarative_
> IMHO is the "right" way to go with the increasing NUMA
> characteristics of systems (also think the problematic of E-
> and P-cores). One must let the compiler/runtime decide the best
> threading/scheduling strategy on a given platform, otherwise
> the code will likely age badly, quickly.
>
> I really wonder if this is one of these famous cases where the
> same old concept is "reinvented" using different buzzwords?
> Just because a tech is old does not mean it is bad, I would say
> _au contraire!_ I sometimes wonder: are the supercomputing
> grandpas just too unfashionable for the cloud/web-kiddies to
> talk with?
>
> -Mark
It is true that OpenMP has often usually done something "new"
being touted - this library is more focused on strict concurrency
though: parallelism can come as a consequence of a rigorous
concurrency model, but the library is at the moment more aimed at
concurrent processing of data (i.e. get data -> process data ->
output -> wait for more data, rather than all the data arrives
then we process it all in parallel then stop).
I had a play with finding a natural way to express OpenMP
constructs in D, the issue, I think, is that the spec is huge and
seems to be happy with the assumption that it can be inserted
into the syntax of the language (which is a little too brutalist
for my tastes). That being said we could probably just add a slot
for a pragma on loops and so on.
More information about the Digitalmars-d
mailing list