For Programmers: Free Programming Magazines  


Home > Archive > Fortran > August 2005 > External subroutines slow down









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author External subroutines slow down
Matthias Möller

2005-08-15, 4:01 am

With the Intel Fortran compiler (l_fc_pu_8.1.021) I observed, that
external subroutines used within loops slow down the performance
drastically.

The critical subroutine is as follows

SUBROUTINE assemble(eig,dir)
EXTERNAL :: eig
INTEGER :: dir

DO i=1,nvt
DO iedge=kedge(i),kedge(i+1)-1
j=kvedge(iedge)

...

!! Call subroutine that computes 4x4 matrix of eigenvalues in x-
!! and y-direction, respectively

!! 1. version
CALL eig(i,j)

!! 2. version
SELECT CASE (dir)
CASE (1)
CALL eig_x(i,j)
CASE (2)
CALL eig_y(i,j)
CASE (3)
CALL eig_z(i,j)
END SELECT

...
END DO
END DO
END SUBROUTINE assemble


In the first version the subroutine to compute the eigenvalues is
declared externally and ASSEMBLE is called three times with eig_x,eig_y
and eig_z, respectively. The generated code runs quite a long time.

In the second version a SELECT-CASE statement is used within(!!) a loop
and nevertheless the code runs much faster. For a simple testcode the
runtime was 8 seconds (v2) and 58 seconds (v1).

Would you suggest to use the second version (with SELECT-CASE within the
loop) or can the first version be improved?

Many thanks for your help

Matthias Moeller
Jan Vorbrüggen

2005-08-15, 9:01 am

What level of optimization are you using? Is inlining enabled, can you
ask the compiler to explicitly inline the external subroutine? For CVF,
this requires "one-step" compilation, i.e., making all source files
available to the compiler in one command.

Jan
Matthias Möller

2005-08-15, 9:01 am

Jan Vorbrüggen wrote:
> What level of optimization are you using? Is inlining enabled, can you
> ask the compiler to explicitly inline the external subroutine? For CVF,
> this requires "one-step" compilation, i.e., making all source files
> available to the compiler in one command.
>
> Jan

I tried both, optimization -O3 -ipo -static (complete testcode is in one
file) and -O0. The required computing time differs drastically.

Matthias
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com