home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / arch / 10457 < prev    next >
Encoding:
Text File  |  1992-11-07  |  2.4 KB  |  69 lines

  1. Xref: sparky comp.arch:10457 comp.lang.misc:3524
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!sh.wide!wnoc-tyo-news!cs.titech!titccy.cc.titech!necom830!mohta
  3. From: mohta@necom830.cc.titech.ac.jp (Masataka Ohta)
  4. Newsgroups: comp.arch,comp.lang.misc
  5. Subject: Re: Hardware Support for Numeric Algorithms
  6. Message-ID: <2230@titccy.cc.titech.ac.jp>
  7. Date: 6 Nov 92 12:31:52 GMT
  8. References: <BwIwEB.J1A@mentor.cc.purdue.edu> <BwJ1rB.pz@rice.edu> <1992Oct22.164414.12708@newshost.lanl.gov> <Bx78zu.395@rice.edu> <1992Nov4.183718.5242@newshost.lanl.gov>
  9. Sender: news@titccy.cc.titech.ac.jp
  10. Followup-To: comp.arch
  11. Organization: Tokyo Institute of Technology
  12. Lines: 55
  13.  
  14. In article <1992Nov4.183718.5242@newshost.lanl.gov> jlg@cochiti.lanl.gov (J. Giles) writes:
  15. >In article <Bx78zu.395@rice.edu>, preston@dawn.cs.rice.edu (Preston Briggs) writes:
  16. >|> [...]
  17. >|> Using C as an assembler is doable, in that you can express (almost)
  18. >|> every optimization in the source code.  The result is machine dependent,
  19. >|> ugly, unmaintainable, and I don't recommend it to anyone, but doesn't
  20. >|> really require any additional optimization -- very similar to assembly
  21. >|> language programming.
  22. >
  23. >This is not quite true.
  24.  
  25. Wrong.
  26.  
  27. >The rationale document for ANSI C explicitly
  28. >recognizes the optimization penalty inherent in pointers and suggests
  29. >that remedies to this be a priority in future versions of the standard.
  30. >Yes, if avoid procedure calls (at least, all those whose arguments
  31. >are pointers), 
  32.  
  33. Automatic optimization by compilers have little to do with the above
  34. mentioned *HAND* optimization.
  35.  
  36. You can transform the following program
  37.  
  38.     f(a,b,c)
  39.     double *a,*b,*c;
  40.  
  41.     for(i=0;i<4*N;i++)
  42.     {    a[i]+=b[i]*c[i];
  43.         ...
  44.  
  45. to
  46.  
  47.     for(i=0;i<N;i+=4)
  48.     {    b0=b[i]; b1=b[i+1]; b2=b[i+2]; b3=b[i+3];
  49.         c0=c[i]; c1=c[i+1]; c2=c[i+2]; c3=c[i+3];
  50.         a0=a[i]; a1=a[i+1]; a2=a[i+2]; a3=a[i+3];
  51.         a[i]=a0+b0*c0; ...
  52.  
  53. by hand, knowing that the area for a, b and c does not overlap.
  54.  
  55. > do your own common expression elimination, do your
  56. >own strength reduction, etc. - if you do all those things and many
  57. >more, the optimization penalty from using C *almost* goes away.
  58.  
  59. Actually, as some (or, these days, large) amount of optimization is
  60. performed by compilers, and as many machines share similar machine
  61. dependent behaviour, the C version is not so machine dependent, ugly
  62. nor unmaintainable.
  63.  
  64. >It's easier to use assembly directly.
  65.  
  66. Thus, it is easier to use C.
  67.  
  68.                         Masataka Ohta
  69.