Path: utzoo!attcan!uunet!convex!mozart!mercer From: mercer@mozart.uucp (Randall Mercer) Newsgroups: comp.lang.fortran Subject: Re: Why array notation Message-ID: <698@convex.UUCP> Date: 6 Nov 88 23:04:01 GMT References: <689@convex.UUCP> <1763@garth.UUCP> Sender: news@convex.UUCP Reply-To: mercer@mozart.UUCP (Randall Mercer) Organization: Convex Computer Corporation, Richardson, Tx. Lines: 57 In article <1763@garth.UUCP> smryan@garth.UUCP (Steven Ryan) writes: >> PDO 10 I=1,N ! PDO for "PARALLEL DO" >>10 A(I)=B(I+1)+C(I) >> >>The latter requires minimal syntactic changes and, for long loops, is >>more concise and readable. Is the problem with the details of defining >>"PDO", or is it some more strategic reason? > >perhaps: > >(1) say what you mean, don't use something that looks sequential for parallel. > Use of PDO instead of DO should make it look parallel. I think syntactic simplicity is an advantage here. >(2) what about > > PDO I=1,N > A(I)=A(I+1)+A(I-1)) > > or > > PDO I=1,N > B(I)=A(I)+C(I) > A(I)=A(I)+B(I+1) > C(I)=C(I)+B(I-1) There are many different ways of resolving these problems, suggesting that one might want more than one variety of PDO. For example, you could define the statements to be executed sequentially, but each statement to be executed as an array operation and array assignment. Essentially that would give FORTRAN 8x semantics with the triplet notation "factored" out of several statements into the PDO. A more useful definition for a vector machine would prohibit recurrences and dependencies whose direction is counter to statement order (like the antidependency from B(I+1) to B(I)= in your second example. A useful variant for a MIMD machine would prohibit all dependencies between iterations. For a SIMD machine, PDO could be defined to load all right-hand sides, then store all left-hand sides. Your first example would be quite meaningful with that definition. I think I would rather have MIMD_PDO, SIMD_PDO, and VECTOR_PDO, then have to learn a distinct syntax for each variation. Other reasons I've seen in responses for preferring array notation are (1) it's easier to implement (2) it's usually more concise (3) it's less researchy and has already been done (4) it lets you manipulate arrays as "first-class" objects I don't believe (1). (2) is true for APL, but only sounds plausible for FORTRAN 8x. I've seen FORTRAN code with very odd indexing that would translate to very expansive and ugly triplet notation. (3) is sort of true, but virtually every vectorizing or parallelizing compiler has some kind of PDO equivalent implemented with directives. (4) is an appealing reason to me. How far does FORTRAN 8x go in providing APL-like support for array manipulations?