amos@taux02.UUCP (Amos Shapir) (11/28/88)
In article <28200245@mcdurb> aglew@mcdurb.Urbana.Gould.COM writes: >I am excited because a friend was parallelizing the previously >best known algorithm (...) and he was obtaining impressive >speedups (it's amazing what a difference a professional programmer >can make). Having seen some programs written by scientists, I am not at all amazed. Most of what a professional programmer does when helping scientists, is to change things like cos(atan(x))**2 to 1/(1+x*x) . The hardest part is convincing the scientists that it does make a difference. -- Amos Shapir amos@nsc.com National Semiconductor (Israel) P.O.B. 3007, Herzlia 46104, Israel Tel. +972 52 522261 TWX: 33691, fax: +972-52-558322 34 48 E / 32 10 N (My other cpu is a NS32532)
ken@argus.UUCP (Kenneth Ng) (11/29/88)
In article <321@taux02.UUCP>, amos@taux02.UUCP (Amos Shapir) writes: : In article <28200245@mcdurb> aglew@mcdurb.Urbana.Gould.COM writes: : >I am excited because a friend was parallelizing the previously : >best known algorithm (...) and he was obtaining impressive : >speedups : is to change things like cos(atan(x))**2 to 1/(1+x*x) . : The hardest part is convincing the scientists that it does make a difference. Or in my case, convincing someone that taking the absolute value of a squared simple (as opposed to complex) number really makes no sense. : Amos Shapir amos@nsc.com : National Semiconductor (Israel) P.O.B. 3007, Herzlia 46104, Israel Kenneth Ng: Post office: NJIT - CCCC, Newark New Jersey 07102 uucp rutgers!galaxy!argus!ken bitnet(prefered) ken@orion.bitnet -- Kenneth Ng: Post office: NJIT - CCCC, Newark New Jersey 07102 uucp !ihnp4!allegra!bellcore!argus!ken *** NOT ken@bellcore.uucp *** bitnet(prefered) ken@orion.bitnet
davidsen@steinmetz.ge.com (William E. Davidsen Jr) (11/29/88)
In article <321@taux02.UUCP> amos@taux02.UUCP (Amos Shapir) writes: | Having seen some programs written by scientists, I am not at all amazed. | Most of what a professional programmer does when helping scientists, | is to change things like cos(atan(x))**2 to 1/(1+x*x) . You mean your optimizing compiler doesn't even do THAT??? In many cases a compiler will do a better job of handling global optimization, code movement, and common subexpressions than a human. Humans excel in recognizing special cases in a small section of code (at least the good ones do). I have seen The VMS C compiler push a value about 100 instructions before it was popped, and avoid a division. A human would probably never find that code, if only because the flow analysis is very tedious to insure that the value is always popped. I have seen output from research projects which recognize sequences of code in separate procedures and generate internal calls to the common code from several places, with values in registers. Obviously this is a savings in space rather than time (calls take time) but it is impressive in terms of recognizing program patterns. -- bill davidsen (wedu@ge-crd.arpa) {uunet | philabs}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me
barmar@think.COM (Barry Margolin) (12/01/88)
In article <321@taux02.UUCP> amos@taux02.UUCP (Amos Shapir) writes: >Most of what a professional programmer does when helping scientists, >is to change things like cos(atan(x))**2 to 1/(1+x*x) . What does this have to do with being a professional PROGRAMMER? The above identity is a MATHEMATICAL fact, having nothing to do with computers, except insofar as the above statements in a program approximate the corresponding mathematical operations. I would expect the above knowledge to be in a mathematician's (and perhaps even a scientist's) bag of tricks, but not necessarily a programmer's. Maybe a programmer who specializes in scientific or mathematical programming (I'm primarily a systems programmer, so I rarely use trig functions) should also know them, but I'm not sure that I would fault one for not knowing them. It would be nice if compiler optimizer writers could put these in; however, it is frequently difficult to recognize the constructs (what if the expression were split across several statements, using a temporary variable), and it's not obvious that they would come up frequently enough to justify the work of putting such optimizations in. Barry Margolin Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar
amos@taux02.UUCP (Amos Shapir) (12/03/88)
In article <32353@think.UUCP> you write: >In article <321@taux02.UUCP> amos@taux02.UUCP (Amos Shapir) writes: >>Most of what a professional programmer does when helping scientists, >>is to change things like cos(atan(x))**2 to 1/(1+x*x) . > >What does this have to do with being a professional PROGRAMMER? The >above identity is a MATHEMATICAL fact, having nothing to do with >computers, except insofar as the above statements in a program >approximate the corresponding mathematical operations. This is exactly the point I was trying to make - to a mathematician, these two expressions are identical and interchangeable; to a programmer, one is an expression requiring two function calls (twice if your compiler is lousy) involving hundreds of operations, while the other requires just one multiply and one divide. It's the programmer's job to know these facts and use them. -- Amos Shapir amos@nsc.com National Semiconductor (Israel) P.O.B. 3007, Herzlia 46104, Israel Tel. +972 52 522261 TWX: 33691, fax: +972-52-558322 34 48 E / 32 10 N (My other cpu is a NS32532)
ncsmith@ndsuvax.UUCP (Timothy Smith) (12/21/88)
[ stuff about converting cos(atan(x)) to 1/(1+x*x) and why this has not much to do with programmers as opposed to mathematicians ] > >This is exactly the point I was trying to make - to a mathematician, >these two expressions are identical and interchangeable; to a programmer, >one is an expression requiring two function calls (twice if your compiler >is lousy) involving hundreds of operations, while the other requires just >one multiply and one divide. It's the programmer's job to know these >facts and use them. >-- > Amos Shapir amos@nsc.com I have to disagree with your last sentence. If you extend this to every area in which a programmer may be doing work, ie. accountting, taxes, etc. then the programmer has to know about every trick in that area so s/he can always optimze the programs s/he writes. A little further extension would be to remove the programmer from the picture entirely and teach the specialist how to program the computer. In my own opinion I think that the programmer should examine what the specialist wants done, find areas that look like canidates for optimization, and then ask the specialist if it is possible to do a different set of operations that could be faster. This lets the specialist concetrate on his/her own area and the programmer concentrate on the program. -- Tim Smith North Dakota State University, Fargo, ND 58105 UUCP: ...!uunet!ndsuvax!ncsmith | 90% of the people on this planet BITNET: ncsmith@ndsuvax.bitnet | are crazy and the rest of us are INTERNET: ncsmith@plains.NoDak.edu | in grave danger of contamination
adamsf@rpics (Frank Adams) (12/24/88)
(I am directing follow-ups to comp.software-eng; this has nothing to do with architecture any more.) In article <1992@ndsuvax.UUCP> ncsmith@ndsuvax.UUCP (Timothy Smith) writes: > I have to disagree with your last sentence. If you extend this to >every area in which a programmer may be doing work, ... then the programmer >has to know about every trick in that area ... I think that the >programmer should examine what the specialist wants done, find areas that >look like canidates for optimization, and then ask the specialist ... I disagree strongly. A professional writing programs in any subject area has a responsibility to be become, if not expert, at least reasonably well informed about that subject. This is what employers should be looking for when hiring programmers, not familiarity with language X. (Although the latter can sometimes substitute for the former -- it is a safe bet that someone who knows MUMPS will know something about medical practice.) Frank Adams adamsf@cs.rpi.edu
andrew@frip.gwd.tek.com (Andrew Klossner) (12/24/88)
>> [ stuff about converting cos(atan(x)) to 1/(1+x*x) and why this has >> not much to do with programmers as opposed to mathematicians ] > This is exactly the point I was trying to make - to a mathematician, > these two expressions are identical and interchangeable ... To an experienced programmer, these expressions are not interchangeable; the first implies a runtime range check on the value of x. -=- Andrew Klossner (uunet!tektronix!hammer!frip!andrew) [UUCP] (andrew%frip.gwd.tek.com@relay.cs.net) [ARPA]
rik@june.cs.washington.edu (Rik Littlefield) (12/25/88)
In article <10790@tekecs.TEK.COM>, andrew@frip.gwd.tek.com (Andrew Klossner) writes: > >> [ stuff about converting cos(atan(x)) to 1/(1+x*x) and why this has > >> not much to do with programmers as opposed to mathematicians ] > > > This is exactly the point I was trying to make - to a mathematician, > > these two expressions are identical and interchangeable ... > > To an experienced programmer, these expressions are not > interchangeable; the first implies a runtime range check on the value > of x. I cannot resist asking. Since the domain of atan includes all real numbers, and the range of atan is surely within the domain of cos, what exactly will the runtime range check be doing? :-) Merry Christmas, all! --Rik