comp.lang.ada
 help / color / mirror / Atom feed
From: "Dr. Adrian Wrigley" <amtw@linuxchip.demon.co.uk.uk.uk>
Subject: Re: PAR (Was: Embedded languages based on early Ada)
Date: Tue, 06 Mar 2007 02:01:33 GMT
Date: 2007-03-06T02:01:33+00:00	[thread overview]
Message-ID: <pan.2007.03.06.02.02.27.892793@linuxchip.demon.co.uk.uk.uk> (raw)
In-Reply-To: ygek5xvms48.fsf_-_@hugsarin.dmusyd.edu

On Mon, 05 Mar 2007 11:01:59 -0800, Jacob Sparre Andersen wrote:

> Ray Blaak wrote:
> 
>> PAR would only be convenience shorthand for writing task bodies
>> around each statement.

Yes.  The semantics are very similar.

> Wouldn't "pragma Parallelize (Statement_Identifier);" be a more
> reasonable way to do this?  As I understand the wish is to tell the
> compiler that these statements are a likely target for parallel
> execution.

I don't think we share this understanding.

PAR is about indicating in the source code which statement sequences
are unordered.  The idea is to make the syntax for concurrency
as simple as the syntax for sequentality. Perhaps using "par"
instead of "begin" is the way to go.  Adding "all" to the for
loop also makes a lot of sense.

If you can persuade programmers to use "par" unless they explicitly
*need* sequential execution, a great many statements will be marked
as concurrent.  Numeric codes will use "par" in the computational
core, as well as outer layers of execution.

So "par" is really about program *semantics*, not about *mechanism*
of execution.  Simply being in a "par" block is not a hint or
a recommendation that the compiler should target the code for parallel
execution.  The "par" block grants the authority to reorder
(even when results vary, whatever the reason).  And it informs the
*reader* that there is no implication of sequentality.

Ultimately, the hardware should be choosing dynamically whether
to create execution threads according to execution statistics
and resource allocation.  The instruction stream should have
potential thread creation and joining points marked. Perhaps
this can be via a concurrent call instruction ("ccall"?), which
is identical to a normal "call" when threads are scarce,
and creates a thread and continues execution at the same time
when threads are readily available.  The objective is to
have zero overhead threading at a fine grain of concurrency.

So I think the pragma Parallelize () is like the equivalent
of the "register" directive in C.  The programmer is trying to
say "I use this variable a lot, so store it in a register for me".
This approach is considered obsolete and counterproductive.
Automatic register allocation, automatic data caching
and automatic thread allocation should all be handled by the
compiler and hardware, whether or not the programmer
recommends it.  Registerization and caching work well with
existing serial code.  Automatic thread allocation is almost
impossible with existing code simply because code must
always be executed in the order given unless concurrency
is provable.  Coding with "par" is no big challenge.
Most programs will use par a lot. Only very short or exceptional
programs can't use "par".

> The compilers are of course already allowed to parallelise the
> execution of statements, but hinting where it is worthwhile to try
> might be more efficient.  Such a pragma will of course introduce a
> discussion of whether the result of the parallel execution should be
> exactly the same as the result of the sequential execution, or if it
> should just be approximately the same.

Often parallel execution will give very different results.

for I in all 2 .. 15 loop
   PutIfPrime (I);
end loop;

Produces
 2 3 5 7 11 13
with sequential operation, but
 11 13 2 3 5 7
with parallel execution.  Or indeed any other order.

The "par" says "I don't care what the order is".
One benefit is being able to continue executing the program while
multiple page faults are being serviced from disk or RAM.  Such
page faults show why parallelisation is often outside the scope
of the compiler - how does it know when the faults occur?
Program execution becomes a hierarchy of concurrent threads,
perhaps with over 1.0e10 threads available during a program's execution.

Mandating sequential execution except where the "pragma" is used
puts parallel statements at an immediate disadvantage - it makes
them seem to be second class citizens, added on afterwards
in an attempt to speed things up. Par should be "everywhere", it's
a *basic* component of program semantics - like a loop or a function call.
It's absent from programming languages is because processors can't really
take advantage of it at present, and text is inherently linear, needing no
special "seq" directive.  Graphical languages on the other hand often
imply concurrency automatically, and so have the opposite property. "par"
is not a hint.

