Title: Architectural Semantics for Practical Transactional Memory Austen McDonald, et al. International Sym
1Architectural Semantics for Practical
Transactional MemoryAusten McDonald, et
al.International Symposium on Computer
Architecture (ISCA-33), Boston, MA, June 2006
- Goal provide ISA for existing HTMs that enables
- flexible nestingsubsumption hurts performance
when libraries use transactions - sw contention error managemente.g. allow
different conflict policies for different nesting
levels, or enable softwarae to see the state for
debug/error handling before rolling back the
transaction - conditional synchronizationuse transactions for
producer/consumer barriers as well as mutual
exclusion - system calls, i/o, runtime exceptions within
transactions - Approach
- two-phase commit
- commit, violation, and abort handlers
- closed open nested transactions
2Two-Phase Commit
- Semantics
- xvalidateverify that there were no conflicts
mark the xaction as validated - xcommitmark the xaction as committed make its
writes visible to shared memory - (in between xvalidate xcommit)can see
speculative state thread-private dataaccesses
to shared data should be wrapped within
open-nested xactions - Use
- commit handler inserted in between by
compiler/runtimee.g. finalize system calls
I/O, coordinate with other code before committing
(e.g. error checking code)
3Handlers
- General
- handler stack in thread-private memoryarbitrary
number of handlers, each with arbitrary number of
arguments, all pushed onto the stack - register with handler code to callresponsible
for calling all handlers - Commit Handlers
- executed between xvalidate xcommit
- enable sw to finalize tasks at commite.g.
syscalls with permanent side effects execute as
commit handlers (write to file or send msgs) - Violation Handlers
- similar to user-level exceptioncurrent PC saved
in xvPC register, conflict address saved in
xvaddr register, then jump to handler - enable sw contention management on a conflict
- enable sw to undo committed inner open xaction
- Abort handlers
- similar to violation handlers
4Nesting
- limited levels of nesting
- each nested xaction has own TCB frame
- single stack for each type of handler
- easy to merge handlers of inner closed xactions
with parent when committing - commit handlers of inner open xactions are
executed, violation/abort handlers discarded - multilevel conflict detection
- xvcurrent register indicate which levels are
affected - always jump to innermost xaction violation
handler - problem how to track multiple active versions of
the same data (needed by different levels of
nesting) - soln1 multiple R/W bits per cache location to
track read/write set membership for all nesting
levels - R/W bits directly correspond to xvcurrent
- need to merge Ri/Wi into Ri1/Wi1 on
closed-nested commit (lazily before new child
level) - soln2 multiple cache locations for the different
versions, each with nesting level tag - level of nesting limited by associativity
- need to do extra compare of nesting level tag to
get the latest data - need to merge entry into parents entry on closed
nested commit (lazily before new child level) - nested parallelism not supported
5Hardware Transactional State
6(Partial)Transaction Protocol
xcommit
COMMITTED
ld/st
run commit handlers (xchcode)
NONE
VALIDATED
commit (open/outermost)merge read/write set
(closed)erase TCB/logs
no conflicts
xbegin/xbegin_open
conflict detection(NOP if lazy closed inner)
initialize TCB
conflict
xvalidate or
ACTIVE
external ld/st(eager)
xbegin_open/ xbegin
run violation handlers (xvhcode) disable
violation reporting set xvpending if more
violations
xvpending
ld/st
! xvpending
initialize TCB
add to read/write set add to write buffer/undo log
xret enable violation reportingjump xvPC
xabort
! xvpending
ABORTED
run abort handlers (xahcode) disable violation
reporting set xvpending if more violations
xvpending
7Miscellaneous
- immediate loads/stores provided to access
thread-private datato be used with caution (e.g.
by compiler, system developer) - xactions used for prod/cons described in
atomos-carlstrom-pldi06 - I/O implemented using commit handler
- xaction writes in private buffer
- commit handler writes in shared buffer with open
nesting