DSM1
DSM1
July-15-2009
Gerd Liefländer
System Architecture Group
Motivation
Why DSM? (compare: why shared memory in local systems?)
Some programmers want one programming concept
for distributed applications without all this IPC stuff
What’s easier?
Sharing data no longer requires explicit IPC (even
though a DSM is based upon IPC)
History has shown: Distributed applications based on
application IPCs tend to have more program bugs
and have larger code than DSM applications
Shared memory was fastest collaboration in local
systems, as long as there are only few conflicting
operations
© 2009 Universität Karlsruhe, System Architecture Group
6
Why DSM?
Better portability of distributed application programs
Natural transition from sequential to distributed application
Better performance of some applications
Data locality, on-demand data movement, and larger RAMs
reduce network traffic due to remote paging
However, ping-pong
ping pong paging due to false sharing etc. must
be avoided
Architecture of a DSM
CPU CPU
DSM1 DSMk
Local Local
Memory Memory
CPU CPU
3 mapped
shared
6 9 memory
3 6 9 DSM
Communication Network
Granularity Problem
1. False sharing
Object O1
2. Thrashing (due to ping-pong)
Object O2
... Object O3
byte variable object 0.5 KB page 64 KB ..
© 2009 Universität Karlsruhe, System Architecture Group
20
Granularity in a Page-Based DSM
Typical standard page size 4 KB might be too small to
host a typical shared data object
However, using super pages might not pay off
Migrating a super page requires bandwidth and it might be
difficult, to find a fitting memory hole for the super page
Furthermore, the larger the super page size the larger the
potential internal fragmentation
In a DS there are some applications that might run
faster when using smaller than 4KB pages
A 4 KB page might contain too many different objects
false sharing, i.e. the ping-pong paging effect due
to conflicting activities at different nodes
p1 p2
write(a,10)
( , )
a9
p1 p2
write(a,10)
a 10
9
p1 p2
write(a,10)
write(a,11)
( , )
a 10
p1 p2
write(a,10)
write(a,11)
( , )
a 11
p1 p2
write(a,10)
write(b,11)
5 9
p1 p2
read(a)
write(a,11)
( , )
A B C
page n page
p g n+1
if(a=7) then
a := 7;
b := b+1;
b := 7; ...
if(b=8) then
print("after"); updates
time
time
if(b=a) then
print("before");
time
new copy
2. Replicate block
3. Update block
3. Update block
1. Request block
a copy of a copy of
new copy new copy
block new copy
block block
new copy
2. Replicate block
3. Invalidate block
3. Invalidate block
1. Request block
a copy of a copy of
block
block block
Remote access:
Presence bit in local PFT is empty
Remote access page fault
Pager gets page from remote node
Set presence bit
Repeat memory access
DSM is coherent if
Page transfer operations are atomic
No node crashed occur
© 2009 Universität Karlsruhe, System Architecture Group
41
Single Copy DSM
False Sharing
2 data objects in the same page used by different activities
Mutual page stealing when threads write to that page
Whenever
h some node
d Lj tries to write to page P
Copy P from the replica with TRW == 1, which must be the
one with the most recent writes
Invalidate all replicas, i.e. delete their PFT entries & empty the
corresponding mapped page-frame.
If there is no such replica with TRW==1 all replicas (also
your local one) are identical and up to date
Set local TRW = 1 and repeat your write operation at Lj
commit invalidation
Implementation
Write operations have to be visible in all processes in the
same order
Duration of a write
Example: Forge the latest write in the next write
Add an owner flag per PFT entry
Duplicate
x cache x cache b m cache
x a m
memory memory memory
y b n
Unused
Read
(Read a copy from the onwer)
Replacement
Replacement
Replacement
Replacement
Write invalidate Nil
Read only
Read
(Read from memory and get an ownership)
Write Write invalidate
Write (invalidate others if they have a copy
(invalidate others if they have a copy and get an ownership)
and get an ownership)
Write invalidate
0 P0 3 P1 6 P2
1 P0 4 P2 7 P1
2 P2 5 P0 8 P2
Read request
Addr0 Addr3 Addr2
writable read owned read owned
Addr2 Addr8
read only read owned
Addr2
read owned
br := b; a := a + 1;
ar := a; b := b + 1;
if(ar ≥ br) then
print ("OK");
W2(x, a) W2(x, a)
aR1(x) nilR1(x)
P1 P2 P3
Acq1(L)
W1(x, a)
W1(x, b)
Rel1(L)
Acq2(L)
bR2(x)
bR2(x)
Rel2(L) aR3(x)