Poor performance of implied-DO loop with Intel Fortran

From: Aidan (aidan_at_alghieri.rsc.anu.edu.au)
Date: 05/03/04

  • Next message: glen herrmannsfeldt: "Re: Poor performance of implied-DO loop with Intel Fortran"
    Date: 3 May 2004 15:02:47 +1000
    
    

    This is something of a "heads-up" to others who might be using the
    Intel fortran compliers.

    I get very poor performance when using implied-DO loops to initialise
    arrays when the loop counter of the implied-DO is greater than one
    million. The performance is fine with loops up to one hundred
    thousand.

    For example. A simple program that just initialises an integer array
    with an implied-DO construct, e.g. array = (/ (1, i=1,n) /). For
    n=100000 the execution time is 20 milliseconds. For n=1000000 execution
    time is > 10 seconds.

    This has been tested under linux with Intel(R) Fortran Compiler for
    32-bit applications, Version 7.1 Build 20040309Z

    I wasn't able to time v8.0 of the Intel compiler because it segfaulted
    (Version 8.0 Build 20040412Z and Build 20031211Z both exhibited the
    same behaviour -- I don't use v8.0 because it is flakey).

    As a comparison a Tru64 UNIX fortran compiler (HP Fortran Compiler
    V5.5A-3548-48D88) ran fine up to n=10000000 with no speed degredation.

    Do other compilers fare better?

    Cheerio

    Aidan

    P.S. Here are some test programs if people want to try them on their
    compilers. Note that one uses a loop and one an implied-DO to achieve
    the same result. Also note that convoluted way this is implemented.
    I was attempting to overcome the optimising of the compiler which
    seemed to put simple initialisations like this into the executable
    unless I hid them in a subroutine.

    program packtest3
      
      call sub(1000000)

    contains

      subroutine sub(n)
        
        integer, intent(in) :: n
        integer :: trues(n)
        
        trues = (/ (i, i=1,n) /)
        
      end subroutine sub

    end program packtest3

    program packtest4
      
      call sub(1000000)
      
    contains

      subroutine sub(n)
        
        integer, intent(in) :: n
        integer :: trues(n)
        
        do i = 1, n
           trues(i) = i
        end do
        
      end subroutine sub
      
    end program packtest4


  • Next message: glen herrmannsfeldt: "Re: Poor performance of implied-DO loop with Intel Fortran"

    Relevant Pages

    • Re: f95 OOP question
      ... and I managed to bring the intel compiler to its knees. ... until you understand Fortran 95 a little better. ... The term module means the same thing in Fortran 95 that it does in every other computer programming language. ...
      (comp.lang.fortran)
    • Bug in IBM Fortran compiler?
      ... while trying to compile an application with the IBM Fortran compiler I ... "Add" subroutine, but I just found that the assignment ...
      (comp.lang.fortran)
    • Re: Jumping into block of an if construct
      ... (For that matter a clever enough compiler could replace this PUT DATA ... routine which itself executes the loops around element handling. ... Either way I think the cost of element handling will usually ... So locally based on subroutine arguments, but not on, for example, ...
      (comp.lang.fortran)
    • Re: beginners question
      ... If you pass a literal to a subroutine, the compiler puts the ... literal into a temporary variable and passes a reference to that ... Also, since FORTRAN was developed at a time when memory was very tight, ...
      (comp.lang.perl.misc)
    • Re: Double precision arrays and subroutines
      ... to be the start of an nx * nx array. ... What happens is that, in Fortran, these two program units are independent. ... The subroutine and the program that calls it are compiled separately, and normally the compiler doesn't know about one when it's compiling the other. ... Thus, the compiler doesn't know about the mismatch between the fact that the subroutine call is being given an integer and two scalar doubles, and the subroutine declaration is expecting an integer and two double arrays. ...
      (comp.lang.fortran)