From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 110292,45b50f14dadfce5b X-Google-Attributes: gid110292,public X-Google-Thread: 1164f8,45b50f14dadfce5b X-Google-Attributes: gid1164f8,public X-Google-Thread: 102b75,45b50f14dadfce5b X-Google-Attributes: gid102b75,public From: Craig Burley Subject: Re: Final kick at the "Merced Guessing Game" Date: 1997/10/15 Message-ID: X-Deja-AN: 280789853 References: <61g30t$o2n@news-rocq.inria.fr> <343C34A7.B715A348@tonys.ecology.umn.edu> <3440F805.C98BB347@tonys.ecology.umn.edu> <61tfaa$9fr@sis.cambridge.arm.com> <3442F866.36A8BB69@tonys.ecology.umn.edu> Organization: Cygnus Support Newsgroups: comp.sys.intel,comp.arch,comp.sys.dec boo writes: > Craig Burley bored us with his thesis, which contained the gem: > > > But, in my experience, the numerical types who use Fortran *already* > > have their algorithm issues worked out, because they're engineers, > > not programmers, and because they *have* to. E.g. it doesn't bother > > me much if my compiler is twice as slow as it could otherwise be > > on my home PC, at least, not compared to how much these numerical > > types are bothered when their latest number-cruncher is 2% slower than > > it could otherwise be, when that 2% costs them $10,000 per week due > > to it being run on a supercomputer on which they're buying time. > > > > C programmers just don't usually have as much vested interest in > > squeezing out that last 2% or so -- after all, their users can just > > wait for the next Pentium to come out anyway, while Fortran programmers > > include a pretty substantial group that depends on today's fastest > > and most expensive computers, and a newer, faster computer only > > means they can stuff more data into, or make more accurate > > calculations in, their programs, instead of using the next generation > > to cover up their programming inefficiencies. > > How about super-computer user who wants the best possible performance > and the greatest flexibility, and chooses C over Fortran? I'd guess that he probably isn't doing intense numerical computation. Personally, if I had to choose between C and Fortran in implementing a supercomputer-based compiler (for some other language entirely, let's assume), I'd *still* want to write it in C. But I'd miss some of Fortran's advantages when it came to generating a faster version of the compiler. Similarly, I'd think that numerical programmers would find that Fortran gets them the most performance on their supercomputers (especially vector machines and the like), especially if they care about portability to *other* supercomputers. (If they don't, it probably doesn't matter which language they choose, though if they're going as low as writing lots of explicitly-parallelizing code, maybe C becomes a better choice at that point...especially if the API being dealt with it written in C, which means that C's been given an unfair advantage in this case, but it is a *practical* advantage.) > I think you have it wrong. The best compilers on the supercomputers > have traditionally been Fortran compilers. Those ones always get > the most development time, so naturally lead. Why do they get the > most attention? Because the supercomputer user is more likely than > not, a Fortran programmer, the language of the Engineer. If a typical > supercomputer user were a C programmer, the Fortran compilers would > not be as good! Fortran leads because Fortran is Entrenched! However, > with the advent of MPP supercomputers and nodal message passing > programming styles possible, efficient C code compares very favorably > with the best F90 code, surpassing it in many instances. Of course, > it is much easier and quicker to write a F90 program, than a > carefully thought out messaging passing nodal C code. (Nodal f77 > code is also extremely efficient, compared with the F90 type > "parallel" code... but I see this as writing a Fortran program > in a C style, because the same level of thinking is required of > C to lay the "arrays" out across the nodes explicitly, what you > call "lowering"). It certainly was true on the Cray vector > supercomputers that C performance simply sucked compared with > the mature Fortran compilers, but this is not the case anymore! > (for some, not all). This really has only changed relatively recently. All good points. Note that once you take up the argument that F77 compilers tend to do better on numerical code than C compilers only because they've got more acceptance and hence more resources, however, you pretty much depart from what I thought we were discussing here, which is which *language* offers the best constructs for efficient programming. My point has been, all along, to point out that while C and Fortran share pretty much the same set of low-level operations -- the kind that allow programmers who know their algorithms *and machines* inside and out to write code that a compiler can, fairly easily, compile directly to efficient code, Fortran offers higher-level constructs that are a) not offered *at all* by C and b) important for scientific/numeric programming. So, in my opinion (and I do claim this is basically 100% fact, so it is *not* a humble opinion), the back end of a Fortran compiler will pretty much *always* be able to do a better job compiling "vanilla", that is, straightforward, write-what-you-mean-type numerical code, for a variety of machines, than the back end of a C compiler will, *given that the same amount of resources went into developing each of the back ends*. Yes, I *know* that if we threw tons of resources behind making C compilers more clever at teasing out the original intent of the programmer, we could make it produce fast code for even numerical codes. Then we could tell all Fortran programmers to spend more time writing C code than they have to write Fortran code, but we'd have One True Language that everyone could use. But, the same *could* be said for the ix86 instruction set. Why not throw, say, 10x-100x the resources we'd otherwise spend on making better C compilers behind making better ix86 decompilers/recompilers instead (more resources needed to tease out more original info)? Then we'd have One True Language indeed, and nobody would have to rewrite Fortran to C, or port C code from ix86 to Alpha or SPARC, we'd just make the ix86 set, which has a huge existing code base, the universal language, by "solving" the performance problem! I'm not seriously suggesting this, of course, but pointing out that once you start saying "well, with enough resources, we could make code written in language X as efficient as that written in language Y", you invite all sorts of options -- and trouble. The fact is that people are *still* unable to write what they mean in their common, everyday codes, regardless of whether they're writing it in Fortran or C. But Fortran *does* offer some improved opportunities in these areas, with its multi-dimensional arrays, its functions, its .AND. and .OR., its lack of permitted aliasing, and C *is*, in the form of various (often poorly engineered, IMO) extensions, trying desperately to catch up -- suggesting C compiler writers have chosen to burden the programmer rather than have their compilers perform the kinds of analyses you, and other C enthusiasts, keep claiming *would* make C as good a performer on *existing* code as Fortran. That suggests to me that, if you're as smart as you think you are, stop wasting time writing optimized C code for particular machines, and go implement a C compiler that blows Fortran away for numeric processing. You'd make *millions* of dollars within the first two years, I suggest. > It is much easier to produce an efficient F90 code than an > efficient C code, that much is obvious. > > > [childish MS bashing masquerading as a analogy snipped] Not childish at all, since it wasn't MS-bashing. It was "humor", a style of writing used to make a point. If you want to claim that the point was invalid, or MS was a bad example, or that I really was "bashing" MS instead of making a point, you're free to make that argument here, if you like. > Exactly what does Microsoft bashing have to do with C vs Fortran? Not bashing Microsoft per se -- I was pointing out how different *programmers* are from *engineers*, and Microsoft is The Example our industry has of that difference, given how many programmers they gainfully employ. C and UNIX are other, great, examples of the winning out of programming/hacking over engineering, but they're rather stale at this point. I even hesitate to use Microsoft as an example, given that they've been a popular target for years anyway, but they're still the best example for the analogy today, especially in a humorous analogy. (For example, assuming that programmers who write Java code today *will* be still using Microsoft products to run their same code tomorrow *is* a case of ignoring real-world complexities to make one's own life simpler. Even Digital was explicitly showing, using different colors, which Fortran features were industry standard versus Digital-provided extensions in their Fortran manuals back in the early '80s, and maybe earlier for all I know. Does Microsoft make such distinctions clear to its users, who *think*, due to industry hype they are believing in, that they're writing "Java", or creating "Web pages", or writing "HTML documents", when in fact they're writing "Microsoft sorta-Java-like", or creating "Internet Explorer pages", or writing "MS-HTML documents"? I don't know, but somehow, I get the impression, the answer is no, they're not making the distinctions clear so their users can know which features to avoid to write Java/Web/HTML. So their users *think* they're creating industry-standard works, when in fact they're locking themselves into Microsoft's world, something they should be doing only as part of a well-thought-out strategy, if at all.) We all have a choice, as end users, as programmers, and as engineers, whether to honor people and businesses who put "making it work" at a lower priority than #1 in designing and building products. "Making it work as long as..." is often a recipe for disaster. Tacoma Narrows Bridge: "making it work as long as winds below 35mph (or whatever)", because it *was* more important to make it inexpensive and elegant. (This is the bridge that tore itself apart within a few years of being built.) CitiCorp building in NYC: "making it work as long as high winds don't hit edge on", because it *was* more important to come up with a new, dramatic design to look good on the skyline (and, presumably, again, be less expensive). (That building was quietly and, I hope, effectively fixed in the dark of night, with secret, large-scale evacuation plans in place should a storm turn into NYC ahead of schedule.) Then again, Empire State Building in NYC: "making it work" #1. Even as the Depression hit, they didn't start cutting corners, even down to preserving the design work on the interior, certainly preserving the structural integrity, making sure it "stood up" before they worred whether it "stood out". Result? It's still standing. Even after being hit by a largish plane. (And, of course, many more storms than most modern buildings have experienced.) Yes, it's *possible* to build increasingly complex, interrelated things and manage the complexity sufficiently to keep the risks and costs down, but today's wise man recognizes that we're *already* at, or beyond, our ability to cope with our own technological creations sufficiently to keep them safe, standing, and working, and so generally chooses simpler systems designed to cope with today's complex environment over more complex systems that are designed assuming the environment will be simplified by their existence. (Not that the distinctions are all that clear. Is a smoke alarm a simple device? Maybe, but in our house, sometimes, when we hear a "beep", it takes us *way* too long to determine whether a microwave oven is going off, a pager is going off, a phone is ringing, a security alarm is going off, etc., or any of these things are happening on the TV program played through a fairly decent stereo, before we consider the smoke alarm. The overly-simplifying assumption in all these devices here? "I'm the only one that makes a sound like this, so I'll be instantly recognized." Worked great for car alarms, didn't it? ;-) So, the wise man prefers a language where the programmer gets to say what he *means* (e.g. use Fortran's multi-dimensional arrays) to one where he must say something else entirely (C), just as the wise man prefers open systems, interfaces, environments, and maybe even source code (UNIX, HTML, the Web, and GNU, for respective examples, perhaps) over single-sourced closed ones (Microsoft, Microsoft, Microsoft, and Microsoft, for respective examples, I would think). Similarly, the wise man prefers C for use of pointers to FORTRAN 77. (I've maintained FORTRAN-66 code that does the necessary tricks to provide structures and pointers. What a pain in the butt. C would have been *vastly* more elegant for this application, which happened to be a low-level system utility -- one that copied files and directory, deleted directory trees, and so on, a la UNIX `cp -r' and `rm -r' -- and many of the bugs we ran into came from the fact that we were using an inappropriate language...though there was little choice back in the mid-'70s on these machines, and, thanks to C's *other* unnecessary complexities, these machines were a bear to port C and its existing body of code to in the '80s.) A given person can manage only so much complexity at a time. If he's spending mental energy coping with a missing feature (such as multi-dimensional arrays, or pointers), that's energy not being spent on the *application*, meaning he's probably going to forget something important, or not have time to test some feature, in the application. What I've seen you saying here is "hey, I'm so awesome a programmer, I've been able to write C code that blows away vanilla Fortran code on a particular machine, by using C's low-level facilities to get close to the iron". What I *haven't* seen you say is why you couldn't have done the *same thing* in Fortran 90 (which I'd *love* to know, given my current project affiliations ;-), or whether that time you spent making the C code run faster was really "worth it" compared to what it might have taken to obtain a Fortran 90 compiler that did the same efficient job on your original vanilla code (assuming one was available). What *I* know is that getting a VLIW machine I used to work on to perform optimally on many numerical problems required *either* coding them by hand *or* using a very advanced FORTRAN 77 compiler we were developing at the time. Using C, no matter at how low a level, would *not* have gotten *close* to the performance available to the assembler/Fortran programmer. *Maybe* introducing a bunch of extensions would have allowed us to build a C compiler that did this, but they'd all have required the C programmer to use all sorts of syntactic trickery (`restrict' attributes and such) to get that performance, whereas our Fortran compiler "just worked" given the original, clear, Fortran code, and the effort needed to make the C compiler do the kinds of analyses necessary to meet the Fortran compilers' performance characteristics would have been much larger than we had to spend on the Fortran compiler (when you factor out common, first-time- through-type stuff typical of such projects). (Of course, users of this machine were mostly scientific and numerical types -- they weren't running operating systems, spreadsheets, or word processors on it, more like doing geological exploration, calculating missile trajectories, sampling and encoding real-time seismic data, and so on.) -- "Practice random senselessness and act kind of beautiful." James Craig Burley, Software Craftsperson burley@gnu.ai.mit.edu