futhark-0.11.0: An optimising compiler for a functional, array-oriented language.

Safe HaskellNone
LanguageHaskell2010

Futhark.Optimise.DoubleBuffer

Description

The simplification engine is only willing to hoist allocations out of loops if the memory block resulting from the allocation is dead at the end of the loop. If it is not, we may cause data hazards.

This module rewrites loops with memory block merge parameters such that each memory block is copied at the end of the iteration, thus ensuring that any allocation inside the loop is dead at the end of the loop. This is only possible for allocations whose size is loop-invariant, although the initial size may differ from the size produced by the loop result.

Additionally, inside parallel kernels we also copy the initial value. This has the effect of making the memory block returned by the array non-existential, which is important for later memory expansion to work.

Documentation