Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!caen!math.lsa.umich.edu!sharkey!amara!mcdaniel From: mcdaniel@adi.com (Tim McDaniel) Newsgroups: comp.lang.c Subject: Re: Execution time bottleneck: How to speed up execution? Message-ID: Date: 12 Feb 91 22:57:59 GMT References: <21658@yunexus.YorkU.CA> Sender: news@adi.COM Followup-To: comp.lang.c Organization: Applied Dynamics International, Inc.; Ann Arbor, Michigan, USA Lines: 39 In-reply-to: racine@yunexus.yorku.ca's message of 11 Feb 91 15:17:37 GMT racine@yunexus.yorku.ca (Jeff Racine) asks about sum += exp( con * (x[i]-x[j]) * (x[i]-x[j]) ); in a pair of nested loops. This part of the algorithm is a bottleneck. Hallelujah, I just got religion. This is the *first* optimization article I remember in comp.lang.c where the author knew that the code fragment was a bottleneck! (If it's not a bottleneck, it doesn't really *matter* what you do; don't put the effort into optimizing if you're not sure.) 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? Jeff, if we were telepaths, we wouldn't need netnews. 8-) Environment: What hardware are you on? What O. S.? What C compiler? What assembler? What other code is around this fragment? Data: What's the typical value of N? Anything special about X[] (integer or other known GCD, triangular)? Anyhting special about CON? Effort: Will this program be run often? Is N large? In short, is the execution time large, and does it matter if it is? (I presume "yes" throughout.) Is the program going to massage the same data on many runs (i.e. would precomputation help)? I doubt that assembler would help very much on common systems, though that's only an ignorant guess. -- "I'd hang you from my nipples ... but it would shock the children." Tim McDaniel Applied Dynamics Int'l.; Ann Arbor, Michigan, USA Internet: mcdaniel@adi.com UUCP: {uunet,sharkey}!amara!mcdaniel