This is the mail archive of the
mailing list for the GCC project.
Re: For which gcc release is going to be foreseen the support for the Coroutines TS extension?
- From: Iain Sandoe <idsandoe at googlemail dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: GCC <gcc at gcc dot gnu dot org>, Nathan Sidwell <nathan at acm dot org>, Sebastian Huber <sebastian dot huber at embedded-brains dot de>, Florian Weimer <fweimer at redhat dot com>, Richard Biener <richard dot guenther at gmail dot com>
- Date: Wed, 21 Aug 2019 13:29:36 +0100
- Subject: Re: For which gcc release is going to be foreseen the support for the Coroutines TS extension?
- References: <CAFegzBQVDrywxU14-YTC5Jw2fxksyPmQcc0omMMWHOjv4email@example.com> <CAH6eHdQtY+ANHatqYugCZsY7vEj=kjowQqe8rseotWb8x50FzQ@mail.gmail.com> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <75F0CC8E-8255-4A0C-9D14-AA1A6349440D@googlemail.com> <email@example.com> <35DC8BFA-112B-4E2C-BF4F-CEBDF62DDCC5@gmail.com> <firstname.lastname@example.org>
> On 20 Aug 2019, at 17:15, Florian Weimer <email@example.com> wrote:
> * Richard Biener:
>> On August 20, 2019 5:19:33 PM GMT+02:00, Nathan Sidwell <firstname.lastname@example.org> wrote:
>>> On 7/26/19 6:03 AM, Iain Sandoe wrote:
>>>> Hello Sebastian,
>>>>> On 26 Jul 2019, at 10:19, Florian Weimer <email@example.com> wrote:
>>>>> C++ coroutines are stackless. I don't think any new low-level
>>>>> support will be needed.
>>>> correct, C++20 coroutines and threading mechanisms are orthogonal
>>>> facilities; one can use (IS C++20) coroutines on top of a threaded
>>>> or in a single-threaded environment.
>>>> Two places I see them as being a go-to facility in embedded systems
>>>> * co-operative multi-tasking UIs on single-threaded platforms.
>>>> * async I/O completion by continuations, rather than callbacks.
>>> There are cases where the overhead of threads is too expensive. For
>>> instance hiding (cache-missing) load latencies by doing other work
>>> waiting -- a context switch at that point is far too expensive.
>> But are coroutines so much lower latency (and a context switch does
>> not involve cache misses on its own?). For doing useful work in this
>> context CPU designers invented SMT...
> I think the idea is that you don't have to worry about synchronizing
> multiple threads to reap the benefits from hardware parallelism. For
> hiding memory access latency, that could be important because the
> synchronization overhead could easily eat up any potential benefits.
It seems to me that this is another “tool” in the “toolbox”, and as such
will find use in more cases than the performance example given above.
Some uses might have more to do with code clarity than performance,
* e.g. any code that’s written in terms of a state machine, or as a large
body of callbacks, might prove to be a candidate for clearer representation
* There’s a potentialy large reduction in held state for cases where the
processing is organised as a series of transformations (as the original
motivating example was a compiler where it was inconvenient to produce
and consume that state between passes).
* There’s clearly an industry quest for a lighter weight representation than
threads and this is being driven (amongst others) by some of the largest
users of massively parallel systems - so SMT is not meeting all their needs.
Representatives from this group are saying that coroutines are part of the
solution that they want (and backing that up by sponsoring the language
development work and several compiler implementations). I don’t have
visibility of their specific internal use-cases, of course, unfortunately.
* Avoiding recasting problems into a form suitable for overt multi-threading
* I expect (and already have one such person reporting bugs against my
branch) that the embedded (no threads) space will find this a clearer way
to implement some functionality (co-operative multitasking user interfaces
springs to mind as noted in a previous post).
I suppose that in the end we will not know how this tool is going to be used
until it gets wider exposure (although there are some production uses of
the LLVM implementation, it’s likely that people won’t commit heavily until
it’s in the standard).
0.02GBP only ..