On Wed, Jun 22, 2016 at 10:56 AM, Michael Ferguson <[email protected]>
wrote:
>
> * Who decides whether it is SoA or AoS? The user, the
> compiler, or some runtime element?
>
>
I believe that Chapel requires the users to specify if they are using a
custom domain. I don't see a reason to change that.
> * For the SoA case, what will the domain map return as
> the type of an intermediate expression? This is the problem
> Mike was getting at. E.g.
>
> MyArray[i].x
>
> has 2 parts: the array access and then the field access.
> You might imagine that within the compiler it translates to:
>
> var tmp = MyArray[i];
> tmp.x
>
> Unless the compiler directly addresses the AoS -> SoA transformation,
> the array access has to be done first. If I were doing this in C++,
> I'd probably make an intermediate "pointer type" that MyArray[i]
> returns that only does the access in this case when you access
> the member. I think such an approach ought to be possible
> in Chapel but I'm pretty sure there are some missing pieces.
> (What are the missing pieces? I'm almost certain user-defined
> coercion would be necessary - which is something I have
> partial work on but hasn't risen to the top of the work list).
>
This is a good point. I'm not sure if I know how to resolve it. I included
a link to an intel article below, they have two structs in the example.
node is AoS and node1 is SoA. And NODES[x] is an array of nodes and NODES1
is an object of node1. It makes sense to write NODES[i].x, the same as
above. For NODES1, you would typically write it as NODES1.x[i]. Not sure if
that helps.
>
> * When is this kind of SoA vs AoS layout change important?
> How much performance potential is there to be gained by
> the optimization? What kinds of programs benefit?
>
>
When I think about how some programs benefit from a column order
representation over a row order for a matrix, I wouldn't think it would be
any different.
Intel has a good article on it:
https://software.intel.com/en-us/articles/memory-layout-transformations
I had first heard of the SoA vs. AoS pattern in game programming. In game
programming, sometimes you might have a struct with positions and then some
values, like health or something. Each object of this type represents some
game objects. So you have a bunch of the objects and you will need to
update them. It's often faster to have a struct of arrays in this case than
array of structs. I think it's related to how things get loaded on the
cache. Some guy (Jonathan Blow) is working on a language for game
programming that can allow the switch.
In a type of application that would be more relevant from Cray users, I
imagine you could make a struct representing a complex or rational data
type. Doing some operations on an array of these might be slower than doing
operations on a struct that contains arrays of each of the variables.
Of course, there is nothing stopping you from creating a struct of arrays
type customized for complex and rational variables. My point about domain
maps and changing the layout is that it would make it easier for users to
be able to make these decisions themselves. Maybe they aren't sure if
changing the representation would result in a speed-up. It's easier to just
change the domain map than it is write a whole new struct.
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users