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.
29283 Discussions

segmentation violation for allocatable arrays

cpmaster
Beginner
729 Views

program test
real(8), dimension(:,:),allocatable :: a,b,c
allocate(a(1024,1024))
allocate(b(1024,1024))
allocate(c(1024,1024))
c = 2.*matmul(a,b)
end program test


This code gives a SEGV at the assignment of c using the Intel
Fortran Compiler for Linux 8.0, but works under g95. It works for
both if the assignment line is replaced by c=matmul(a,b), or if the
array dimensions are any smaller than 1024. Am I
missing something basic here? Thanks in advance.
0 Kudos
5 Replies
TimP
Honored Contributor III
729 Views
For a WAG, the compiler may be allocating a temporary result, before multiplying by 2. You may not have asked for additional stack space to allow for that temporary. Unfortunately, this seems a little inefficient, but not enough so to try to avoid it.
0 Kudos
cpmaster
Beginner
729 Views

program test
interface subtest
subroutine subtest(a)
real(8),dimension(:,:) :: a
end subroutine subtest
end interface
real(8), dimension(1024,1024) :: a
call subtest(a)
end program test

subroutine subtest(a)
real(8), dimension(:,:) :: a
OPEN(1,FILE='test.txt',FORM='unformatted')
WRITE(1) a
CLOSE(1)
end subroutine subtest


Fair enough. However, I also get a segv when I try to pass an array to a subroutine that writes the data to a file. This also only happens when the array dimensions are 1024 or more.
Is there a problem in passing "a" as an assumed-shape array?

Thanks, Cyrus
0 Kudos
TimP
Honored Contributor III
729 Views
I guess the question here also is why the compiler has to allocate a new copy of the array. When I look at the code generated by -S, the new copy is generated in subtest, and vectorization has to be turned on to make the copy code efficient.
There's more than meets the eye in this assumed-shape thing. People I work with who write production code avoid it, and compiler vendors aren't challenged to figure out whether it can be optimized.
0 Kudos
jtao
Beginner
729 Views
I am not sure if you already tried to set user resource limit to a bigger number. If not, you can trytosetthe stack size to unlimited to test things
out.
for bash: ulimit -s unlimitied
for (t)csh:limit -s unlimited
my 2c,
Jian
0 Kudos
cpmaster
Beginner
729 Views
Thanks, Jian, that remedied the problem.
0 Kudos
Reply