CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Speeding my Fortran Code

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 30, 2005, 05:48
Default Speeding my Fortran Code
  #1
S
Guest
 
Posts: n/a
I have a fortran serial code in fortran 90 and ifc compiler with red hat linux 9. I would like to speed my fortran code. How can I do so? S
  Reply With Quote

Old   March 30, 2005, 06:38
Default Re: Speeding my Fortran Code
  #2
autofly
Guest
 
Posts: n/a
use hugh level optimize it when you compile the code for example , f77 -O4 test.f -o test
  Reply With Quote

Old   March 30, 2005, 06:55
Default Re: Speeding my Fortran Code
  #3
S
Guest
 
Posts: n/a
How much faster did you get when you use this optimization S
  Reply With Quote

Old   March 30, 2005, 08:58
Default Re: Speeding my Fortran Code
  #4
scar
Guest
 
Posts: n/a
Before to applied any special flag in the compiler, you should check if your code was written properly, considering

loop unrolling use a correct memory pattern fusion loop correct use of cache piping ...

A good reference is the book "High Performance Computing" Dowd, K. O'Reilly

Afterward, you can improve the performance using the flags.

  Reply With Quote

Old   March 30, 2005, 12:31
Default Re: Speeding my Fortran Code
  #5
giorgio
Guest
 
Posts: n/a
You can also profile your code using the appropriate flags (-pg or -p). In this way you'll have a report of the most time-consuming routines to optimize (man gprof or man prof to know more)

Good luck, Giorgio
  Reply With Quote

Old   March 31, 2005, 01:52
Default Re: Speeding my Fortran Code
  #6
Xiong Yan
Guest
 
Posts: n/a
Optimize you source code and choose a proper compile flag (e.g. pgf90 -fastsse will do great in speed campared with "without -fastsse" when the program running on SSE instruction supported cpu)
  Reply With Quote

Old   March 31, 2005, 03:21
Default Re: Speeding my Fortran Code
  #7
S
Guest
 
Posts: n/a
I told you I have ifc compiler and I tested all level of optimzation the code without optimzations runs faster S
  Reply With Quote

Old   March 31, 2005, 03:53
Default Re: Speeding my Fortran Code
  #8
Xiong Yan
Guest
 
Posts: n/a
I just want to give u some personal advice. Now that u have tested all level of optimization the code. What answer do u want? Revise ur code or change another compiler maybe work.
  Reply With Quote

Old   March 31, 2005, 05:10
Default Re: Speeding my Fortran Code
  #9
andy
Guest
 
Posts: n/a
It is the modern practise that if you omit the optimisation flag the compiler defaults to quite a high level of optimisation. To see the performance without optimisation you probably need to pass a "no optimisation" flag.

It is also quite normal for the highest levels of optimisation to take ages to compile, produce large object code and run slower.

If you want to see effective combinations of optimisation flags for the Intel compiler look at the flags used to get the published SPEC figures on www.spec.org.

If you are passing around dynamic arrays in Fortran 95 rather than using simple Fortran 77 arrays this can impact performance. There have been articles discussing how to avoid tripping yourself up (I recall one by NAG) but I cannot find any at the moment. You will have to google for one.

I have also noticed that current Fortran optimizers on PCs are often not as effective as main frame optimizers from 20 years ago. Attention to stride length, loop ordering, using 1D rather than 3D arrays seem to have a bigger effect than they should since a Fortran optimizer (unlike a C/C++ optimizer) should be able to perform most of this.
  Reply With Quote

Old   March 31, 2005, 07:11
Default Re: Speeding my Fortran Code
  #10
Salvador
Guest
 
Posts: n/a
ifc -O3 -tpp7 the last one depending on the processor you use (P4 in this case), nothing faster so do it and forget it. Do not expect miracles only slight iprovements. ifc takes -O2 by default so even -O3 will not do much. If you are using dynamic arrays the effects maybe larger. Try running -pg and using gprof to see which subroutines take the most time and then re-think them, you will (surely) probably speed up the code much more in that way. Beware of exponential and powers, they can take a lot of time (use x*x istead of x**2). Specially if you are doing expansion series and using a lot of terms a lot of times (yp will see it in gprof) Minimize writing to files, 1D arrays instead of 3D, usual staff ... If you do not have memory costraint try to to precompute everything you can and store it before the big loops. The same apply to clusters, try reduce comunication between procs, barriers..

  Reply With Quote

Old   March 31, 2005, 08:08
Default Re: Speeding my Fortran Code
  #11
Tom
Guest
 
Posts: n/a
You probably need to use the -vec_report5 flag when you compile (I use "-xW -O3" or "-xN -O3") to see why your code is not vectorizing. You also need to ensure that you have not set any debug options since these will override any optimization (i.e. you don't want "-g" or "-check bounds" or anything similar on the compile line).

It's possible that you may need to restructure some do loops in order to help the vectorizer optimize your code. Read the optimization documentation that comes with the compiler.
  Reply With Quote

Old   March 31, 2005, 15:50
Default Re: Speeding my Fortran Code
  #12
Márcio Ricardo
Guest
 
Posts: n/a
If you're running your programs on a Pentium, you could use the Intel mkl math library. It is freely avaiable for download, like the compiler, and it's designed to work optimally with ifc and PIV.
  Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Discontinuous Galerkin schemes -- fortran source code diedro Main CFD Forum 3 March 12, 2011 11:20
fortran code HaKu Main CFD Forum 1 February 17, 2010 10:57
3D fortran Navier-Stokes code emrah Main CFD Forum 4 December 15, 2007 10:53
Design Integration with CFD? John C. Chien Main CFD Forum 19 May 17, 2001 16:56
Multi-dimensional heat conduction fortran code odat Main CFD Forum 1 August 6, 1999 01:18


All times are GMT -4. The time now is 02:11.