<s>
In	O
computing	O
,	O
an	O
array	B-General_Concept
of	I-General_Concept
structures	I-General_Concept
(	O
AoS	O
)	O
,	O
structure	B-General_Concept
of	I-General_Concept
arrays	I-General_Concept
(	O
SoA	O
)	O
or	O
array	B-General_Concept
of	I-General_Concept
structures	I-General_Concept
of	O
arrays	O
(	O
AoSoA	O
)	O
are	O
contrasting	O
ways	O
to	O
arrange	O
a	O
sequence	O
of	O
records	O
in	O
memory	B-General_Concept
,	O
with	O
regard	O
to	O
interleaving	B-General_Concept
,	O
and	O
are	O
of	O
interest	O
in	O
SIMD	B-Device
and	O
SIMT	B-General_Concept
programming	O
.	O
</s>
<s>
Structure	B-General_Concept
of	I-General_Concept
arrays	I-General_Concept
(	O
SoA	O
)	O
is	O
a	O
layout	O
separating	O
elements	O
of	O
a	O
record	O
(	O
or	O
'	O
struct	O
 '	O
in	O
the	O
C	B-Language
programming	I-Language
language	I-Language
)	O
into	O
one	O
parallel	B-Data_Structure
array	I-Data_Structure
per	O
field	B-Application
.	O
</s>
<s>
The	O
motivation	O
is	O
easier	O
manipulation	O
with	O
packed	O
SIMD	B-Device
instructions	O
in	O
most	O
instruction	B-General_Concept
set	I-General_Concept
architectures	I-General_Concept
,	O
since	O
a	O
single	O
SIMD	B-Device
register	O
can	O
load	O
homogeneous	O
data	O
,	O
possibly	O
transferred	O
by	O
a	O
wide	O
internal	O
datapath	O
(	O
e.g.	O
</s>
<s>
The	O
downside	O
is	O
requiring	O
more	O
cache	O
ways	O
when	O
traversing	O
data	O
,	O
and	O
inefficient	O
indexed	B-Language
addressing	I-Language
.	O
</s>
<s>
For	O
example	O
,	O
to	O
store	O
N	O
points	O
in	O
3D	O
space	O
using	O
a	O
structure	B-General_Concept
of	I-General_Concept
arrays	I-General_Concept
:	O
</s>
<s>
Array	B-General_Concept
of	I-General_Concept
structures	I-General_Concept
(	O
AoS	O
)	O
is	O
the	O
opposite	O
(	O
and	O
more	O
conventional	O
)	O
layout	O
,	O
in	O
which	O
data	O
for	O
different	O
fields	O
is	O
interleaved	O
.	O
</s>
<s>
For	O
example	O
,	O
to	O
store	O
N	O
points	O
in	O
3D	O
space	O
using	O
an	O
array	B-General_Concept
of	I-General_Concept
structures	I-General_Concept
:	O
</s>
<s>
Array	B-General_Concept
of	I-General_Concept
structures	I-General_Concept
of	O
arrays	O
(	O
AoSoA	O
)	O
or	O
tiled	O
array	O
of	O
structs	O
is	O
a	O
hybrid	O
approach	O
between	O
the	O
previous	O
layouts	O
,	O
in	O
which	O
data	O
for	O
different	O
fields	O
is	O
interleaved	O
using	O
tiles	O
or	O
blocks	O
with	O
size	O
equal	O
to	O
the	O
SIMD	B-Device
vector	O
size	O
.	O
</s>
<s>
This	O
is	O
often	O
less	O
intuitive	O
,	O
but	O
can	O
achieve	O
the	O
memory	B-General_Concept
throughput	O
of	O
the	O
SoA	O
approach	O
,	O
while	O
being	O
more	O
friendly	O
to	O
the	O
cache	B-General_Concept
locality	I-General_Concept
and	O
load	O
port	O
architectures	O
of	O
modern	O
processors	O
.	O
</s>
<s>
In	O
particular	O
,	O
memory	B-General_Concept
requests	O
in	O
modern	O
processors	O
have	O
to	O
be	O
fulfilled	O
in	O
fixed	O
width	O
(	O
e.g.	O
,	O
size	O
of	O
a	O
cacheline	O
)	O
.	O
</s>
<s>
The	O
tiled	O
storage	O
of	O
AoSoA	O
aligns	O
the	O
memory	B-General_Concept
access	O
pattern	O
to	O
the	O
requests	O
 '	O
fixed	O
width	O
,	O
leading	O
to	O
fewer	O
access	O
operations	O
to	O
complete	O
a	O
memory	B-General_Concept
request	O
and	O
thus	O
increasing	O
the	O
efficiency	O
.	O
</s>
<s>
For	O
example	O
,	O
to	O
store	O
N	O
points	O
in	O
3D	O
space	O
using	O
an	O
array	B-General_Concept
of	I-General_Concept
structures	I-General_Concept
of	O
arrays	O
with	O
a	O
SIMD	B-Device
register	O
width	O
of	O
8	O
floats	B-Algorithm
(	O
or	O
8×32	O
=	O
256	O
bits	O
)	O
:	O
</s>
<s>
A	O
different	O
width	O
may	O
be	O
needed	O
depending	O
on	O
the	O
actual	O
SIMD	B-Device
register	O
width	O
.	O
</s>
<s>
The	O
interior	O
arrays	O
may	O
be	O
replaced	O
with	O
SIMD	B-Device
types	O
such	O
as	O
for	O
languages	O
with	O
such	O
support	O
.	O
</s>
<s>
It	O
is	O
possible	O
to	O
split	O
some	O
subset	O
of	O
a	O
structure	O
(	O
rather	O
than	O
each	O
individual	O
field	B-Application
)	O
into	O
a	O
parallel	B-Data_Structure
array	I-Data_Structure
and	O
this	O
can	O
actually	O
improve	O
locality	B-General_Concept
of	I-General_Concept
reference	I-General_Concept
if	O
different	O
pieces	O
of	O
fields	O
are	O
used	O
at	O
different	O
times	O
in	O
the	O
program	O
(	O
see	O
data	O
oriented	O
design	O
)	O
.	O
</s>
<s>
Some	O
SIMD	B-Device
architectures	O
provide	O
strided	O
load/store	B-General_Concept
instructions	I-General_Concept
to	O
load	O
homogeneous	O
data	O
from	O
the	O
SoA	O
format	O
.	O
</s>
<s>
Yet	O
another	O
option	O
used	O
in	O
some	O
Cell	B-General_Concept
libraries	O
is	O
to	O
de-interleave	O
data	O
from	O
the	O
AoS	O
format	O
when	O
loading	O
sources	O
into	O
registers	O
,	O
and	O
interleave	O
when	O
writing	O
out	O
results	O
(	O
facilitated	O
by	O
the	O
superscalar	O
issue	O
of	O
permutes	O
)	O
.	O
</s>
<s>
Some	O
vector	O
maths	O
libraries	O
align	O
floating	B-Algorithm
point	I-Algorithm
4D	O
vectors	O
with	O
the	O
SIMD	B-Device
register	O
to	O
leverage	O
the	O
associated	O
data	O
path	O
and	O
instructions	O
,	O
while	O
still	O
providing	O
programmer	O
convenience	O
,	O
although	O
this	O
does	O
not	O
scale	O
to	O
SIMD	B-Device
units	O
wider	O
than	O
four	O
lanes	O
.	O
</s>
<s>
AoS	O
vs.	O
SoA	O
presents	O
a	O
choice	O
when	O
considering	O
3D	O
or	O
4D	O
vector	O
data	O
on	O
machines	O
with	O
four-lane	O
SIMD	B-Device
hardware	O
.	O
</s>
<s>
SIMD	B-Device
ISAs	O
are	O
usually	O
designed	O
for	O
homogeneous	O
data	O
,	O
however	O
some	O
provide	O
a	O
dot	O
product	O
instruction	O
and	O
additional	O
permutes	O
,	O
making	O
the	O
AoS	O
case	O
easier	O
to	O
handle	O
.	O
</s>
<s>
Although	O
most	O
GPU	B-Architecture
hardware	O
has	O
moved	O
away	O
from	O
4D	O
instructions	O
to	O
scalar	O
SIMT	B-General_Concept
pipelines	O
,	O
modern	O
compute	B-Operating_System
kernels	I-Operating_System
using	O
SoA	O
instead	O
of	O
AoS	O
can	O
still	O
give	O
better	O
performance	O
due	O
to	O
memory	B-General_Concept
coalescing	O
.	O
</s>
<s>
SoA	O
is	O
mostly	O
found	O
in	O
languages	O
,	O
libraries	O
,	O
or	O
metaprogramming	B-Application
tools	O
used	O
to	O
support	O
a	O
data-oriented	O
design	O
.	O
</s>
<s>
The	O
SIMD-oriented	O
features	O
of	O
the	O
experimental	O
Jai	O
programming	O
language	O
is	O
a	O
recent	O
attempt	O
to	O
provide	O
language	O
level	O
SoA	O
support	O
.	O
</s>
<s>
"	O
Data	O
frames	O
,	O
"	O
as	O
implemented	O
in	O
R	B-Language
,	O
Python	B-Language
's	O
Pandas	O
package	O
,	O
and	O
Julia	B-Application
's	O
DataFrames.jl	O
package	O
,	O
are	O
interfaces	O
to	O
access	O
SoA	O
like	O
AoS	O
.	O
</s>
<s>
The	O
Julia	B-Application
package	O
StructArrays.jl	O
allows	O
for	O
accessing	O
SoA	O
as	O
AoS	O
to	O
combine	O
the	O
performance	O
of	O
SoA	O
with	O
the	O
intuitiveness	O
of	O
AoS	O
.	O
</s>
<s>
Code	O
generators	O
for	O
the	O
C	B-Language
language	I-Language
,	O
including	O
and	O
the	O
X	B-Language
Macro	I-Language
technique	O
.	O
</s>
<s>
An	O
example	O
of	O
AoSoA	O
in	O
metaprogramming	B-Application
is	O
found	O
in	O
LANL	O
's	O
Cabana	O
library	O
written	O
in	O
C++	O
;	O
it	O
assumes	O
a	O
vector	O
width	O
of	O
16	O
lanes	O
by	O
default	O
.	O
</s>
