home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.arch:10457 comp.lang.misc:3524
- 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
- From: mohta@necom830.cc.titech.ac.jp (Masataka Ohta)
- Newsgroups: comp.arch,comp.lang.misc
- Subject: Re: Hardware Support for Numeric Algorithms
- Message-ID: <2230@titccy.cc.titech.ac.jp>
- Date: 6 Nov 92 12:31:52 GMT
- 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>
- Sender: news@titccy.cc.titech.ac.jp
- Followup-To: comp.arch
- Organization: Tokyo Institute of Technology
- Lines: 55
-
- In article <1992Nov4.183718.5242@newshost.lanl.gov> jlg@cochiti.lanl.gov (J. Giles) writes:
- >In article <Bx78zu.395@rice.edu>, preston@dawn.cs.rice.edu (Preston Briggs) writes:
- >|> [...]
- >|> Using C as an assembler is doable, in that you can express (almost)
- >|> every optimization in the source code. The result is machine dependent,
- >|> ugly, unmaintainable, and I don't recommend it to anyone, but doesn't
- >|> really require any additional optimization -- very similar to assembly
- >|> language programming.
- >
- >This is not quite true.
-
- Wrong.
-
- >The rationale document for ANSI C explicitly
- >recognizes the optimization penalty inherent in pointers and suggests
- >that remedies to this be a priority in future versions of the standard.
- >Yes, if avoid procedure calls (at least, all those whose arguments
- >are pointers),
-
- Automatic optimization by compilers have little to do with the above
- mentioned *HAND* optimization.
-
- You can transform the following program
-
- f(a,b,c)
- double *a,*b,*c;
-
- for(i=0;i<4*N;i++)
- { a[i]+=b[i]*c[i];
- ...
-
- to
-
- for(i=0;i<N;i+=4)
- { b0=b[i]; b1=b[i+1]; b2=b[i+2]; b3=b[i+3];
- c0=c[i]; c1=c[i+1]; c2=c[i+2]; c3=c[i+3];
- a0=a[i]; a1=a[i+1]; a2=a[i+2]; a3=a[i+3];
- a[i]=a0+b0*c0; ...
-
- by hand, knowing that the area for a, b and c does not overlap.
-
- > do your own common expression elimination, do your
- >own strength reduction, etc. - if you do all those things and many
- >more, the optimization penalty from using C *almost* goes away.
-
- Actually, as some (or, these days, large) amount of optimization is
- performed by compilers, and as many machines share similar machine
- dependent behaviour, the C version is not so machine dependent, ugly
- nor unmaintainable.
-
- >It's easier to use assembly directly.
-
- Thus, it is easier to use C.
-
- Masataka Ohta
-