some flags for optimization?? ( run with higher speed)??

This is a discussion on some flags for optimization?? ( run with higher speed)?? within the Fortran forums in Programming Languages category; Dear all ; I've written a code in fortran90. Since my sample is large, my code runs slowly. I need some flags in order to enter them to Makefile which can be able to run the code with higher speed. ----------------------------------------------------------------- this is my Makefile: ---------------------------------- FC=ifort NROBJS=nr.o nrtype.o parametros.o MYOBJS= wfinside.o gauntutils.o leedutils.o MYSUBFUN=DoubleFactorialDP.o FactorialDP.o Gaunt.o Legendre.o SphericalHarmonicYZ.o SqrtFactorialDP.o ThreeJSymbol.o factorial.f90 bessel.o writefile.o intgral.o ComlexUnit.o ..SUFFIXES: ..SUFFIXES: .f90 .o all: $(NROBJS) $(MYOBJS) $(MYSUBFUN) main-goodformat2.o $(FC) $(NROBJS) $(MYOBJS) $(MYSUBFUN) main-goodformat2.o -o wannier.exe ..f90.o: $(FC) -c $< nr.o: nr.f90 nrtype.o nrtype.o: nrtype.f90 parametros.o: parametros.f90 DoubleFactorialDP.o: DoubleFactorialDP.f90 FactorialDP.o: FactorialDP.f90 gauntutils.o: gauntutils.f90 Gaunt.o: ...

Go Back   Application Development Forum > Programming Languages > Fortran

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-08-2008, 03:29 AM
Fatemeh
Guest
 
Default some flags for optimization?? ( run with higher speed)??

Dear all ;

I've written a code in fortran90. Since my sample is large, my code
runs slowly.
I need some flags in order to enter them to Makefile which can be able
to run the code with higher speed.
-----------------------------------------------------------------
this is my Makefile:
----------------------------------
FC=ifort
NROBJS=nr.o nrtype.o parametros.o
MYOBJS= wfinside.o gauntutils.o leedutils.o
MYSUBFUN=DoubleFactorialDP.o FactorialDP.o Gaunt.o Legendre.o
SphericalHarmonicYZ.o SqrtFactorialDP.o ThreeJSymbol.o factorial.f90
bessel.o writefile.o intgral.o ComlexUnit.o
..SUFFIXES:
..SUFFIXES: .f90 .o

all: $(NROBJS) $(MYOBJS) $(MYSUBFUN) main-goodformat2.o
$(FC) $(NROBJS) $(MYOBJS) $(MYSUBFUN) main-goodformat2.o -o
wannier.exe

..f90.o:
$(FC) -c $<

nr.o: nr.f90 nrtype.o
nrtype.o: nrtype.f90


parametros.o: parametros.f90
DoubleFactorialDP.o: DoubleFactorialDP.f90
FactorialDP.o: FactorialDP.f90
gauntutils.o: gauntutils.f90
Gaunt.o: Gaunt.f90
leedutils.o: leedutils.f90
Legendre.o: Legendre.f90
SphericalHarmonicYZ.o: SphericalHarmonicYZ.f90
SqrtFactorialDP.o: SqrtFactorialDP.f90
ThreeJSymbol.o: ThreeJSymbol.f90
factorial.o: factorial.f90
bessel.o: bessel.f90
writefile.o: writefile.f90
intgral.o: intgral.f90
ComlexUnit.o: ComlexUnit.f90
wfinside.o: wfinside.f90
main-goodformat.o: main-goodformat2.f90 $(NROBJS) $(MYOBJS) $
(MYSUBFUN)
-----------------------------------------------------
Would you please guide me if there is any flag for this purpose?
(I cannot write my code in Parallel. so I should find some flags!!!)
I'm anxiously looking forward your reply and guidelines.

With my best regards,
Fatemeh
Reply With Quote
  #2  
Old 09-08-2008, 04:02 AM
Dr Ivan D. Reid
Guest
 
Default Re: some flags for optimization?? ( run with higher speed)??

