- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I face some difficulties with some optimizations performed by the ifort compiler.
If i write this subroutine : [fortran]
subroutine zmv (ia,ib,n)
C-------------------------------------------------------------------
C move the content of a table to another
C ib should be left of ia in memory
integer ia(*),ib(*),i,n
C
do i=1,N
ib(i)=ia(i)
enddo
return
end
[/fortran]
The thing is that using O3 option, ifort will replace my loop by a intel_fast_memcpy while nothing prevent me from doing this : [fortran]
program test
implicit none
integer i,n
parameter (n=10)
integer Z(n)
c Initialize the content of the array
do i=1,10
Z(i) = i
enddo
c Move the 6 to 10th value to the 3rd to 7th
call zmv(Z(6),Z(3),5)
c Print the result
write(*,'(99g)')(Z(i),i=1,n)
end
[/fortran]
As one can see, in the zmv subroutine call, the ia and ib array are overlapping (ib being left of ia). In this case, according to the C documentation, and as seen in a much more complicated exemple, nothing guarantee me that the copy will be correctly performed. A much safer way would have been to use memmove.
So I was wondering why ifort does this? Is my call to zmv subroutine somehow not compliant with fortran standard?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your program is not standards-compliant. zmv by itself is ok, but when combined with the call that causes overlap of the ia and ib arguments, you violate the rules against dummy aliasing. You could try compiling with -assume dummy_alias - that should disable this optimization.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your program is not standards-compliant. zmv by itself is ok, but when combined with the call that causes overlap of the ia and ib arguments, you violate the rules against dummy aliasing. You could try compiling with -assume dummy_alias - that should disable this optimization.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page