Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29276 Discussions

Vectorization and segmentation fault

Matthieu_B_
Beginner
4,825 Views

I have a problem with an old software that used to work with ifort 11 and does not anymore with recent versions.

This software is written in fortan 77 and uses an old trick to manage its memory. This trick leads to the arrays out of their bounds so don’t be shocked!

The idea is, at the beginning of the execution to allocate a big array with a C malloc and to calculate the distance from this array and a reference array (called refarr in the following). To get data with the good type in the allocated array, an equivalence statement is used.

 

In this software,  a loop always return a segmentation fault when it is vectorized and I don’t get why. Here is a simplified source code :

[fortran]

      subroutine mysub(datpos,n)

   

c     datpos = data position in the allocated array

 

      implicit none

   

   

      integer*8 DIST ! distance of the reference array to the allocated array

      integer   datpos,n

   

      integer   refarr

      integer*8 adress_arr(1)

      integer   anint,i,j,jj(n)

         

      COMMON/MYCOM/DIST,refarr(2)

   

   

c      with this statement, refarr, adress_arr are at the same adress

      equivalence (refarr(1),adress_arr(1))

    

c    some code her

 

      anint = 0

   

      do i=4,n !or anything else here

        jj(i)=refarr(adress_arr(DIST+datpos)+1+i)

        if(refarr(adress_arr(DIST+jj(i))+3).EQ.4)THEN

          anint = 1

        ENDIF

      enddo

   

c    more code her

 

      return

      end

[/fortran]

 

With ifort11, this loop was not vectorized and it worked. I obviously found the solution to use the NOVECTOR directive but it does not explain the problem. I found another solution : if I declare a jj array and change the loop this way, the software works (I also needed to use the VECTOR ALWAYS directive because the optimizer says that the vectorization of the modified loop seem unefficient) :

[fortran]

      do i=4,n !or anything else here

        jj(i)=refarr(adress_arr(DIST+datpos)+1+i)

        if(refarr(adress_arr(DIST+jj(i))+3).EQ.4)THEN

          anint = 1

        ENDIF

      enddo

[/fortran]

 

Does anyone have an idea of what is the problem ?

0 Kudos
22 Replies
Martyn_C_Intel
Employee
769 Views

I didn't imagine it; I did test an early 15.0 compiler and the fix did work. However, a subsequent fix to a different issue caused a regression in this one, and this wasn't detected until after the product release, due to a technical problem (relating to the memory footprint). A new fix for both issues is in progress. It will not be in the first update to the 15.0 compiler, which will be posted shortly, but it should be in the second update sometime in the new year.

Apologies for the thrash on this.

0 Kudos
Martyn_C_Intel
Employee
769 Views

Just confirming that this issue is indeed fixed in update 2 to the 15.0 compiler, 15.0.2.164, which is available via the Intel Registration Center.

0 Kudos
Reply