On Mon, 8 Sep 2008 00:29:40 -0700 (PDT), Fatemeh <fateme.mirjani@gmail.com>
wrote in <23de88ca-360d-44d2-b1f2-da24b92166bf@z66g2000hsc.googlegroups.com>:

> I've written a code in fortran90. Since my sample is large, my code
> runs slowly.
> I need some flags in order to enter them to Makefile which can be able
> to run the code with higher speed.
> -----------------------------------------------------------------
> this is my Makefile:
> ----------------------------------
> FC=ifort
> NROBJS=nr.o nrtype.o parametros.o
> MYOBJS= wfinside.o gauntutils.o leedutils.o
> MYSUBFUN=DoubleFactorialDP.o FactorialDP.o Gaunt.o Legendre.o
> SphericalHarmonicYZ.o SqrtFactorialDP.o ThreeJSymbol.o factorial.f90
> bessel.o writefile.o intgral.o ComlexUnit.o
> .SUFFIXES:
> .SUFFIXES: .f90 .o
>
> all: $(NROBJS) $(MYOBJS) $(MYSUBFUN) main-goodformat2.o
> $(FC) $(NROBJS) $(MYOBJS) $(MYSUBFUN) main-goodformat2.o -o
> wannier.exe
>
> .f90.o:
> $(FC) -c $<
>
> nr.o: nr.f90 nrtype.o
> nrtype.o: nrtype.f90

....

> Would you please guide me if there is any flag for this purpose?
> (I cannot write my code in Parallel. so I should find some flags!!!)
> I'm anxiously looking forward your reply and guidelines.


You don't appear to be using any optimisation. Try adding -O3 to
your .f90.o: line. Type in 'ifort --help' to get a listing of some flags you
can try. There's also a chance you can get better interprocedural optimisation
by combining some of your source files together.

--
Ivan Reid, School of Engineering & Design, _____________ CMS Collaboration,
Brunel University. Ivan.Reid@[brunel.ac.uk|cern.ch] Room 40-1-B12, CERN
KotPT -- "for stupidity above and beyond the call of duty".
Reply With Quote
  #3  
Old 09-08-2008, 04:33 AM
Fatemeh
Guest
 
Default Re: some flags for optimization?? ( run with higher speed)??

On Sep 8, 12:02 pm, "Dr Ivan D. Reid" <Ivan.R...@brunel.ac.uk> wrote:
> On Mon, 8 Sep 2008 00:29:40 -0700 (PDT), Fatemeh <fateme.mirj...@gmail.com>
> wrote in <23de88ca-360d-44d2-b1f2-da24b9216...@z66g2000hsc.googlegroups.com>:
>
>
>
> > I've written a code in fortran90. Since my sample is large, my code
> > runs slowly.
> > I need some flags in order to enter them to Makefile which can be able
> > to run the code with higher speed.
> > -----------------------------------------------------------------
> > this is my Makefile:
> > ----------------------------------
> > FC=ifort
> > NROBJS=nr.o nrtype.o parametros.o
> > MYOBJS= wfinside.o gauntutils.o leedutils.o
> > MYSUBFUN=DoubleFactorialDP.o FactorialDP.o Gaunt.o Legendre.o
> > SphericalHarmonicYZ.o SqrtFactorialDP.o ThreeJSymbol.o factorial.f90
> > bessel.o writefile.o intgral.o ComlexUnit.o
> > .SUFFIXES:
> > .SUFFIXES: .f90 .o

>
> > all: $(NROBJS) $(MYOBJS) $(MYSUBFUN) main-goodformat2.o
> > $(FC) $(NROBJS) $(MYOBJS) $(MYSUBFUN) main-goodformat2.o -o
> > wannier.exe

>
> > .f90.o:
> > $(FC) -c $<

>
> > nr.o: nr.f90 nrtype.o
> > nrtype.o: nrtype.f90

>
> ...
>
> > Would you please guide me if there is any flag for this purpose?
> > (I cannot write my code in Parallel. so I should find some flags!!!)
> > I'm anxiously looking forward your reply and guidelines.

