home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / fortran / 3242 < prev    next >
Encoding:
Internet Message Format  |  1992-08-27  |  2.2 KB

  1. Path: sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!pacbell.com!network.ucsd.edu!lyapunov.ucsd.edu!mbk
  2. From: mbk@lyapunov.ucsd.edu (Matt Kennel)
  3. Newsgroups: comp.lang.fortran
  4. Subject: Re: Small Language Wanted
  5. Date: 27 Aug 1992 23:00:31 GMT
  6. Organization: Institute For Nonlinear Science, UCSD
  7. Lines: 55
  8. Message-ID: <17jmqfINNmrc@network.ucsd.edu>
  9. References: <9224107.5975@mulga.cs.mu.OZ.AU>
  10. NNTP-Posting-Host: lyapunov.ucsd.edu
  11. X-Newsreader: Tin 1.1 PL3
  12.  
  13. fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
  14. : No, in principle if the library function in question is a *standard*
  15. : library function, then its implementation is just a part of the
  16. : compilation system. When the compiler sees #include <math.h>, it can
  17. :     - read /usr/include/math.h
  18. :     - read foobar.xyzzy
  19. :     - insert the appropriate declarations without reading any file.
  20. : Furthermore, when it sees
  21. :     pow(a,i)
  22. : in your code, and "i" happens to be an integer then it can emit code to
  23. :     - call the standard pow() function after convertin
  24. :       i to a double
  25. :     - call a special function the calculates doubles to
  26. :       integer powers
  27. :     - calculate the exponentiation using inline code.
  28.  
  29. Suppose in foo.c I do the above.  Then in pow.c I have my own
  30. new defintion of "pow" which does something different.
  31.  
  32. How does C know when compiling foo.c the difference :
  33.  
  34. cc -c foo.c
  35. cc -o foo foo.o -lm
  36.  
  37. vs.
  38.  
  39. cc -c foo.c
  40. cc -c pow.c
  41. cc -o foo foo.o pow.o -lm
  42.  
  43. ???
  44.  
  45. Or is this a resolved problem?
  46.  
  47. Question:  Do you know which real live C compilers that people can buy or
  48. steal which do in fact perform the optimizations that we're talking about?
  49.  
  50. Say, perhaps, computing pow(x,4) with *TWO* FP multiplications.
  51.  
  52. I suspect the percentage is about 85% for Fortran, and maybe 10% for C,
  53. but I really have no idea.
  54.  
  55. : Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
  56. : This .signature virus is a self-referential statement that is true - but 
  57. : you will only be able to consistently believe it if you copy it to your own
  58. : .signature file!
  59.  
  60. --
  61. -Matt Kennel          mbk@inls1.ucsd.edu
  62. -Institute for Nonlinear Science, University of California, San Diego
  63. -*** AD: Archive for nonlinear dynamics papers & programs: FTP to
  64. -***     lyapunov.ucsd.edu, username "anonymous".
  65.