Example 3-16 Aos And Soa Code Samples - Intel ARCHITECTURE IA-32 Reference Manual

Architecture optimization
Table of Contents

Advertisement

IA-32 Intel® Architecture Optimization
SoA Data Structure
Example 3-15
typedef struct{
float x[NumOfVertices];
float y[NumOfVertices];
float z[NumOfVertices];
int a[NumOfVertices];
int b[NumOfVertices];
int c[NumOfVertices];
. . .
} VerticesList;
VerticesList Vertices;
There are two options for computing data in AoS format: perform
operation on the data as it stands in AoS format, or re-arrange it (swizzle
it) into SoA format dynamically. See Example 3-16 for code samples of
each option based on a dot-product computation.

Example 3-16 AoS and SoA Code Samples

; The dot product of an array of vectors (Array) and a
; fixed vector (Fixed) is a common operation in 3D
; lighting operations,
;
where Array = (x0,y0,z0),(x1,y1,z1),...
;
; A dot product is defined as the scalar quantity
;
; AoS code
; All values marked DC are "don't-care."
; In the AOS model, the vertices are stored in the
; xyz format
movaps
movaps
mulps
movhlps xmm1, xmm0
3-28
and Fixed = (xF,yF,zF)
d0 = x0*xF + y0*yF + z0*zF.
xmm0, Array
xmm1, Fixed
xmm0, xmm1
; xmm0 = DC, x0,
; xmm1 = DC, xF,
; xmm0 = DC, x0*xF, y0*yF, z0*zF
; xmm1 = DC, DC,
y0,
z0
yF,
zF
DC,
x0*xF
continued

Advertisement

Table of Contents
loading

Table of Contents