Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!bu.edu!inmet!mazur From: mazur@inmet.inmet.com Newsgroups: comp.lang.c Subject: Re: Execution time bottleneck: How Message-ID: <20900015@inmet> Date: 15 Feb 91 19:51:00 GMT References: <233522@<1991Feb12> Lines: 23 Nf-ID: #R:<1991Feb12:233522:inmet:20900015:000:920 Nf-From: inmet.inmet.com!mazur Feb 15 14:51:00 1991 In article <21658@yunexus.YorkU.CA> racine@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@inmet.inmet.com -..!uunet!inmet!mazur