From: corbett@lupa.Sun.COM (Robert Corbett) Newsgroups: comp.lang.fortran Subject: Re: FTN95 minval() and maxval() question Date: 16 Dec 2000 07:14:21 GMT In article <3A3A3A1C.A0B8480@atm.ox.ac.uk>, Bob Wells <wells@atm.ox.ac.uk> wrote: >Michael Metcalf wrote: > >Was anybody else as depressed as I was by this thread ? >A compiler bug can be demonstrated in less than a dozen lines >of code so straightforward that even I can understand it. >Nothing exotic or "near the boundary of the standard". >Almost 77 in fact. >Further, a Fortran sage suspects a bug without any expression of >surprise, so presumably such bugs are not a rare. >Hasn't compiler writing improved during Fortran's long life ? Yes, it has. Nonetheless, modern Fortran compilers are less stable than FORTRAN 77 compilers. Changes made to the Fortran language in the past decade make it much harder to write a Fortran compiler. The front-end portion of Sun's Fortran 95 compiler consists of 16 times as many lines of source as the front-end portion of Sun's FORTRAN 77 compiler. More than half of the code in the front-end portion of Sun's Fortran 95 compiler is devoted to analysis and optimization of array expressions. Sincerely, Bob Corbett

From: robert.corbett@sun.com Newsgroups: comp.lang.fortran Subject: Re: Fortran 77 vs Fortran 90/95 Date: 6 Aug 2005 21:40:11 -0700 Message-ID: <1123389611.331673.3440@g47g2000cwa.googlegroups.com> > How different is it from Fortran 77? Fortran 95 is quite different from FORTRAN 77. Almost all of standard-conforming FORTRAN 77 is there, but finding it among the crowd can be challenging. Fortran 95 is much more complex than FORTRAN 77. Fortran 2003 is much more complex than Fortran 95. I have seen the proposals for extensions in the next Fortran standard, and if even a quarter of those proposals are approved, the next standard will be much more complex than Fortran 2003. > What are the advantages of it over Fortran 77? There are lots of advantages. In my opinion, the most important is dynamic storage allocation. > How stable is Fortran 90/95 compared to Fortran 77? The FORTRAN 77 subset of Fortran 95 tends to be fairly stable. All the vendors have good test suites for FORTRAN 77. OTHO, Fortran 95 compilers are, as a rule, much bigger and much slower than FORTRAN 77 compilers. Optimizing array expressions in particular is a bottomless sink for code space and compilation time. Bob Corbett

From: robert.corbett@sun.com Newsgroups: comp.lang.fortran Subject: Re: Sun Studio Express 3 compilers available for download Date: 22 Dec 2006 00:08:31 -0800 Message-ID: <1166774911.514910.29420@48g2000cwx.googlegroups.com> Gary Scott wrote: > robert.corbett@sun.com wrote: > > Sun f90/f95 is a big compiler for a big language. > > > > The days of small, fast Fortran compilers ended > > with Fortran 90. Sun could provide a much smaller > > compiler by dropping certain optimizations, but > > I don't think most users would be pleased by that > > trade-off. I predict that Sun's Fortran 2003 > > compiler will be about 50% larger than Sun's > > current Fortran compiler. I hate to think how large > > a compiler for Fortran 2008 will need to be. > > How does F95 compare to Ada 95, C++, Delphi compilers roughly? A Fortran 95 compiler that did not try to produce good code would probably be smaller than an Ada or C++ compiler. A Fortran 95 compiler that tries to generate good code for array expressions is going to be big. I am unaware of any effective algorithms for optimizing a general array expression. A superoptimizer approach might work, but I'm guessing that most people would like their optimized compilations to finish before the heat death of the universe. Therefore, optimizing array expressions is, like much of compiler optimization technology, a matter of recognizing special cases and generating good code for them. The problem is that the number of interesting special cases is greater than any compiler can handle. With Fortran 2008, my guess is that even a compiler that does not try to do any optimizations will be larger than a comparable Ada or C++ compiler. Bob Corbett

From: robert.corbett@sun.com Newsgroups: comp.lang.fortran Subject: Re: Sun Studio Express 3 compilers available for download Date: 8 Jan 2007 20:05:43 -0800 Message-ID: <1168315543.505907.207510@v33g2000cwv.googlegroups.com> ejko123@yahoo.com wrote: > robert.corbett@sun.com wrote: > > > > I am unaware of any effective algorithms for optimizing a general > > array expression. A superoptimizer approach might work, but I'm > > guessing that most people would like their optimized compilations > > to finish before the heat death of the universe. > > This is probably much more than can be adequately discussed here, > but I'd like to understand why this is hard. Is it hard because of > the register allocation problem, the array temporary problem, or > something else? Are there some good review papers on the subject? It's not that it is hard; it is that the number of possible cases involved is huge. Consider the fragment IF (COUNT( (/ a, b, c, d /) ) == 4) THEN where a, b, c, and d are LOGICAL expressions. This fragment comes from real world code. A naive code generator might allocate space for a temporary array of four LOGICALs, assign the values of a, b, c, and d to the elements of the array, execute a loop over the array counting the number of elements that are not .FALSE. and then compare the result against 4. A sophisticated code generator might evaluate the expression as if it were the equivalent expression a .AND. b .AND. c .AND. d The sophisticated code will run much faster than the naive code. Sun f90/f95 is not yet sophisticated with regard to this expression. A superoptimizer would eventually find the sophisticated implementation of the expression. A normal code generator is not going to find it unless the expression is among the patterns it recognizes. Even simple cases get complicated. Consider the assignment A = 0 where A is an array of rank > 1. If A is a contiguous array, the fastest code for doing the assignment might be to compute the number of elements of the array, and do a flattened loop over the entire array. If A is a pointer array, it might be advantageous to test if A is contiguous and do the flattened assignment if it is, while using a nested loop version of the assignment to handle the other cases. Bob Corbett

Index Home About Blog