What is this structure called? Simply SoA?

人走茶凉 提交于 2019-12-11 12:43:19

问题


I've seen common comparisons made between the AoS (Array of Structures):

struct xyz
{
    ALIGNED float x, y, z, ignored;
};
ALIGNED struct xyz AoS[n];

And the SoA (Structure of Arrays):

struct SoA
{
    ALIGNED_AND_PADDED float x[n];
    ALIGNED_AND_PADDED float y[n];
    ALIGNED_AND_PADDED float z[n];
};

So what would this kind of data representation be called?

struct xyz4
{
    ALIGNED float x[4];
    ALIGNED float y[4];
    ALIGNED float z[4];
};
ALIGNED struct xyz4[n/4] ???;

A "cache-efficient SoA"? An AoSoA? An SoAoS? A "PITA to code"? It seems like the most efficient solution generally speaking, providing SoA-type SIMD with a lot of cache hits.


回答1:


That data structure has multiple names such as a Hybrid Structure of Arrays (see Extending a C-like Language for Portable SIMD Programming) or an array of struct of arrays (AoSoA).

AoS is not suitable for SIMD. SoA is an improvement but in some cases is still not sufficient. The solution is a Hybrid Structure of Arrays. It may be a PITA as you say but that's what you have to use sometimes if you want the highest efficient from SIMD (unless gather and scatter instructions become efficient).



来源:https://stackoverflow.com/questions/30022824/what-is-this-structure-called-simply-soa

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!