Execution time bottleneck: How
mazur at inmet.inmet.com
mazur at inmet.inmet.com
Sat Feb 16 06:51:00 AEST 1991
In article <21658 at yunexus.YorkU.CA> racine at yunexus.yorku.ca (Jeff Racine) writes:
> for (j=1; j <= n; j++) {
> sum = 0.0;
> for (i=1; i<= n; i++) {
> sum += exp( con * (x[i]-x[j]) * (x[i]-x[j]) );
> }
> a[j] = k*sum;
> }
>This part of the algorithmn is a bottleneck. I want to make this as
>quick as possible. What are my options? I have heard that assembler
>would be faster. How much faster would assembler be? Would it be worth
>the effort? Are there other alternatives that you can see?
I missed the original article, so I'm not sure what you are compiling this
code with, but rewriting the loop so that you decrement from (n-1) to 0
may reduce the number of instructions necessary to do the comparison (i.e.,
you may be able to do a "tst; beq" instead of "ld i, tst, beq"). Small
savings, but they add up.
Beth Mazur
mazur at inmet.inmet.com
-..!uunet!inmet!mazur
More information about the Comp.lang.c
mailing list