- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, Jian, that remedied the problem.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page