(j3.2006) Fw: (j3-members.2015) Question about DO CONCURRENT
Malcolm Cohen
malcolm
Mon Feb 16 01:35:03 EST 2015
Daniel Chen writes:
<<<
I guess what I want to confirm is if Malcolm's example as it is (without BLOCK)
is standard conforming.
If it is not, the standard doesn't seem have explicit restrictions to disallow
it.
If it is conforming, it doesn't seem have a well defined behavior by the current
wording as well.
>>>
My example would have to be conforming; the standard has perfectly well defined
behaviour for it - if it gets assigned a value by precisely one iteration the
(outer) variable has that value on completing the loop, and if it gets assigned
a value by more than one iteration, the outer variable becomes undefined on
completing the loop (i.e. it became a per-iteration temp). It's just that
(because of the difficulty in knowing which case you actually have) the best
level of performance might be unobtainable.
There are various strategies by which you might still get reasonable
performance, e.g. by duplicating the variable to have an iteration-local one
plus a writeback to the global one (that enables parallellisation of the loop
but there is a small overhead of the extra variable).
Or the compiler vendor could issue a "performance warning" when spotting this
kind of conditionally-assigned variable that "performance might be improved by
declaring the variable local to the loop iterations with a BLOCK construct". On
the off-chance that this is an inner loop for which performance is critical,
that could be good advice.
Cheers,
--
................................Malcolm Cohen, Nihon NAG, Tokyo.
More information about the J3
mailing list