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

How do I disable vectorisation for specific loops in ifort? (Mac OS 10.5)

jabakobob
Beginner
1,086 Views
When I try to run the following program:

PROGRAM TEST
implicit none
INTEGER, PARAMETER:: nx=100, ny=100
REAL, DIMENSION(:,:), ALLOCATABLE :: S
INTEGER:: i, j

ALLOCATE( S( -nx:nx, -ny:ny ) )

PRINT *,"Starting... "

do i=-nx,nx
do j=-ny,ny
S(i,j) = exp(-1.0 * ( i**2 + j**2 ) )
end do
end do


END PROGRAM

the following Error is thrown at runtime:
forrtl: severe (174): SIGSEGV, segmentation fault occurred

(If I remove the print line, the error sudenly disappears)

If I compile with the -O1 option, everything works as expected.

I suspect that the problem might be related to vectorisation - how can I disable vectorisation for one loop in fortran with ifort?
0 Kudos
4 Replies
Steven_L_Intel1
Employee
1,086 Views
I doubt it's vectorization. But there is a !DEC$ NOVECTOR directive you can put before the loop.

On which line does the segv occur?
0 Kudos
jabakobob
Beginner
1,086 Views
I tried the !DEC$ NOVECTOR directive, and the code worked.

I can't say what line the segv occurs exactly, it only says unknown for line number.

If I add a PRINT statement in the outer loop, it prints the message once and then the segv occurs.
If I add a print statement in the inner loop, the code works as expected (and the loop isn't vectorized)

I also tried the !DEC$ NOVECTOR directive for vector operations, and it worked for simple ones (ie. a[:]=b[:]), but it doesn't seem to work for more complicated assignments like

a[1:n,1:n]=a[1:n,1:n]+a[0:n-1,0:n-1]

The compiler just spits out the following warning:
The statement following this DEC loop optimization directive must be an iterative do-stmt, a vector assignment, an OMP pdo-directive, or an OMP parallel-do-directive.

...and then vectorizes it anyways.
0 Kudos
Steven_L_Intel1
Employee
1,086 Views
Please report the SEGV problem to Intel Premier Support.
0 Kudos
jabakobob
Beginner
1,086 Views
Just reported the issue to Premier Support.... (Took me some time to sign up and answer all those security questions...) Thanks for your help!
0 Kudos
Reply