stfc / PSyclone

Domain-specific compiler and code transformation system for Finite Difference/Volume/Element Earth-system models in Fortran
BSD 3-Clause "New" or "Revised" License
104 stars 27 forks source link

Add UnrolledLoop transformation to ArrayAssignment2LoopsTrans: ArrayAssignment2UnrolledLoopsTrans #2731

Open hbrunie opened 4 hours ago

hbrunie commented 4 hours ago

@sergisiso @arporter , our Poseidon uplifter works well with simplified Kernel: Perfectly Nested loop with "simple" assignments inside.

Some of FlashX code (and probably other out there like Nemo) use a lot of arrays notations. These notations can be transformed to simple Loop with the PsyIR ArrayAssignment2LoopsTrans, nevertheless, this adds some loops inside of a nice well defined Kernel.

Thus I thought of extending this transformation. This could be a new one just wrapping the first one and unrolling the loop. Indeed in this case we know where this loop comes from and it seems safe to unroll it.

Tell me if such a transformation would be useful elsewhere. Cheers, Hugo

hbrunie commented 4 hours ago

I just ran into a more complex case where the array bounds are not known at compile time. So not sure if this transformation would be useful in many cases ... In FlashX they do: integer, dimension(3), intent(in) :: logc real, dimension(logc(3):,:,logc(1):,logc(2):), intent(inout) :: uin