comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Ada 2012 automatic concurrency?
Date: Thu, 27 Dec 2012 00:55:11 +0200
Date: 2012-12-27T00:55:11+02:00	[thread overview]
Message-ID: <ak1difFu5plU1@mid.individual.net> (raw)
In-Reply-To: <af146e53-f736-4c59-8015-60a90d9f5fcf@googlegroups.com>

On 12-12-25 19:26 , charleshixsn@earthlink.net wrote:
> In the RM I read (page 209): NOTES 1 Concurrent task execution may be
> implemented on multicomputers, multiprocessors, or with interleaved
> execution on a single physical processor. On the other hand, whenever
> an implementation can determine that the required semantic effects
> can be achieved when parts of the execution of a given task are
> performed by different physical processors acting in parallel, it may
> choose to perform them in this way.
> 
> ---------------- Does this imply that if I use protected types, that
> the code will automatically be run concurrently on a multiprocessor
> system, or might automatically be run concurrently?

I believe that the second sentence in your quote has a more general
meaning: that an Ada compiler is allowed to generate code that uses
several processors or cores in parallel just to implement a logically
sequential (single-task) computation. For example, if your program
contains the two statements:

   x := a + b;
   y := a - b;

and the target computer has two processors or cores capable of addition
and subtraction, the Ada compiler may generate code that uses these two
processors in parallel, one to compute a+b and the other to compute a-b.
This is allowed, since the semantic effects are the same as when using
one processor for both computations (assuming that none of these
variables is declared "volatile").

So I don't think that your use or non-use of protected types (or tasks)
is relevant to this RM sentence.

> If so, does Gnat do this?

I think not, but it might be a feature of the GCC back-end rather than
the GNAT Ada front-end.

However, many high-performance processors today have multiple
"functional units" per core, and the processor core itself can issue or
execute several instructions in parallel, from the same program, even if
the compiler intends or assumes sequential execution when it generates
the instruction sequence.

This multi-issue feature of modern processors means that there is less
interest and profit in doing such fine-grain parallelization at
compile-time. At most, the compiler should sequence instructions
according to the data dependencies, to let the processor run several
consecutive data-independent instructions in parallel.

For large-grain parallelization, you should use tasks. I don't know of
any Ada compiler, including GNAT, that does automatic large-grain
parallelization.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
      .      @       .



  parent reply	other threads:[~2012-12-26 22:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-25 17:26 Ada 2012 automatic concurrency? charleshixsn
2012-12-26 22:02 ` John B. Matthews
2012-12-26 22:55 ` Niklas Holsti [this message]
2012-12-27  5:57   ` charleshixsn
2012-12-27  8:59     ` Dirk Heinrichs
2012-12-27 11:22       ` Brian Drummond
2012-12-27 22:13       ` Randy Brukardt
2012-12-27 14:27     ` Jeffrey Carter
2012-12-27 20:13       ` tmoran
2012-12-27 19:06     ` Niklas Holsti
replies disabled

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