- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
This might be a silly question, but I can't seem to decide on the answer myself. Is a compiler allowed to optimise past a call to a subroutine? For example, consider this:
subroutine sub ( l, r ) real(8), intent(inout) :: l(*), r(*) l(2) = 2.0_8 call other_sub(l(1), r(1)) l(2) = r(2) end subroutine sub
Is the compiler allowed to remove the first assignment, since other_sub is called with only the first elements of the arrays?
I'm most considering the case when there's no interface for other_sub. I often see calls like this for MPI calls in some of our old code, passing the first element of an array section as the buffer with a non-unit buffer size. I'm worried this might eventually break things if extra optimisations are used.
Cheers,
Ben
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would say no, because "sequence association" allows other_sub to access additional elements of the array.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would say no, because "sequence association" allows other_sub to access additional elements of the array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve Lionel (Intel) wrote:
I would say no, because "sequence association" allows other_sub to access additional elements of the array.
Thanks, I had forgotten about sequence association.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
With IPO enabled, and where the source to other_sub is discoverable (and can be inlined), the compiler optimization code should be able to see if there are any dependencies on the l(2) = 2.0_8, and if none, remove the unnecessary statement.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jim, sure, but I think that is not the situation being asked about.

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