Re: Automatically transform or expand do loop in a subroutine



Richard Maine wrote:
highegg <highegg@xxxxxxxxx> wrote:

On Jan 31, 7:06 am, nos...@xxxxxxxxxxxxx (Richard Maine) wrote:
yaqi <yaqiw...@xxxxxxxxx> wrote:
I want to save computing time as much as I can.
...

do i=1,d
c = c + i
end do
The "obvious" way to save a lot of computing time here is to replace the
loop with

c = c + d*i

certainly not. c = c + d*(d+1)/2, more likely :)

Um. Er. Right.

c = c + ishft(d*(d+l),-1) will be faster, with most compilers, in the
case l >= 0. Even in analogous cases, where there is information
implying that the expression need be valid only for positive operands,
compilers don't take advantage of it.
Perhaps i and l aren't good choices for newsgroup posts. It was
difficult enough to remove obvious mistakes from my response.
.



Relevant Pages

  • Re: Do you think NI can fix my PLL? -- Details
    ... One also usually expects that the VCO response, ie., the frequency response of the phase, is not burdened by zeros/poles close to the desired PLL BW, so one can treat it simply as Kvco/s. ... Basically, there needs to be some plan for elucidating if what I have at present is just a mediocre motor characterization, poor choice of loop compensation, or trouble with the slight nonlinearities of the drive. ... If you're not getting any significant jitter at all then you should be able to make a really slow loop and be done with it. ...
    (sci.electronics.design)
  • Re: Cuk converter bizzare control loop
    ... >>Would like to hear a comment on the control loop from someone who has ... I used a convertor with the same response to convey signals at ... frequencies approaching a small submultiple of the switching ... It is the same problem with respect to balancing the bike. ...
    (sci.electronics.design)
  • Re: allowing braces around suites
    ... Well people do make mistakes and it would be helpfull if the language ... came after a loop became indented at the same level as the loop. ... endmarkers helps readability as much as indenting code does ... one could consider the case for endmarkers. ...
    (comp.lang.python)
  • Re: Slowing down an array / batch
    ... then getting a response and storing the response in a ... through this loop but more than the remote server can handle if I just ... My main problam is that the remote server will only allow 250 requests ... I've pasted my loop example below, but I need advice on how to either ...
    (comp.lang.php)
  • Re: Calling a subroutine causes serialization of threads?
    ... I didn't expect to get any response so quickly ... "It would be interesting to change the loop count to see if you can ... Or profile the code using a high resolution ... timer or a hardware performance counter to see ...
    (comp.programming.threads)