Home Neural Network Solved: frequent variable handed as argument of perform is overoptimized

Solved: frequent variable handed as argument of perform is overoptimized

0
Solved: frequent variable handed as argument of perform is overoptimized

[ad_1]

The next 4 information compiled with ifx 2023.2.0 (ifx (IFX) 2023.2.0 20230622), offers completely different solutions with out and with optimization:

==> alloc.f90 <==

integer perform alloc(n)
  use common_mod
  integer n
  alloc = imem + n
  imem = imem + n
finish perform alloc

==> frequent.f90 <==

module common_mod
  frequent/actmem/imem
  integer imem
finish module common_mod

==> predominant.f90 <==

program predominant
  frequent/actmem/imem
  integer imem
  imem=0
  name check(imem)
finish program predominant

==> check.f90 <==

subroutine check(imem)
  integer :: res
  print *, imem
  res = alloc(8)
  print *, imem
finish subroutine check

 Compilation & execution:

$ ifx frequent.f90 alloc.f90 check.f90 predominant.f90 -O0 && ./a.out
           0
           8
$ ifx frequent.f90 alloc.f90 check.f90 predominant.f90 -O1 && ./a.out
           0
           0

With ifort (ifort (IFORT) 2021.10.0 20230609) it really works positive at any stage of optimisation. 

Doable answer is to make imem in check routine unstable. Then, with ifx the code works positive.

[ad_2]