<s>
In	O
computer	O
science	O
,	O
a	O
parallel	B-Operating_System
external	I-Operating_System
memory	I-Operating_System
(	O
PEM	O
)	O
model	O
is	O
a	O
cache-aware	O
,	O
external-memory	O
abstract	B-Application
machine	I-Application
.	O
</s>
<s>
It	O
is	O
the	O
parallel-computing	O
analogy	O
to	O
the	O
single-processor	O
external	B-Application
memory	I-Application
(	O
EM	O
)	O
model	O
.	O
</s>
<s>
In	O
a	O
similar	O
way	O
,	O
it	O
is	O
the	O
cache-aware	O
analogy	O
to	O
the	O
parallel	B-Operating_System
random-access	I-Operating_System
machine	I-Operating_System
(	O
PRAM	O
)	O
.	O
</s>
<s>
The	O
PEM	O
model	O
is	O
a	O
computation	O
model	O
which	O
consists	O
of	O
processors	O
and	O
a	O
two-level	O
memory	B-General_Concept
hierarchy	I-General_Concept
.	O
</s>
<s>
This	O
memory	B-General_Concept
hierarchy	I-General_Concept
consists	O
of	O
a	O
large	O
external	B-Application
memory	I-Application
(	O
main	O
memory	O
)	O
of	O
size	O
and	O
small	O
internal	O
memories	O
(	O
caches	O
)	O
.	O
</s>
<s>
Concurrent	B-Operating_System
Read	I-Operating_System
Concurrent	I-Operating_System
Write	I-Operating_System
(	O
CRCW	B-Operating_System
)	O
:	O
The	O
same	O
block	O
in	O
main	O
memory	O
can	O
be	O
read	O
and	O
written	O
by	O
multiple	O
processors	O
concurrently	O
.	O
</s>
<s>
Concurrent	B-Operating_System
Read	I-Operating_System
Exclusive	I-Operating_System
Write	I-Operating_System
(	O
CREW	O
)	O
:	O
The	O
same	O
block	O
in	O
main	O
memory	O
can	O
be	O
read	O
by	O
multiple	O
processors	O
concurrently	O
.	O
</s>
<s>
Exclusive	B-Operating_System
Read	I-Operating_System
Exclusive	I-Operating_System
Write	I-Operating_System
(	O
EREW	B-Operating_System
)	O
:	O
The	O
same	O
block	O
in	O
main	O
memory	O
cannot	O
be	O
read	O
or	O
written	O
by	O
multiple	O
processors	O
concurrently	O
.	O
</s>
<s>
The	O
following	O
two	O
algorithms	O
solve	O
the	O
CREW	O
and	O
EREW	B-Operating_System
problem	O
if	O
processors	O
write	O
to	O
the	O
same	O
block	O
simultaneously	O
.	O
</s>
<s>
The	O
multiway	O
partitioning	O
algorithm	O
(	O
PEM_DIST_SORT	O
)	O
uses	O
a	O
PEM	O
prefix	B-Application
sum	I-Application
algorithm	O
to	O
calculate	O
the	O
prefix	B-Application
sum	I-Application
with	O
the	O
optimal	O
I/O	O
complexity	O
.	O
</s>
<s>
This	O
algorithm	O
simulates	O
an	O
optimal	O
PRAM	O
prefix	B-Application
sum	I-Application
algorithm	O
.	O
</s>
<s>
Run	O
PEM	O
prefix	B-Application
sum	I-Application
on	O
the	O
set	O
of	O
vectors	O
simultaneously	O
.	O
</s>
<s>
Using	O
the	O
prefix	B-Application
sums	I-Application
stored	O
in	O
the	O
last	O
processor	O
P	O
calculates	O
the	O
vector	O
of	O
bucket	O
sizes	O
and	O
returns	O
it	O
.	O
</s>
<s>
The	O
selection	B-Algorithm
problem	I-Algorithm
is	O
about	O
finding	O
the	O
k-th	O
smallest	O
item	O
in	O
an	O
unordered	O
list	O
of	O
size	O
.	O
</s>
<s>
The	O
following	O
code	O
makes	O
use	O
of	O
PRAMSORT	O
which	O
is	O
a	O
PRAM	O
optimal	O
sorting	O
algorithm	O
which	O
runs	O
in	O
,	O
and	O
SELECT	O
,	O
which	O
is	O
a	O
cache	O
optimal	O
single-processor	O
selection	B-Algorithm
algorithm	I-Algorithm
.	O
</s>
