Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

ICE with -heap-arrays and -O3

Alexis_R_
New Contributor I
810 Views
Test case attached, here is how to run it, and the output I get with ifort version 12.1.0 (20110811):

[bash]$ ls 111017_ice.zip 
111017_ice.zip
$ unzip 111017_ice.zip 
Archive:  111017_ice.zip
   creating: fftw3.3/
   creating: src/
  inflating: test_ifort_ice.txt      
  inflating: fftw3.3/fftw33.f90      
  inflating: fftw3.3/fftw3.f03       
  inflating: src/image_fft.f90       
  inflating: src/runtime_parameters.f90  
  inflating: src/runtime_parameters.f90~  
  inflating: src/image_base.f90      
  inflating: src/image_looping.f90   
  inflating: src/image.f90
$ source test_ifort_ice.txt 
rm: No match.
: catastrophic error: **Internal compiler error: segmentation violation signal raised** Please report this error along with the circumstances in which it occurred in a Software Problem Report.  Note: File and line given may not be explicit cause of this error.
compilation aborted for src/image.f90 (code 1)
[/bash]


The ICE is averted if -heap-arrays is removed or if -O3 is changed to -O2.

I would appreciate a workaround that doesn't involve switching -O3 off, if you find one.


EDIT: the ICE does not occur with ifort 12.0.5 (20110719)

0 Kudos
7 Replies
Ron_Green
Moderator
810 Views
OK, I'll get a report started and see if I can find a workaround.
ron
0 Kudos
Alexis_R_
New Contributor I
810 Views
Hi Ron,

Did you manage to reproduce this?
0 Kudos
Ron_Green
Moderator
810 Views
sorry for the delay, I have been at a conference and traveling.

Yes, I can reproduce on the latest compilers.

The error is when it compiles AMPL_FROM_HALF_TO_FULL_OLD in image.f90. I am trying to simplify it some, but it seems it needs most of the context/statements in this to reproduce.

You can compile image.f90 at -O2 to avoid. The O3 loop transforms are what is crashing. The other files can all be compiled with -O3 -heap-arrays, and only image.f90 at -O2 -heap-arrays would be a work around.

Still working to trim this down, should have more info later today.
ron
0 Kudos
Ron_Green
Moderator
810 Views
OK, I found it and have a new version of image.f90 that is functionally equivalent.

As I said, the culprit is a compiler bug compiling AMPL_FROM_HALF_TO_FULL_OLD in image.f90.
This code, near the end, has 2 IF ELSE ENDIF blocks with the same condition.
Thus, at O3 the compiler is trying to fuse the 2 IF blocks into 1 IF block.
You can compare my code with your original.

I have attached a revised image.f90 below that is functionally equivalent. I manually merged the 2 identical IF blocks. This compiles at -O3 -heap-arrays.

Also look at my reproducer below and you'll see the identical IF conditional in 2 IF blocks back-to-back.

For reproducing the bug for the bug report, I used the code below which removed all USE dependences, removed the module, etc. Again, the bug is triggered when O3 tries to merge the 2 IF blocks.

[bash]        SUBROUTINE AMPL_FROM_HALF_TO_FULL_OLD(IMG)
        implicit none

        TYPE IMAGE
          INTEGER                     ::  DIM(3)              =   (/1,1,1/)
          REAL, POINTER ::  RVALUE(:,:,:)
        END TYPE IMAGE

                TYPE(IMAGE),    INTENT(INOUT)   ::      IMG

                TYPE(IMAGE)             ::      TMP
                INTEGER                 ::      I
                REAL, ALLOCATABLE       ::      RTEMP(:)

                ! Prepare the temporary image
                TMP             = IMG

                IMG%RVALUE = 0.0

                ! First the first Y-Z plane needs to be flipped.
                IF (IMG%DIM(3) .GT. 1) THEN
                        IMG%RVALUE(1,1,1:IMG%DIM(3)) = 0.0
                ENDIF

                IF (IMG%DIM(3) .GT. 1) THEN
                        DO I=IMG%DIM(1)/2+2,IMG%DIM(1)
                                RTEMP(1:IMG%DIM(2)-1) = RTEMP(IMG%DIM(2)-1:1:-1) ! reverse order within RTEMP
                                IMG%RVALUE(IMG%DIM(1)-I+2,2:IMG%DIM(2),1) = RTEMP(1:IMG%DIM(2)-1)
                        ENDDO
                ENDIF

        END SUBROUTINE AMPL_FROM_HALF_TO_FULL_OLD
[/bash]
0 Kudos
Alexis_R_
New Contributor I
810 Views
Ron,

Nice catch & many thanks for the workaround.

Alexis
0 Kudos
Ron_Green
Moderator
810 Views
You did most of the work getting the right code to me with a great description of how to build. the rest was just my grunt work :)

The bug report is DPD200175015

we'll keep you posted when a fix is available.

ron

0 Kudos
Ron_Green
Moderator
810 Views
This bug is fixed in the recent 12.1 compilers released after February 2012.

closing this issue

ron
0 Kudos
Reply