>
> You don't appear to be using any optimisation. Try adding -O3 to
> your .f90.o: line. Type in 'ifort --help' to get a listing of some flags you
> can try. There's also a chance you can get better interprocedural optimisation
> by combining some of your source files together.
>
> --
> Ivan Reid, School of Engineering & Design, _____________ CMS Collaboration,
> Brunel University. Ivan.Reid@[brunel.ac.uk|cern.ch] Room 40-1-B12, CERN
> KotPT -- "for stupidity above and beyond the call of duty".


IN WHICH LINE OF MAKEFILE SHOULD I ADD -O3 ?
WHAT IS YOUR MEAN ABOUT "combining some of the source files"?
Reply With Quote
  #4  
Old 09-08-2008, 05:15 AM
Fatemeh
Guest
 
Default Re: some flags for optimization?? ( run with higher speed)??

On Sep 8, 12:33 pm, Fatemeh <fateme.mirj...@gmail.com> wrote:
> On Sep 8, 12:02 pm, "Dr Ivan D. Reid" <Ivan.R...@brunel.ac.uk> wrote:
>
>
>
> > On Mon, 8 Sep 2008 00:29:40 -0700 (PDT), Fatemeh <fateme.mirj...@gmail.com>
> > wrote in <23de88ca-360d-44d2-b1f2-da24b9216...@z66g2000hsc.googlegroups.com>:

>
> > > I've written a code in fortran90. Since my sample is large, my code
> > > runs slowly.
> > > I need some flags in order to enter them to Makefile which can be able
> > > to run the code with higher speed.
> > > -----------------------------------------------------------------
> > > this is my Makefile:
> > > ----------------------------------
> > > FC=ifort
> > > NROBJS=nr.o nrtype.o parametros.o
> > > MYOBJS= wfinside.o gauntutils.o leedutils.o
> > > MYSUBFUN=DoubleFactorialDP.o FactorialDP.o Gaunt.o Legendre.o
> > > SphericalHarmonicYZ.o SqrtFactorialDP.o ThreeJSymbol.o factorial.f90
> > > bessel.o writefile.o intgral.o ComlexUnit.o
> > > .SUFFIXES:
> > > .SUFFIXES: .f90 .o

>
> > > all: $(NROBJS) $(MYOBJS) $(MYSUBFUN) main-goodformat2.o
> > > $(FC) $(NROBJS) $(MYOBJS) $(MYSUBFUN) main-goodformat2.o -o
> > > wannier.exe

>
> > > .f90.o:
> > > $(FC) -c $<

>
> > > nr.o: nr.f90 nrtype.o
> > > nrtype.o: nrtype.f90

>
> > ...

>
> > > Would you please guide me if there is any flag for this purpose?
> > > (I cannot write my code in Parallel. so I should find some flags!!!)
> > > I'm anxiously looking forward your reply and guidelines.

>
> > You don't appear to be using any optimisation. Try adding -O3 to
> > your .f90.o: line. Type in 'ifort --help' to get a listing of some flags you
> > can try. There's also a chance you can get better interprocedural optimisation
> > by combining some of your source files together.

>
> > --
> > Ivan Reid, School of Engineering & Design, _____________ CMS Collaboration,
> > Brunel University. Ivan.Reid@[brunel.ac.uk|cern.ch] Room 40-1-B12, CERN
> > KotPT -- "for stupidity above and beyond the call of duty".

>
> IN WHICH LINE OF MAKEFILE SHOULD I ADD -O3 ?
> WHAT IS YOUR MEAN ABOUT "combining some of the source files"?


I wrote -O3 at the first line of makefile and it works, but the speed
is still low. what should I do? Is there any usefull flag for my
purpose?

Thanks in advance.
Fatemeh
Reply With Quote
  #5  
Old 09-08-2008, 09:33 AM
Steve Lionel
Guest
 
Default Re: some flags for optimization?? ( run with higher speed)??

On Mon, 8 Sep 2008 00:29:40 -0700 (PDT), Fatemeh <fateme.mirjani@gmail.com>
wrote:

>I've written a code in fortran90. Since my sample is large, my code
>runs slowly.
>I need some flags in order to enter them to Makefile which can be able
>to run the code with higher speed.


Since you are using Intel Fortran (for Linux, I assume), please feel free to
ask your questions in our user forum at:

http://softwarecommunity.intel.com/i...ShowForum.aspx

-O3 has been suggested. You should also use an instruction set optimization
option appropriate for the processor you're using (which you did not specify.)
http://softwarecommunity.intel.com/i...ShowForum.aspx
describes these options and lists the processors to which they apply. You
should also read
http://www.intel.com/support/perform.../CS-028403.htm For example,
if you were using an Intel Core 2 processor, use -xT .

Another option you can experiment with is -ipo. This needs to be specified
both for compile and for the ifort command that creates the executable. This
has the same effect as combining all the sources as mentioned by Ivan.

An option that can make a significant difference in some applications is
-no-prec-div, which uses a faster method for divides, with the tradeoff of
some accuracy.

I strongly recommend reading the Intel documentation's section on optimizing
applications. It has a lot of good advice.

--
Steve Lionel
Developer Products Division
Intel Corporation
Nashua, NH

For email address, replace "invalid" with "com"

User communities for Intel Software Development Products
http://softwareforums.intel.com/
Intel Fortran Support
http://support.intel.com/support/per...etools/fortran
My Fortran blog
http://www.intel.com/software/drfortran
Reply With Quote
  #6  
Old 09-08-2008, 11:40 AM
Richard Maine
Guest
 
Default Re: some flags for optimization?? ( run with higher speed)??

Fatemeh <fateme.mirjani@gmail.com> wrote:

> I need some flags in order to enter them to Makefile which can be able
> to run the code with higher speed.


Others have mentioned the most straightforward answer to this - namely
to turn on the compiler's optimizer, making the code run faster being
exactly what the optimizer is for.

But I'm afraid that a much more basic answer is that there probably is
no magic switch that will solve your problem. Making programs run faster
is a subject of far more depth than just finding a magic switch. At
times there can be trivial solutions, but at other times it can take a
lot of work. You gave pretty much no specific useful data in your
posting, so I can't offer much in the way of specific useful replies.

Some very general answers, unfortunately to general to be of much use,
I'm afraid.

1. Well, there are always the compiler optimization options, as you
asked for. Sometimes one can get lucky. Other times, they do no good at
all. I'd say that most often, they offer some speedup, but probably less
than what I'm guessing you are looking for. Would you be happy with 30%
speedup? That would be pretty good (though exact numbers do vary a lot).

2. This really should be number 1, but I just wanted to get the easy
answer up at the top there. The advice that is so standard as to be a
cliche - algorithms determine speed a lot more than anything else. That
advice bears repeating again and again... and again. People who say
things like that "they already looked at that" usually don't appreciate
how fundamentally important it really is. Usually, it bears looking at
again. You can get percentage speed improvements in lots of ways. To get
large factors, you need to look at algorithm choice. Factors of
thousands (or more) are not at all unheard of.

Of course, learning about good algorithms is a substantial subject of
study, all in itself.

3. Then there is coding. Frankly, most coding tweaks are small stuff
compared to algorithms. People historically spend far too much time
looking for coding tweaks when they should be looking for better
algorithms (or on making the code actually correct instead of just
fast). But there are numerous such tweaks. One of the biggest ones for
today's machines is to watch for memory acess patterns. Things like
processing down columns instead of across rows of large arrays can make
a big difference (though redoing algorithms so that they don't require
such large arrays at all can make a bigger one).

I know that the above are awfully general. Unfortunately, so was your
question.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
Reply With Quote
  #7  
Old 09-08-2008, 12:12 PM
Craig Powers
Guest
 
Default Re: some flags for optimization?? ( run with higher speed)??

Fatemeh wrote:
> Dear all ;
>
> I've written a code in fortran90. Since my sample is large, my code
> runs slowly.
> I need some flags in order to enter them to Makefile which can be able
> to run the code with higher speed.


In general, you should study the compiler documentation. After a
certain level, optimizations become so aggressive that they are not
guaranteed to speed up your program and may even slow it down. Also,
some optimizations sacrifice accuracy for additional speed. You will
need to test them, to determine what works best and to determine what
you can use without getting wrong (or insufficiently accurate) results.