Enough ranting for now...
--
Adrian




  reply	other threads:[~2007-03-06  2:01 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-23  0:59 Preferred OS, processor family for running embedded Ada? Mike Silva
2007-02-23  4:41 ` Steve
2007-02-23 16:00   ` Mike Silva
2007-02-23  4:49 ` Jeffrey R. Carter
2007-02-23 13:13   ` Mike Silva
2007-02-23 13:56 ` Stephen Leake
2007-02-23 14:10   ` Mike Silva
2007-02-24 10:45     ` Stephen Leake
2007-02-24 12:27       ` Jeffrey Creem
2007-02-24 22:10         ` Dr. Adrian Wrigley
2007-02-25 13:10           ` roderick.chapman
2007-02-25 17:53             ` Jeffrey R. Carter
2007-02-25 15:08           ` Stephen Leake
2007-02-28 17:20             ` Embedded languages based on early Ada (from "Re: Preferred OS, processor family for running embedded Ada?") Colin Paul Gloster
2007-03-01  9:18               ` Jean-Pierre Rosen
2007-03-01 11:22               ` Dr. Adrian Wrigley
2007-03-01 11:47                 ` claude.simon
2007-03-01 13:57                 ` Dmitry A. Kazakov
2007-03-01 18:09                   ` Ray Blaak
2007-03-02 11:36                   ` Dr. Adrian Wrigley
2007-03-02 16:32                     ` Dmitry A. Kazakov
2007-03-03  0:00                       ` Dr. Adrian Wrigley
2007-03-03 11:00                         ` Dmitry A. Kazakov
2007-03-03 11:27                           ` Jonathan Bromley
2007-03-03 12:12                             ` Simon Farnsworth
2007-03-03 14:07                               ` Dr. Adrian Wrigley
2007-03-03 17:28                                 ` Pascal Obry
2007-03-03 18:11                                   ` Dmitry A. Kazakov
2007-03-03 18:31                                     ` Pascal Obry
2007-03-03 20:26                                       ` Dmitry A. Kazakov
2007-03-03 21:28                                   ` Dr. Adrian Wrigley
2007-03-03 22:00                                     ` Pascal Obry
2007-03-03 13:40                             ` Dr. Adrian Wrigley
2007-03-03 15:26                               ` Jonathan Bromley
2007-03-03 16:59                                 ` Dr. Adrian Wrigley
2007-03-05 15:36                               ` Colin Paul Gloster
2007-03-03  1:58                       ` Ray Blaak
2007-03-03  8:14                         ` Pascal Obry
2007-03-03 11:00                         ` Dmitry A. Kazakov
2007-03-03 21:13                           ` Ray Blaak
2007-03-05 19:01                             ` PAR (Was: Embedded languages based on early Ada) Jacob Sparre Andersen
2007-03-06  2:01                               ` Dr. Adrian Wrigley [this message]
2007-03-06  3:30                                 ` Randy Brukardt
2007-03-06  7:10                                   ` Ray Blaak
2007-03-06 18:05                                     ` Ray Blaak
2007-03-06  6:04                                 ` tmoran
2007-03-06  6:59                                 ` Ray Blaak
2007-03-06  7:07                                 ` Ray Blaak
2007-03-06  7:22                                 ` Martin Krischik
2007-03-06 13:18                                 ` Dr. Adrian Wrigley
2007-03-06 18:16                                   ` Ray Blaak
2007-03-06 23:49                                   ` Randy Brukardt
2007-03-07  8:59                                     ` Dmitry A. Kazakov
2007-03-07 18:26                                       ` Ray Blaak
2007-03-07 19:03                                         ` Dr. Adrian Wrigley
2007-03-07 19:55                                         ` Dmitry A. Kazakov
2007-03-07 20:17                                           ` Ray Blaak
2007-03-08 10:06                                             ` Dmitry A. Kazakov
2007-03-08 18:03                                               ` Ray Blaak
2007-03-07 20:18                                           ` Pascal Obry
2007-03-07 20:41                                             ` Dr. Adrian Wrigley
2007-03-08  5:45                                               ` Randy Brukardt
2007-03-08 10:06                                                 ` Dmitry A. Kazakov
2007-03-10  1:58                                                   ` Randy Brukardt
2007-03-10  9:11                                                     ` Dmitry A. Kazakov
2007-03-08 18:08                                                 ` Ray Blaak
2007-03-10  1:50                                                   ` Randy Brukardt
2007-03-05 15:23                   ` Embedded languages based on early Ada (from "Re: Preferred OS, processor family for running embedded Ada?") Colin Paul Gloster
2007-03-06  0:31                     ` Dr. Adrian Wrigley
2007-03-01 16:09                 ` Colin Paul Gloster
2007-03-01 13:23               ` Martin Thompson
2007-02-26 16:34           ` Preferred OS, processor family for running embedded Ada? Jean-Pierre Rosen
2007-02-26 21:18             ` Dr. Adrian Wrigley
2007-02-27 15:39               ` Jean-Pierre Rosen
2007-02-28 12:25                 ` Jerome Hugues
2007-02-24 19:11       ` Mike Silva
2007-02-24 13:59     ` Jacob Sparre Andersen
2007-03-01 19:32       ` Jacob Sparre Andersen
2007-03-01 20:22         ` Mike Silva
replies disabled

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