Loop unrolling + fusion ?

Claus Reinke claus.reinke at talk21.com
Wed Mar 18 20:43:04 EDT 2009

>> {-# INLINE f PEEL n UNROLL m #-}
> The problem here is that this only works for directly recursive  
> functions which I, for instance, don't normally use in high- 
> performance code. Most of my loops are pipelines of collective  
> combinators like map, filter, fold etc. because these are the ones  
> that can be fused automatically. Unless I'm misunderstanding  
> something, this approach doesn't handle such cases.

If the map, filter, fold, etc can be unrolled, then the unrolled
definitions would be fused, right? So what is missing is fine
control ("how much to unroll this particular call to map here").

Would it help to allow {-# INLINE map PEEL n UNROLL m #-}
in the caller modules as well as the definition modules, with the latter
providing a general case/upper limit, and the former providing finer
control? If you wanted even finer control, one would need a way to
specify named copies of inlineable recursion combinators, with
PEEL/UNROLL attached to the copies..

I see how this would need addressing, but I don't yet see a good
way to specify call-site-specific PEEL/UNROLL for recursion
combinators. Unless you want to control it by adding combinators
for the purpose?-)


More information about the Glasgow-haskell-users mailing list