Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!brutus.cs.uiuc.edu!apple!snorkelwacker!spdcc!merk!alliant!fisher From: fisher@Alliant.COM (Larry Fisher) Newsgroups: comp.lang.fortran Subject: Re: WHERE statement Keywords: F8X Message-ID: <3504@alliant.Alliant.COM> Date: 27 Oct 89 14:57:39 GMT References: <10400001@jadoube> Reply-To: fisher@alliant.Alliant.COM (Larry Fisher) Distribution: na Organization: Alliant Computer Systems, Littleton, MA Lines: 39 I have one question in regard to the "conversion" of a DO loop with nested IFs to a Fortran 8X WHERE block: Why do the conversion? Working with the Alliant Fortran compiler, I have the option of using WHERE blocks when porting and tuning code. However, I find that it is rarely worth the time to do the conversion for a number of reasons. First, I assume that the reason for using WHERE is to get (force) the DO/nested IF structure to be mapped to vector hardware instructions. As a practical matter on today's vector processors, vectorized IF statements are worthwhile only if the conditionally-executed (cond-ex) statements are "frequently" executed. I quote the word frequently because the definition varies by machine and by computational complexity of the cond-ex code. Keeping the explanation brief, the implementation of vector IFs causes the cond-ex code to be executed *regardless* of whether or not the result will be used. The only part of the cond-ex code that is conditional is the storage into destination (left-hand-side) variables based on a mask; a mask that is the result of the IF statement's condition expression. Second, I (IMHO) view WHERE blocks to be a notational shorthand that is to be used where appropriate. The DO/nested IF example recently shown in this group is not one I would consider appropriate for a WHERE block. As was pointed out by the original poster, forcing the readable F78 code into a much-less-comprehensible F8x WHERE block doesn't make sense, never mind the fact that no equivalent to ELSEIF exists. Finally, It doesn't appear to me that the existing algorithm implemented in F78 is one that, without changes, will run effectively on vector hardware. Certainly we could discuss automatic mapping of DO/IF constructs to WHERE blocks by a Fortran compiler, as is done, where appropriate, by Alliant's FX/Fortran compiler, but that's just one of a number of other considerations tied to the above comments. "Opinions..." -- Larry Fisher Domain: fisher@alliant.com Alliant Computer Systems UUCP: {mit-eddie|linus}!alliant!fisher Littleton, MA 01460 Phone: (508) 486-1449