Re: MODULEand USE versus Argument Passing



Thanks.

Adding aa call to an External (versus contained) subprogram, S3,
to your code, and making the Integer a,b,c ... be REAL*8,
and using Intel ifort 8.1 with no optimization (on an Athalon),
I got the following timings

Module 0.22
Containg Subprogram Arguments 0.22
External Subprogram Arguments 0.22999999999999993

Skip

On 29 Jun 2005 07:36:52 -0700, "Joost" <jv244@xxxxxxxxx> wrote:

-|I don't think you can see this independent of the architecture, the
-|compilers, the kind of arguments and so on and so forth. Just a simple
-|benchmark shows that in that specific case, passing 10 arguments is
-|actually faster (ia32, ifort):
-|
-|output:
-| Module 0.285956000000000
-| Arguments 0.250962000000000
-|
-|code:
-|MODULE M1
-| INTEGER :: a,b,c,d,e,f,g,h,i,j
-|CONTAINS
-| SUBROUTINE S1()
-| a=a*b*c*d*e*f*g*h*i*j
-| END SUBROUTINE S1
-| SUBROUTINE S2(a,b,c,d,e,f,g,h,i,j)
-| INTEGER :: a,b,c,d,e,f,g,h,i,j
-| a=a*b*c*d*e*f*g*h*i*j
-| END SUBROUTINE S2
-|END MODULE M1
-|
-|USE M1
-|INTEGER :: k
-|REAL*8 :: t1,t2,t3,t4
-|a=0 ; b=0 ; c=0 ; d=0 ; e=0 ; f=0;
-|g=0 ; h=0 ; i=0 ; j=0
-|CALL CPU_TIME(T1)
-|DO k=1,10000000
-| CALL S1()
-|ENDDO
-|CALL CPU_TIME(T2)
-|write(6,*) "Module ",T2-T1
-|CALL CPU_TIME(T1)
-|DO k=1,10000000
-| CALL S2(a,b,c,d,e,f,g,h,i,j)
-|ENDDO
-|CALL CPU_TIME(T2)
-|write(6,*) "Arguments ",T2-T1
-|END
-|
-|Cheers,
-|
-|Joost

.



Relevant Pages

  • Re: How to compile the example_itsol_1.f , and why always meets these errors.
    ... > the arguments are different at the calling point and where the subprogram ... > Subroutine my_sub ... it try to call the DITSOL_PCG which is a cxml ...
    (comp.lang.fortran)
  • Re: Event mechanisms for GUIs
    ... writing a subroutine even when said subroutine is only called one place. ... I beg to differ. ... When a subprogram is called from one place, it is clear when, why, and under what circumstance the call takes place. ... When a subprogram is passed to a windowing framework to be called when the framework pleases, ...
    (comp.lang.ada)
  • Re: ArrayList - Newbie Misunderstanding
    ... different from a subroutine with multiple entry and exit points - in ... subprogram can either be local or global. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: factorial n! program
    ... Fundamentally a function is a subprogram that returns a value in a way ... A subroutine is invoked by a separate call statement (well, ... There are lots of consequences and subtleties, ... That extra feature brings with it some ...
    (comp.lang.fortran)