futhark-0.19.5: An optimising compiler for a functional, array-oriented language.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Futhark.Optimise.Fusion.Composing

Description

Facilities for composing SOAC functions. Mostly intended for use by the fusion module, but factored into a separate module for ease of testing, debugging and development. Of course, there is nothing preventing you from using the exported functions whereever you want.

Important: this module is "dumb" in the sense that it does not check the validity of its inputs, and does not have any functionality for massaging SOACs to be fusible. It is assumed that the given SOACs are immediately compatible.

The module will, however, remove duplicate inputs after fusion.

Synopsis

Documentation

fuseMaps Source #

Arguments

:: Bindable lore 
=> Names

The producer var names that still need to be returned

-> Lambda lore

Function of SOAC to be fused.

-> [Input]

Input of SOAC to be fused.

-> [(VName, Ident)]

Output of SOAC to be fused. The first identifier is the name of the actual output, where the second output is an identifier that can be used to bind a single element of that output.

-> Lambda lore

Function to be fused with.

-> [Input]

Input of SOAC to be fused with.

-> (Lambda lore, [Input])

The fused lambda and the inputs of the resulting SOAC.

fuseMaps lam1 inp1 out1 lam2 inp2 fuses the function lam1 into lam2. Both functions must be mapping functions, although lam2 may have leading reduction parameters. inp1 and inp2 are the array inputs to the SOACs containing lam1 and lam2 respectively. out1 are the identifiers to which the output of the SOAC containing lam1 is bound. It is nonsensical to call this function unless the intersection of out1 and inp2 is non-empty.

If lam2 accepts more parameters than there are elements in inp2, it is assumed that the surplus (which are positioned at the beginning of the parameter list) are reduction (accumulator) parameters, that do not correspond to array elements, and they are thus not modified.

The result is the fused function, and a list of the array inputs expected by the SOAC containing the fused function.

fuseRedomap :: Bindable lore => Names -> [VName] -> Lambda lore -> [SubExp] -> [SubExp] -> [Input] -> [(VName, Ident)] -> Lambda lore -> [SubExp] -> [SubExp] -> [Input] -> (Lambda lore, [Input]) Source #

mergeReduceOps :: Lambda lore -> Lambda lore -> Lambda lore Source #