Data-oriented programming and the vectorisation transformation

I just realised that the data layout and the resulting code organisation in data-oriented programming, as proposed for games design, in many aspects resembles the data layout and code organisation favoured by the vectorisation transformation that is at the core of Data Parallel Haskell.  This should not be surprising as both have similar goals, namely to maximise data throughput, to minimise stalls by utilising the memory hierarchy, and to maximise parallelism.

However, the parallels are interesting given the very different origins of both approaches.  The big difference is of course that data-oriented programming is a design methodology for programmers, whereas the vectorisation transformation is a program transformation automatically applied by a compiler.  Nevertheless, we may regard the vectorisation transformation as a program transformation that turns purely functional code into code that is structured in a data-oriented manner, where the layout of bulk data shapes the organisation of the code.

This raises the question of how useful nested data parallel programming and the vectorisation transformation may be to games programming.

Loading mentions Retweet
Posted 29 days ago

5 comments

Oct 26, 2009
Paul Bone said...
I've been programming with CUDA recently, and having read your work on DpH I noticed that in order to get coalesced memory accesses in CUDA you have to transform your data structures in a very similar way to the transformation DpH uses for parallel arrays of structures, for example [:(a, b):] -> ([:a:], [:b:]).

This and other optimisations for CUDA make me think that the best way to write for CUDA is by compiling from a higher level language such as DpH), which I believe is a work-in-progress.

Good work.

Oct 26, 2009
Paul, yes, we perform that transformation —turning arrays of pairs into pairs of arrays— also in our work-in-progress embedded array language for GPUs: http://hackage.haskell.org/package/accelerate

Accelerate is less ambitious as DPH in the range of programs being parallelised, but it is more ambitious in the targeted hardware. DPH on GPUs is a longer-term goal (we want it to work well on multicore CPUs first), though it may get easier with the new Fermi architecture that NVIDIA recently announced (which among other things appears to support function pointers in GPUs kernels).

Oct 26, 2009
Paul Bone said...
Hrm, I hadn't heard of Accelerate, I'll check it out. Nor have I heard of Fermi.

Thanks.

Oct 26, 2009
There is an overview over Fermi on NVIDIA's website: http://www.nvidia.com/object/fermi_architecture.html
Oct 27, 2009
Sam Martin said...
It's a parallel that hasn't gone unnoticed! Very interesting stuff.

Leave a comment...

 
Got an account with one of these? Login here, or just enter your comment below.
Posterous-login    Connect    twitter