comp.lang.ada
 help / color / mirror / Atom feed
From: Brad Moore <brad.moore@shaw.ca>
Subject: Re: GNAT and Tasklets
Date: Sat, 20 Dec 2014 10:36:55 -0700
Date: 2014-12-20T10:36:55-07:00	[thread overview]
Message-ID: <Wsilw.1234991$1s.181390@fx05.iad> (raw)
In-Reply-To: <m72i19$29s$1@loke.gir.dk>

On 14-12-19 06:05 PM, Randy Brukardt wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> 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.
>
>

  reply	other threads:[~2014-12-20 17:36 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-10 16:31 GNAT and Tasklets vincent.diemunsch
2014-12-11 10:02 ` Jacob Sparre Andersen
2014-12-11 16:30   ` Anh Vo
2014-12-11 18:15     ` David Botton
2014-12-11 21:45     ` Egil H H
2014-12-11 23:09   ` Randy Brukardt
2014-12-12  2:28     ` Jacob Sparre Andersen
2014-12-12  8:46   ` vincent.diemunsch
2014-12-12 23:33     ` Georg Bauhaus
2014-12-13  2:06   ` Brad Moore
2014-12-13  6:50     ` Dirk Craeynest
2014-12-14  0:18 ` Hubert
2014-12-14 21:29   ` vincent.diemunsch
2014-12-16  5:09     ` Brad Moore
2014-12-17 13:24       ` vincent.diemunsch
2014-12-16  4:42 ` Brad Moore
2014-12-17 13:06   ` vincent.diemunsch
2014-12-17 20:31     ` Niklas Holsti
2014-12-17 22:08       ` Randy Brukardt
2014-12-17 22:52         ` Björn Lundin
2014-12-17 23:58           ` Randy Brukardt
2014-12-18 10:39             ` Björn Lundin
2014-12-18 23:01               ` Randy Brukardt
2014-12-19  8:39                 ` Natasha Kerensikova
2014-12-19 23:39                   ` Randy Brukardt
2014-12-19  8:59                 ` Dmitry A. Kazakov
2014-12-19 11:56                 ` Björn Lundin
2014-12-20  0:02                   ` Randy Brukardt
2014-12-18  8:42       ` Dmitry A. Kazakov
2014-12-18  8:56         ` vincent.diemunsch
2014-12-18  9:36           ` Dmitry A. Kazakov
2014-12-18 10:32             ` vincent.diemunsch
2014-12-18 11:19               ` Dmitry A. Kazakov
2014-12-18 12:09                 ` vincent.diemunsch
2014-12-18 13:07                   ` Dmitry A. Kazakov
2014-12-19 10:40                   ` Georg Bauhaus
2014-12-19 11:01                     ` Dmitry A. Kazakov
2014-12-19 16:42                       ` Brad Moore
2014-12-19 17:28                         ` Dmitry A. Kazakov
2014-12-19 18:35                           ` Brad Moore
2014-12-19 20:37                             ` Dmitry A. Kazakov
2014-12-20  1:05                               ` Randy Brukardt
2014-12-20 17:36                                 ` Brad Moore [this message]
2014-12-21 18:23                                   ` Brad Moore
2014-12-21 19:21                                     ` Shark8
2014-12-21 19:45                                       ` Brad Moore
2014-12-21 23:21                                         ` Shark8
2014-12-22 16:53                                           ` Brad Moore
2014-12-21 21:35                                     ` tmoran
2014-12-21 22:50                                       ` Brad Moore
2014-12-21 23:34                                         ` Shark8
2014-12-22 16:55                                           ` Brad Moore
2014-12-22 23:06                                   ` Randy Brukardt
2014-12-20 16:49                             ` Dennis Lee Bieber
2014-12-20 17:58                               ` Brad Moore
2014-12-19 19:43                           ` Peter Chapin
2014-12-19 20:45                           ` Georg Bauhaus
2014-12-19 20:56                             ` Dmitry A. Kazakov
2014-12-19 23:55                           ` Randy Brukardt
2014-12-19 23:51                       ` Randy Brukardt
2014-12-18 22:33               ` Randy Brukardt
2014-12-19 13:01                 ` GNAT�and Tasklets vincent.diemunsch
2014-12-19 17:46                   ` GNAT?and Tasklets Brad Moore
2014-12-20  0:39                   ` GNAT and Tasklets Peter Chapin
2014-12-20  9:03                     ` Dmitry A. Kazakov
2014-12-20  0:58                   ` GNAT�and Tasklets Randy Brukardt
2014-12-18  9:34         ` GNAT and Tasklets Niklas Holsti
2014-12-18  9:50           ` Dmitry A. Kazakov
2014-12-17 21:08     ` Brad Moore
2014-12-18  8:47       ` vincent.diemunsch
2014-12-18 21:58         ` Randy Brukardt
2014-12-17 22:18     ` Randy Brukardt
2014-12-18  0:56     ` Shark8
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox