Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Speed Of Program Running

Status
Not open for further replies.

Muzzy

Programmer
Dec 14, 2001
68
GB
Hi,

I'm using Plato Fortran 95 and when I run my programs they take forever(At least a day). My machine is a decent spec so I don't know what the problem is. Is there anyway to speed up program run time?

Cheers

Muzzy
 
What exactly does your program do?

There are lots of optimizations but it really depends on the algorithm eg a Fourier Transform will be slow but code it as an FFT and it will be fast. Options are numerous. Of course, if you are using the best algorithm there is or trying to formulate one then there are a few things like

1) loop jamming
Code:
do i=1,10
    x(i) = y(i)
enddo

runs slower than

do i = 1, 10, 2
    x(i) = y(i)
    x(i+1) = y(i+1)
enddo
2) Doing all conversions first so that you have as few conversions as possible
3) Possibly using fixed arrays instead of dynamic ones
4) Using a lookup table instead of computing sin/cos/tan/atn values - this is how we reduced the reconstruction time for a body scanner (in the early 80s) from 1 week to 20 minutes.
 
My program in f95 (broadly) calculates the optimal reward and a policy reward
from a discounted branching bandit system with two classes of customer and two
potentially available machines. I am using a value iteration to evaluate the
dynamic program and the discounted nature of the problem is one point which
prolongs matters since i am concerned with exponential discounting (e^-alpha)
for v small alpha therefore requiring 'many' iterations before convergence.

A further problem is the truncation of the system. I have to truncate far
enough out to ensure accurate results but for small alpha this can mean a
maximum number of each class of customer being around 500. Within each
iteration I have to calculate the reward for every possible state (therefore
500*500) resulting in a subroutine of the form (very roughly)

do 1,# required for convergence
do 1,500
do 1,500
calculate reward for this state
end do
end do
end do

clearly there is more to the program but this appears to be the bit that takes
the time.

The reward calculation part is also fairly involved since it involves other
states in the system due to the dynamic program.

I have tried to think of ways to speed this up since my theoretical results
are based on reward sub-optimalities for alpha tending to zero.

I also get a stack error if i try to make my array larger than 800*800.


Any Ideas? Cheers.
 
That is a lot of iterations. Do you have many dynamic allocations and deallocations? If you do, could you make them static allocations and don't bother with the deallocation. That may fix your stack problem. Alternatively, move them into a common block which is more or less global memory.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top