> -----------------------------------------------------------------
> this is my Makefile:
> ----------------------------------
> FC=ifort


I typically add a couple of lines here:
OPTFLAGS=-O -ipo
LINKFLAGS=

(the latter is where I add in -l and -L lines when I include external
libraries)

For my particular usage, -O -ipo is the appropriate optimization set,
and other alternatives do not increase execution speed measurably. Your
mileage may vary---this is highly dependent on processor architecture
and your code.

> NROBJS=nr.o nrtype.o parametros.o
> MYOBJS= wfinside.o gauntutils.o leedutils.o
> MYSUBFUN=DoubleFactorialDP.o FactorialDP.o Gaunt.o Legendre.o
> SphericalHarmonicYZ.o SqrtFactorialDP.o ThreeJSymbol.o factorial.f90
> bessel.o writefile.o intgral.o ComlexUnit.o
> .SUFFIXES:
> .SUFFIXES: .f90 .o
>
> all: $(NROBJS) $(MYOBJS) $(MYSUBFUN) main-goodformat2.o
> $(FC) $(NROBJS) $(MYOBJS) $(MYSUBFUN) main-goodformat2.o -o


Then, this becomes:
$(FC) $(OPTFLAGS) $(LINKFLAGS) $(NROBJS) $(MYOBJS) \
$(MYSUBFUN) main-goodformat2.o -o wannier.exe

> .f90.o:
> $(FC) -c $<


and this becomes:
$(FC) $(OPTFLAGS) -c $<

Reply With Quote
  #8  
Old 09-08-2008, 04:36 PM
Dr Ivan D. Reid
Guest
 
Default Re: some flags for optimization?? ( run with higher speed)??

On Mon, 8 Sep 2008 01:33:10 -0700 (PDT), Fatemeh <fateme.mirjani@gmail.com>
wrote in <25135587-cf11-414f-80d1-a17640c15999@b1g2000hsg.googlegroups.com>:
> On Sep 8, 12:02 pm, "Dr Ivan D. Reid" <Ivan.R...@brunel.ac.uk> wrote:
>> On Mon, 8 Sep 2008 00:29:40 -0700 (PDT), Fatemeh <fateme.mirj...@gmail.com>
>> wrote in <23de88ca-360d-44d2-b1f2-da24b9216...@z66g2000hsc.
>> googlegroups.com>:


>> > .f90.o:
>> > $(FC) -c $<


>> You don't appear to be using any optimisation. Try adding -O3 to
>> your .f90.o: line. Type in 'ifort --help' to get a listing of some flags you
>> can try. There's also a chance you can get better interprocedural optimisation
>> by combining some of your source files together.


> IN WHICH LINE OF MAKEFILE SHOULD I ADD -O3 ?


>> > .f90.o:
>> > $(FC) -c -O3 $<


but Richard Maine's solution is more general. I think you need to read up
the documentation on makefiles as well as ifort flags.

> WHAT IS YOUR MEAN ABOUT "combining some of the source files"?


Concatenating them together, so that the compiler can make
intelligent decisions about in-lining small functions, for example.
Steve Lionel suggested that -ipo can help here even without combining
sources -- naturally I bow to his greater knowledge of his own product
(and I have used -ipo myself to some effect, lately).

--
Ivan Reid, School of Engineering & Design, _____________ CMS Collaboration,
Brunel University. Ivan.Reid@[brunel.ac.uk|cern.ch] Room 40-1-B12, CERN
KotPT -- "for stupidity above and beyond the call of duty".
Reply With Quote
  #9  
Old 09-09-2008, 02:08 AM
michaelmetcalf@compuserve.com
Guest
 
Default Re: some flags for optimization?? ( run with higher speed)??

On Sep 8, 11:15*am, Fatemeh <fateme.mirj...@gmail.com> wrote:
> On Sep 8, 12:33 pm, Fatemeh <fateme.mirj...@gmail.com> wrote:
>
>
>
>
>
> > On Sep 8, 12:02 pm, "Dr Ivan D. Reid" <Ivan.R...@brunel.ac.uk> wrote:

