(j3.2006) Fw: a question on MERGE and expression evaluation

Bill Long longb
Fri Nov 19 11:11:54 EST 2010



On 11/18/10 8:14 PM, Van Snyder wrote:
>

>
> I definitely don't want to start with MERGE, because I'd like someday to
> see it explicitly require lazy evaluation (which is presently allowed
> but not required), at least in the scalar-mask case.  Either that or get
> conditional expressions (with lazy evaluation of either the consequent
> or anti-consequent, depending upon the predicate).
>
> Right now, the standard doesn't require evaluating all of MERGE's
> arguments, but it also doesn't prohibit evaluating the one that ends up
> not being used.  That makes MERGE less useful than it could be as a
> substitute for conditional expressions.  For example, you can't count on
>

On the other hand, it makes MERGE very useful for generating code for 
the new fad in processors - GPU's.  They have hardware for masked 
assignments, but are very poor at handling branches.   Requiring lazy 
evaluation would make MERGE essentially useless in that context.  And we 
would suddenly see proposals for a new intrinsic that behaved exactly as 
the current MERGE.  If we want an intrinsic that requires lazy 
evaluation, THAT one should be the new one.  With notes by the text book 
writers to not use it in vectorizable code segments.

>    x = merge(y,0,present(y))
>
> working.
>
> Jim's customer wants to count on
>
>    merge(1.0/a,0,a/=0.0)
>
> not working when a == 0.  Why would you want that not to work?  I would

In the modern IEEE world, this does work. 1./0. -> Infinity and is 
perfectly well defined. It might set a flag bit somewhere, but almost no 
one ever checks those bits.

Cheers,
Bill


> much prefer that it be guaranteed to work, rather than that it work or
> not work at the compiler's whim.
>
>> Cheers,
>
>
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3

-- 
Bill Long                                           longb at cray.com
Fortran Technical Support    &                 voice: 651-605-9024
Bioinformatics Software Development            fax:   651-605-9142
Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101





More information about the J3 mailing list