comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Ada and OpenMP
Date: Sat, 9 Mar 2013 22:24:57 -0600
Date: 2013-03-09T22:24:57-06:00	[thread overview]
Message-ID: <khh1ur$b6b$1@munin.nbi.dk> (raw)
In-Reply-To: 513AB6D3.6030106@shaw.ca

"Brad Moore" <brad.moore@shaw.ca> wrote in message 
news:513AB6D3.6030106@shaw.ca...
> On 08/03/2013 4:36 PM, Randy Brukardt wrote:
...
>> Take the OP's example, for example:
>>
>> for I in 1 .. MAX loop
>>     A(I) := A(I) + 1; -- Can raise Constraint_Error because of overflow 
>> or
>> range checks.
>> end loop;
>>
>> This can be done in parallel only if (A) there is no exception handler 
>> for
>> Constraint_Error or others anywhere in the program; or
>
> I am working towards a new version of Paraffin to be released soon that 
> handles exceptions in such loops (as well as a number of other features).
>
> The technique though, is to have the workers catch any exception that 
> might have been raised in the users code, and then call 
> Ada.Exceptions.Save_Occurence to save the exception to be raised later.

I'd expect this to work fine - it's how I'd implement it if I was doing 
that. The issue, though, is that this changes the semantics of the loop WRT 
to exceptions. Specifically, the parts of A that get modified would be 
unspecified, while that's not true for the sequential loop (the items that 
are modified have to be a contiguous group at the lower end of the array).

That's fine for Paraffin, because no one will accidentally use it expecting 
deterministic behavior. It's not so clear when you actually write the loop 
syntax. Which is why a parallel loop syntax seems valuable, as it would make 
it explicit that parallelism is expected (and would also allow checking for 
dependencies between iterations, which usually can't be allowed).

Of course, an alternative would be just to standardize a library like 
Paraffin for this purpose, possibly with some tie-in to the iterator syntax. 
(I know you proposed something on this line, but too late to include in Ada 
2012.)

                                        Randy.





  reply	other threads:[~2013-03-10  4:24 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-07 18:04 Ada and OpenMP Rego, P.
2013-03-07 20:04 ` Ludovic Brenta
2013-03-07 22:22   ` Peter C. Chapin
2013-03-07 23:42     ` Randy Brukardt
2013-03-08  0:39       ` Peter C. Chapin
2013-03-08  3:31         ` Randy Brukardt
2013-03-08  7:17           ` Simon Wright
2013-03-08 23:40             ` Randy Brukardt
2013-03-08 12:07           ` Peter C. Chapin
2013-03-08 14:40         ` Rego, P.
2013-03-08  1:15       ` Shark8
2013-03-08  3:42         ` Randy Brukardt
2013-03-08 14:53           ` Rego, P.
2013-03-08 15:47             ` Georg Bauhaus
2013-03-08 23:40             ` Randy Brukardt
2013-03-08 16:52           ` Shark8
2013-03-08 23:36             ` Randy Brukardt
2013-03-09  4:13               ` Brad Moore
2013-03-10  4:24                 ` Randy Brukardt [this message]
2013-03-08  7:37       ` Simon Wright
2013-03-10 18:00       ` Waldek Hebisch
2013-03-07 23:43     ` Georg Bauhaus
2013-03-08 10:18       ` Georg Bauhaus
2013-03-08 14:24     ` Rego, P.
2013-03-07 22:52 ` Simon Wright
2013-03-08 21:37   ` Brad Moore
replies disabled

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