Optimisation Past Subroutine Calls

Optimisation Past Subroutine Calls

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

5 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione
Best Reply

I would say no, because "sequence association" allows other_sub to access additional elements of the array.

Steve - Intel Developer Support

Citazione:

Steve Lionel (Intel) ha scritto:

I would say no, because "sequence association" allows other_sub to access additional elements of the array.

Thanks, I had forgotten about sequence association.

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

www.quickthreadprogramming.com

Jim, sure, but I think that is not the situation being asked about.

Steve - Intel Developer Support

Lascia un commento

Eseguire l'accesso per aggiungere un commento. Non siete membri? Iscriviti oggi