- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What is the best way to optimise loops like the following, which are from Steam and Water property calculations:
DUMMY=0 DO i = 1,34 DUMMY = DUMMY - nreg1(i) * ireg1(i) * (7.1D0 - pi) ** (ireg1(i) - 1) * & (tau - 1.222D0) ** jreg1(i) END DO gammapireg1 = DUMMY
ireg1 has values from 0 to 32 and jreg1 from 17 to -41
ireg1 and jreg1 are INTEGER PARAMETER arrays, and nreg1 is a REAL*8 PARAMETER array
Is it more efficient to calculate all the elements of the array result and sum at the end?
Thanks,
David
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I expect ifort would split the loop automatically in cases where there is any chance of improved performance by summing separately. To prevent this (unlikely in your case), insert "!dir$ distribute point" after the DO.
As the individual exponents are compile time constants, you might try to unroll the loop entirely so that optimizations might be engaged based on expanding e.g. x**i => x*x**(i-1). An unroll directive e.g. !dir$ unroll(8) preceding DO might have useful effect even if it doesn't accomplish that.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page