Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!samsung!dali.cs.montana.edu!ogicse!ucsd!mvb.saic.com!dayton.saic.com!ake From: ake@dayton.saic.com (Earle Ake) Newsgroups: comp.lang.fortran Subject: Re: why does optimization take so long ? Message-ID: <1991May21.204444.1623@dayton.saic.com> Date: 22 May 91 00:44:44 GMT References: <1236@nikhefh.nikhef.nl> Organization: Science Applications Intl. Corp., Dayton, Ohio Lines: 45 In article <1236@nikhefh.nikhef.nl>, t19@nikhefh.nikhef.nl (Geert J v Oldenborgh) writes: > I am curious whether any of you know why compiling certain routines with a -O > flag takes a semi-infinite amount of time on certain computers (Apollo DN1000, > Sun Fortran 1.3.1) (i.e. I killed compilation after a few hours CPU time for a > single routine). The code in question is generated by a computer algebra > program, and looks like this > > qqgg= n1i*n2i*pbqi*ptqi * ( - 2*pnpe*pbpt**2*qk + 2*pnpe* > + qk*mb2*mt2 + 2*pnpb*pepb*pbpt*qk - 2*pnpb*pepb*qk*mt2 + 2* > + pnpb*pept*pbpt*qk + 4*pnpb*pept*pbpt**2 - pnpb*pept*qk*mb2 - > ...400 similar lines... > > As a lot of the time is spent here I'd like to be able to optimize it. My guess is you are running out of physical memory during the optimization and the thing is paging like crazy. Why not try to optimize it some yourself and give the compiler a break? I see a few things to try. xxxx = pnpe*pbpt xxx0 = pnpb*pepb xxx1 = xxx0*pbpt xxx2 = xxx0*qk xxx3 = pnpb*pept xxx4 = xxx3*pbpt xxx5 = xxx3*qk qqgg= n1i*n2i*pbqi*ptqi * ( - 2*xxxx**2*qk + 2*pnpe* + qk*mb2*mt2 + 2*xxx1*qk - 2*xxx2*mt2 + 2* + xxx4*qk + 4*xxx4**2 - xxx5*mb2 - And so on. Move those parts of the equation that are computed more than once outside the LARGE equation. What you give up is readibility unless you start giving the intermediate variables names like pnpbpept = pnpb*pept or pnpbpeptqk = pnpb*pept*qk. Earle _____________________________________________________________________________ ____ ____ ___ Earle Ake /___ /___/ / / Science Applications International Corporation ____// / / /__ Dayton, Ohio ----------------------------------------------------------------------------- Internet: ake@dayton.saic.com uucp: dayvb!ake SPAN: 28284::ake