>
> > > On Mon, 8 Sep 2008 00:29:40 -0700 (PDT), Fatemeh <fateme.mirj...@gmail.com>
> > > *wrote in <23de88ca-360d-44d2-b1f2-da24b9216...@z66g2000hsc.googlegroups.com>:

>
> > > > I've written a code in fortran90. Since my sample is large, my code
> > > > runs slowly.
> > > > I need some flags in order to enter them to Makefile which can be able
> > > > to run the code with higher speed.
> > > > -----------------------------------------------------------------
> > > > this is my Makefile:
> > > > ----------------------------------
> > > > FC=ifort
> > > > NROBJS=nr.o nrtype.o parametros.o
> > > > MYOBJS= wfinside.o gauntutils.o leedutils.o
> > > > MYSUBFUN=DoubleFactorialDP.o FactorialDP.o Gaunt.o Legendre.o
> > > > SphericalHarmonicYZ.o SqrtFactorialDP.o ThreeJSymbol.o factorial.f90
> > > > bessel.o writefile.o intgral.o ComlexUnit.o
> > > > .SUFFIXES:
> > > > .SUFFIXES: .f90 .o

>
> > > > all: $(NROBJS) $(MYOBJS) $(MYSUBFUN) main-goodformat2.o
> > > > * * * * $(FC) $(NROBJS) $(MYOBJS) $(MYSUBFUN) main-goodformat2.o *-o
> > > > wannier.exe

>
> > > > .f90.o:
> > > > * * * * $(FC) -c $<

>
> > > > nr.o: nr.f90 nrtype.o
> > > > nrtype.o: nrtype.f90

>
> > > ...

>
> > > > Would you please guide me if there is any flag for this purpose?
> > > > (I cannot write my code in Parallel. so I should find some flags!!!)
> > > > I'm anxiously looking forward your reply and guidelines.

>
> > > * * * * You don't appear to be using any optimisation. *Tryadding -O3 to
> > > your .f90.o: line. *Type in 'ifort --help' to get a listing of someflags you
> > > can try. *There's also a chance you can get better interprocedural optimisation
> > > by combining some of your source files together.

>
> > > --
> > > Ivan Reid, School of Engineering & Design, _____________ *CMS Collaboration,
> > > Brunel University. * *Ivan.Reid@[brunel.ac.uk|cern.ch] * *Room 40-1-B12, CERN
> > > * * * * KotPT -- "for stupidity above and beyond the call of duty".

>
> > IN WHICH LINE OF MAKEFILE SHOULD I ADD *-O3 ?
> > WHAT IS YOUR MEAN ABOUT "combining some of the source files"?

>
> I wrote -O3 at the first line of makefile and it works, but the speed
> is still low. what should I do? Is there any usefull flag for my
> purpose?
>
> Thanks in advance.
> Fatemeh- Hide quoted text -
>
> - Show quoted text -


A further possibility is to examine whether the compiler's flags are,
by default, degrading run-time performance. In particular, ifort
peforms run-time array bounds checking by default, very useful for
code development, but if you're using arrays heavily, as I do, the
peformance hit can be large. If I use O3 and no run-time checking my
programs go up to three times faster than with O0 and bounds checking.

Regards,

Mike Metcalf
Reply With Quote
  #10  
Old 09-09-2008, 10:51 AM
Steve Lionel
Guest
 
Default Re: some flags for optimization?? ( run with higher speed)??

On Mon, 8 Sep 2008 23:08:21 -0700 (PDT), michaelmetcalf@compuserve.com wrote:

>A further possibility is to examine whether the compiler's flags are,
>by default, degrading run-time performance. In particular, ifort
>peforms run-time array bounds checking by default,


The only situation where array bounds checking is on by default is in the
Debug configuration of a Visual Studio project. In a Release configuration,
or if building from the command line, all the run-time checks are off by
default.

--
Steve Lionel
Developer Products Division
Intel Corporation
Nashua, NH

For email address, replace "invalid" with "com"

User communities for Intel Software Development Products
http://softwareforums.intel.com/
Intel Fortran Support
http://support.intel.com/support/per...etools/fortran
My Fortran blog
http://www.intel.com/software/drfortran
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 03:06 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.