ecmwf-ifs / loki

Freely programmable source-to-source translation for Fortran
https://sites.ecmwf.int/docs/loki/
Apache License 2.0
29 stars 12 forks source link

Vector notation not removed when assignments moved into KLON loop #200

Open rolfhm opened 11 months ago

rolfhm commented 11 months ago

If you have something like

PZ(1:KLON, 1) = 0.

DO JLON = 1, KLON
  DO JLEV = 1, KLEV
    ....
  ENDDO
ENDDO

Running the pool_allocator transformation will give you something like

DO JLON = 1, KLON
  PZ(1:KLON, 1) = 0.
  DO JLEV = 1, KLEV
    ....
  ENDDO
ENDDO

I assume this has nothing to do with the pool_allocator and is due to the transformation that tries to merge jlon loops failing to replace the range index with a jlon? Small example can be found in ac_cloud_model2.F90 here: https://github.com/rolfhm/minimal_test/tree/pool_infinite_recursion

reuterbal commented 11 months ago

Hi Rolf, thanks for this, I share your assessment. I think what you need here is to apply the resolve_vector_notation utility as part of the housekeeping in the beginning: https://github.com/ecmwf-ifs/loki/blob/37d0033ea165985fb35cec2273067024af8e1e11/loki/transform/transform_array_indexing.py#L82

That should replace the vector notation by an explicit horizontal loop, and, as a consequence, then be handled correctly in the de- and re-vectorizing during SCC.

rolfhm commented 11 months ago

Should that routine be called by the transformation script for all transformations?