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

  1. Newsgroups: comp.arch
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!caen!hellgate.utah.edu!lanl!cochiti.lanl.gov!jlg
  3. From: jlg@cochiti.lanl.gov (J. Giles)
  4. Subject: Re: Hardware Support for Numeric Algorithms
  5. Message-ID: <1992Nov6.181826.29015@newshost.lanl.gov>
  6. Sender: news@newshost.lanl.gov
  7. Organization: Los Alamos National Laboratory
  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> <2230@titccy.cc.titech.ac.jp>
  9. Date: Fri, 6 Nov 1992 18:18:26 GMT
  10. Lines: 57
  11.  
  12. In article <2230@titccy.cc.titech.ac.jp>, mohta@necom830.cc.titech.ac.jp (Masataka Ohta) writes:
  13. |> In article <1992Nov4.183718.5242@newshost.lanl.gov> jlg@cochiti.lanl.gov (J. Giles) writes:
  14. |> [...]
  15. |> >The rationale document for ANSI C explicitly
  16. |> >recognizes the optimization penalty inherent in pointers and suggests
  17. |> >that remedies to this be a priority in future versions of the standard.
  18. |> >Yes, if avoid procedure calls (at least, all those whose arguments
  19. |> >are pointers), 
  20. |> 
  21. |> Automatic optimization by compilers have little to do with the above
  22. |> mentioned *HAND* optimization.
  23. |> 
  24. |> You can transform the following program
  25. |> 
  26. |>     f(a,b,c)
  27. |>     double *a,*b,*c;
  28. |> 
  29. |>     for(i=0;i<4*N;i++)
  30. |>     {    a[i]+=b[i]*c[i];
  31. |>         ...
  32. |> 
  33. |> to
  34. |> 
  35. |>     for(i=0;i<N;i+=4)
  36. |>     {    b0=b[i]; b1=b[i+1]; b2=b[i+2]; b3=b[i+3];
  37. |>         c0=c[i]; c1=c[i+1]; c2=c[i+2]; c3=c[i+3];
  38. |>         a0=a[i]; a1=a[i+1]; a2=a[i+2]; a3=a[i+3];
  39. |>         a[i]=a0+b0*c0; ...
  40. |> 
  41. |> by hand, knowing that the area for a, b and c does not overlap.
  42.  
  43. And the code still does not parallelize.  Why?  An ANSI C implementation
  44. must *infer* which things can be parallel and which can't because the
  45. C language doesn't have explicit vector constructs.  There is *NO*
  46. *HAND* optimization of the above code which will remendy this - without
  47. using some non-standard extension for explicitly declaring whether
  48. the variables are aliased or not.
  49.  
  50. Yes, if you have a primitive, non-pipelined, non-vector, non-parallel,
  51. purely scalar machine, then perhaps careful hand coding can produce
  52. as good a result with C as with assembly.  If you have such a machine,
  53. you obviously don't think speed is worth paying for in hardware - why
  54. do you think spending *more* money for programmer time to hand optimize
  55. is a better investment?    
  56.  
  57. |> [...]
  58. |> >It's easier to use assembly directly.
  59. |> 
  60. |> Thus, it is easier to use C.
  61.  
  62. Most assembly languages have more legible *syntax* than C, their
  63. semantics are usually cleaner and more well-defined, and they 
  64. provide direct control, rather than indirect reliance on the 
  65. inference capabilities of the compiler.
  66.  
  67. -- 
  68. J. Giles
  69.