C

These terms describe the different ways in which data are located in memory, which is important for https://ru.wikipedia.org/wiki/SIMD (Single Instruction, Multiple Data) is a computing principle of parallelism in which one team applies to a large number of data.AOS Array of Structs, a set of structures. I mean, a structure is defined with the contents of one element, and it creates a set of gifts:struct point3D {
float x;
float y;
float z;
};
struct point3D points[N];
// соответственно, для обращения к конкретному элементу
// обращаемся к соответствующей структуре из массива:
float get_point_x(int i) { return points[i].x; }
It looks like a number of XYZs.x0, y0, z0, x1, y1, z1, ... xn-1, yn-1, zn-1
This method is very simple for the developer (i.e. a set of structures can be created anywhere in the programme), but not very effective in SIMD.SOA Struct of Arrays, structure with masses. I mean, a structure containing data sets is defined:struct pointlist3D {
float x[N];
float y[N];
float z[N];
};
struct pointlist3D points;
// для обращения к конкретному элементу
// обращаемся к массиву значений в структуре:
float get_point_x(int i) { return points.x[i]; }
Thus, the values of one type and meaning are shared. In memory, it looks like:x0, x1, ... xn-1, y0, y1, ... yn-1, z0, z1, ... zn-1
For SIMD, this approach is much more effective, but not very effective for developers, because the structure needs to be known at the compilation stage.SOS Struct of Structs, structure with structures. This method is designed to combine the AOS convenience and SOA speed by grouping one-time data into a given size unit (in general, it can be called AOSOA, a set of structures with masses):struct point3Dx4 {
float x[N];
float y[N];
float z[N];
};
struct point3Dx4 points[(N+3)/4]; // для округления в большую сторону
// здесь обращение чуть более сложное:
float get_point_x(int i) { return points[i/4].x[i%4]; }
In memory, it looks like:x0, x1, x2, x3, y0, y1, y2, y3, ... yn-4, yn-3, yn-2, yn-1, zn-4, zn-3, zn-2, zn-1
Based on https://en.wikipedia.org/wiki/AOS_and_SOA