- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
I would say no, because "sequence association" allows other_sub to access additional elements of the array.
Link kopiert
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
I would say no, because "sequence association" allows other_sub to access additional elements of the array.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Jim, sure, but I think that is not the situation being asked about.

- RSS-Feed abonnieren
- Thema als neu kennzeichnen
- Thema als gelesen kennzeichnen
- Diesen Thema für aktuellen Benutzer floaten
- Lesezeichen
- Abonnieren
- Drucker-Anzeigeseite