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

"Illegal instruction" error with OpenMP

reynoldssmu_edu
Beginner
1,443 Views
I am having a rather peculiar error when trying to use OpenMP and ifort in OS X.
I have the following [very simple] code:
!========================================
program axpy
implicit none
integer, parameter :: n=10000000
integer :: i
double precision :: a, stime, ftime
double precision, dimension(n) :: x, y, z
a = -3.d0
do i=1,n
x(i) = exp(2.d0*i/n)
y(i) = 1.d0*(n-1)/n
end do
do i=1,n
z(i) = a*x(i) + y(i)
end do
do i=1,n
x(i) = y(i)/a - z(i)
end do
do i=1,n
y(i) = x(i)*y(i)/n
end do
write(*,*) ' max(z) =',maxval(z)
end program axpy
!========================================
The code is in a file "axpy_omp.f90"
I compile this at the command line with
ifort -openmp -O2 axpy_omp.f90 -o axpy_omp.exe
and when I run the code I get the error message
Illegal instruction
If I compile without OpenMP,
ifort -O2 axpy_omp.f90 -o axpy_omp.exe
it runs just fine.
I have seen some other threads complaining about ifort + XCode, though since I'm not using XCode in this process, I'm not sure if it is at all related. In any case, I'm running on OS X 10.5.8, with XCode 3.1.4 installed. My version of ifort is
ifort (IFORT) 11.0 20090318
Any help would be appreciated, as I'm planning on using this code as a simple OpenMP example in an upcoming class.
0 Kudos
2 Replies
Ron_Green
Moderator
1,443 Views
you're being slapped by the puny stack size on Mac OS X.

read this article: http://software.intel.com/en-us/articles/determining-root-cause-of-sigsegv-or-sigbus-errors/

but since you're using OMP, you can't use -heap-arrays. The ulimit -s 65532 isn't going to help either, as this is still too small. Use the -Wl trick. This worked for me:

ifort -openmp -O2 -o u80188 u80188.f90 -Wl,-stack_size,0x10000000

and it ran
$ ./u80188
max(z) = -2.00000070000006

Now the caveat: I did this with the latest compiler and not 11.0. But your code is so simple, I don't see anything that would trip up the 11.0 compiler.

Good luck with the class!

ron
0 Kudos
reynoldssmu_edu
Beginner
1,443 Views
Thanks for the quick reply. I hadn't thought of the stack size, though I should have. I also have corresponding C routines for all of my F90 examples, and had no trouble in the equivalent C file, though there I dynamically allocate the arrays. Instead of using your workaround I just allocated the arrays at runtime instead of declaring them statically in the header.

0 Kudos
Reply