AutoSynch
An Automatic-Signal Monitor Based on Predicate Tagging Wei-Lun Hung
wlhung@utexas.edu
Vijay K. Garg
garg@ece.utexas.edu
Parallel and Distributed Systems Laboratory Department of Electrical & Computer Engineering
PLDI 2013
AutoSynch An Automatic-Signal Monitor Based on Predicate Tagging - - PowerPoint PPT Presentation
AutoSynch An Automatic-Signal Monitor Based on Predicate Tagging Vijay K. Garg Wei-Lun Hung garg@ece.utexas.edu wlhung@utexas.edu Parallel and Distributed Systems Laboratory Department of Electrical & Computer Engineering PLDI 2013
wlhung@utexas.edu
garg@ece.utexas.edu
Parallel and Distributed Systems Laboratory Department of Electrical & Computer Engineering
PLDI 2013
1
2
3
4
PLDI 2013 1 / 31
takePtr putPtr count = 4
PLDI 2013 2 / 31
PLDI 2013 3 / 31
PLDI 2013 3 / 31
PLDI 2013 4 / 31
PLDI 2013 5 / 31
PLDI 2013 6 / 31
PLDI 2013 7 / 31
PLDI 2013 8 / 31
1 public AutoSynch class BoundedBuffer { 2
Object[] buff;
3
int putPtr, takePtr, count;
4
public BoundedBuffer(int n) {
5
buff = new Object[n];
6
putPtr = takePtr = count = 0 ;
7
}
8
public Object take() {
9
waituntil (count > 0);
10
Object ret = buff[takePtr++];
11
takePtr %= buff.length;
12
count--;
13
}
14 } 1 public class BoundedBuffer { 2
Object[] buff;
3
int putPtr, takePtr, count;
4
Lock mutex = new ReentrantLock();
5
Condition full = mutex.newCondition();
6
Condition empty = mutex.newCondition();
7
public BoundedBuffer(int n) {
8
buff = new Object[n];
9
putPtr = takePtr = count = 0;
10
}
11
public Object take() {
12
mutex.lock();
13
while (count == 0) {
14
empty.await();
15
}
16
Object ret = buff[takePtr++];
17
takePtr %= buff.length;
18
count--;
19
if (count == buff.length - 1) {
20
full.signalAll();
21
}
22
mutex.unlock();
23
}
24 } PLDI 2013 9 / 31
PLDI 2013 10 / 31
PLDI 2013 11 / 31
C1
buff.length = 64 count = 24 waituntil (count >= numi) waituntil (itemsi.length + count <= buff.length)
num1 = 32
items0.length = 18
C2 num2 = 40 P0 C3 C4
local variable shared variable condition waiting queue
PLDI 2013 12 / 31
PLDI 2013 13 / 31
PLDI 2013 13 / 31
PLDI 2013 13 / 31
AutoSynch Java Library AutoSynch Preprocessor AutoSynch Code Java Code Standard Java Compiler Java Bytecode
PLDI 2013 14 / 31
1
2
3
4
PLDI 2013 15 / 31
C1
buff.length = 64 count = 24 waituntil (count >= numi) waituntil (itemsi.length + count <= buff.length)
num1 = 32
items0.length = 18
C2 num2 = 40 P0 C3 C4
PLDI 2013 16 / 31
C1
buff.length = 64 count = 24 waituntil (count >= num1) items0.length = 18
C2 P0 C3 C4
waituntil (count >= num2) Replace local variables with the values at runtime
PLDI 2013 16 / 31
C1
buff.length = 64 count = 24 waituntil (count >= 32) items0.length = 18
C2 P0 C3 C4
waituntil (count >= 40) Replace local variables with the values at runtime
PLDI 2013 16 / 31
C1
buff.length = 64 count = 42 waituntil (count >= 32)
C2 P0 C3 C4
waituntil (count >= 40) The thread (P0) owning a monitor performs predicate evaluations for other threads (C1 and C2) before leaving Put 18 items
PLDI 2013 16 / 31
1
2
3
4
PLDI 2013 17 / 31
C1
buff.length = 64 count = 42 waituntil (count >= 32)
C2 P0 C3 C4
waituntil (count >= 40)
PLDI 2013 18 / 31
C1
buff.length = 64 count = 42 waituntil (count >= 32)
C2 P0 C3 C4
waituntil (count >= 40)
PLDI 2013 18 / 31
C1
buff.length = 64 count = 10
C2 C3 C4
Take 32 items
PLDI 2013 18 / 31
C2
buff.length = 64 count = 10
C3 C4
count < 40
PLDI 2013 18 / 31
buff.length = 64 count = 10
C2 C3 C4
waituntil (count >= 40)
PLDI 2013 18 / 31
PLDI 2013 19 / 31
PLDI 2013 19 / 31
1
2
3
4
PLDI 2013 20 / 31
1
2
3
PLDI 2013 21 / 31
◮ ((x < 5) ∧ (y = 3)) ◮ ((x > 5) ∧ foo1()) ◮ foo2()
PLDI 2013 22 / 31
PLDI 2013 23 / 31
PLDI 2013 23 / 31
PLDI 2013 23 / 31
PLDI 2013 23 / 31
PLDI 2013 23 / 31
PLDI 2013 23 / 31
PLDI 2013 23 / 31
PLDI 2013 23 / 31
PLDI 2013 24 / 31
PLDI 2013 25 / 31
7.5 15 22.5 30 2 4 8 16 32 64 128 256 runtime (seconds) # consumers/producers
Explicit AutoSynch AutoSynch-T Baseline
75 150 225 300 2 4 8 16 32 64 128 256 runtime (seconds) # consumers/producers
Explicit AutoSynch AutoSynch-T Baseline
PLDI 2013 26 / 31
7.5 15 22.5 30 2 4 8 16 32 64 128 256 runtime (seconds) # threads
Explicit AutoSynch AutoSynch-T
7.5 15 22.5 30 2/10 4/20 8/40 16/80 32/160 64/320 runtime (seconds) # threads
Explicit AutoSynch AutoSynch-T
PLDI 2013 27 / 31
3.75 7.5 11.25 15 2 4 8 16 32 64 128 256 runtime (seconds) # consumers
Explicit AutoSynch 750 1500 2250 3000 2 4 8 16 32 64 128 256 # context swiches (× 1000) # consumers Explicit AutoSynch
PLDI 2013 28 / 31
PLDI 2013 29 / 31
1 2 3 4 1000 2000 3000 4000 5000 runtime (seconds) # delay time (microseconds)
Explicit AutoSynch AutoSynch-T
0.75 1.5 2.25 3 1000 2000 3000 4000 5000 runtime (seconds) # delay time microseconds
Explicit AutoSynch AutoSynch-T
PLDI 2013 30 / 31
PLDI 2013 31 / 31