From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!newsfeed0.kamp.net!newsfeed.kamp.net!nx02.iad01.newshosting.com!newshosting.com!69.16.185.111.MISMATCH!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!fx05.iad.POSTED!not-for-mail From: Brad Moore User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: =?windows-1252?Q?GNAT=A0and_Tasklets?= References: <8277a521-7317-4839-b0b6-97f8155be1a4@googlegroups.com> <9e1d2b9f-1b97-4679-8eec-5ba75f3c357c@googlegroups.com> <478c81f9-5233-4ae1-a3eb-e67c4dbd0da1@googlegroups.com> <1r2ziulc78imb$.ad6zx5upic6s$.dlg@40tude.net> <1gfkkgi7ukoj3$.1pqtchynzp9rc$.dlg@40tude.net> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 68.145.219.148 X-Complaints-To: internet.abuse@sjrb.ca X-Trace: 1419097014 68.145.219.148 (Sat, 20 Dec 2014 17:36:54 UTC) NNTP-Posting-Date: Sat, 20 Dec 2014 17:36:54 UTC Date: Sat, 20 Dec 2014 10:36:55 -0700 X-Received-Bytes: 4602 X-Received-Body-CRC: 2590547758 Xref: news.eternal-september.org comp.lang.ada:24179 Date: 2014-12-20T10:36:55-07:00 List-Id: On 14-12-19 06:05 PM, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:1gfkkgi7ukoj3$.1pqtchynzp9rc$.dlg@40tude.net... >> On Fri, 19 Dec 2014 11:35:05 -0700, Brad Moore wrote: > ... >>> I haven't listed all the semantics but for the questions you ask, >>> each arm of the parallel block is a separate thread of execution (which >>> we have been calling a tasklet). >>> >>> Each tasklet starts off with its own local declaration of Total, >>> initialized to 0, which is the Identity value for the reduction. >>> >>> So, for the top Total, you end up with {Top_}Total := 1 + A + B; >>> for the bottom Total, you end up with {Bottom_}Total := C + D; >>> >>> Then during the reduction phase, those two results get reduced using the >>> reduction operation, which in this case is "+". >>> >>> So the end result is Total = 1 + A + B + C + D; >> >> I think that the block should have explicit parameters, e.g. Total must be >> an in-out parameter of the block. The syntax should be similar to the >> selective accept. Each arm must also have parameters, and only those and >> of >> the block must be visible within an arm. E.g. A, B must be parameters. >> Nothing else should be visible. > > Interesting. This does sound like a better approach to me. (The whole > reduction object idea seems to me to be the worst part of the parallel > proposals -- something needs to be available, but that doesn't seem to be > the way to do it.) > > OTOH, the syntax to specify such parameters doesn't seem natural. We surely > don't want to force a parallel block or loop to be the only contents of a > subprogram. > > More thought required. I had considered the idea of parallel block parameters as well, as the underlying idea has appeal, but had dismissed the idea in my mind due to similar reasons. Having a parameter list in the middle of a section of code looks plain weird to me. It looks like a callable entity, but the call is never made. The call implicitly occurs when the parallel block is encountered in the thread of execution, and the parameters are implicitly passed from other objects having the same name. I would think that would be quite foreign to existing Ada programmers, and might be considered somewhat inelegant. It seemed better to treat this as a simple control structure more like an if statement, and leave the parameter passing and exception contracts to the enclosing subprogram. As for reduction. We haven't yet discussed reduction for parallel blocks. It's not clear that we even need that, because in a parallel block, it seems easy enough to declare separate variables, and then write the reduction yourself. eg. function Fibonacci (N : Integer) return Integer is Left, Right : Integer := 0; begin if N <= 2 return N; parallel Left := Fibonacci (N - 1); and Right := Fibonacci (N - 2); end parallel; return Left + Right; -- No automatic reduction needed end Fibonacci; Brad > > Randy. > >