thread-level transactional memory - research.cs.wisc.edu · october 21, 2004 thread-level...

24
Thread-Level Transactional Memory Decoupling Interface and Implementation UW Computer Architecture Affiliates Conference Kevin Moore October 21, 2004

Upload: others

Post on 07-Oct-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

Thread-Level TransactionalMemoryDecoupling Interface and Implementation

UW Computer ArchitectureAffiliates Conference

Kevin MooreOctober 21, 2004

Page 2: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 2

Transactional Memory

Atomic and isolated execution Replace locks for critical sections

No lock granularity problem

Software Error Recovery Allow programmers to abort/rollback

transactions when errors are detected Convenient interface for exception handling

Page 3: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 3

Why Haven’t You Built It?

ISA Change No immediate benefit Complexity No solution for large transactions No solution for software error recovery

Page 4: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 4

The Interface Matters Many systems implement the same ISA

Support multiple design points Survive technology changes

Programmability is the key motivation fortransactional memory

Interface challenge Modern processors support small (few memory

operations) easily Unlimited transactions are more convenient for

software

Page 5: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 5

Virtualize TransactionalMemory

Decouple interface and implementation Allow arbitrary size transactions Don’t require unlimited buffering

Flexible implementation Multiple cost/performance options

Support software error recovery Recover all transactions

Page 6: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 6

Overview

Motivation Background TLTM Interface Out-of-Cache Transactions Conclusion

Page 7: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 7

Prior Transactional MemorySystems

Transactional Memory Transactional Memory Coherence and

Consistency Oklahoma Update Transactional Lock Removal 801 Storage (Database Storage)

Page 8: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 8

Transactional Memory

Herlihy and Moss, ISCA 1993 Replaced short critical sections with

atomic transactions More efficient than locks Implementation based on cache

coherence states

Page 9: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 9

Herlihy and Moss, ISCA 1993 Transaction cache

Stores all data accessedby transactions

2 copies of eachupdated cache line

Fully associative Acts as a victim cache

Long Locks Processors are allowed

to refuse coherencerequests

S

S

M

XAbort

XCommit

Cache TransactionCache

CPU

Memory

Page 10: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 10

Transactional MemoryCoherence and Consistency

TCC combines coherence andtransaction support

All memory requests are part of sometransaction

Designed for a single CMP Relies on broadcast

Page 11: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 11

TCC Each processor executes a speculative

(optimistic) transaction Commits are serial

Broadcasts addresses of all updates in thetransaction

Supports long-running (large) transactions Must grab (and hold) commit permission first Cannot abort large transactions

Page 12: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 12

TCC

CPUL1 D

L2 CacheLogically Shared

Write buffer ~4kB, Fully-Associative

On-ChipInterconnect

Broadcast-BasedCommunication

Page 13: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 13

Limits of Prior Proposals

No separation between implementationand interface

No concurrent execution of largetransactions

No software error recovery Don’t address operating system

Page 14: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 14

Thread-Level TransactionalMemory (TLTM)

Decouple transactional interface andimplementation

No limit on transaction size or content Break the dependence on caching all

data accessed in a transaction

Page 15: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 15

TLTM API Transactions

Specified by begin and commit operations All memory operations between begin and

commit are part of the transaction Transactions end in a commit or an abort

Abort/Recovery Can be triggered by software or hardware Control may be passed to software abort handler If software handler is called, a before-image log

is provided in the memory space of the process

Page 16: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 16

TLTM Guarantee

1) Execute the transaction atomically(and commit) or,

2) Allow a software abort handler to runbefore any updates are exposed

For each transaction the hardware will:

Page 17: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 17

Transactional MemoryRequirements

Maintain multiple versions of updatedobjects

Track data set (reads and updates) Rollback/Restart

Page 18: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 18

Thread-Level Log

Stack

Log

Thread 0

Stack

Log

Thread n

Code

Data

Heap

Global

Page 19: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 19

Log-Based Recovery Undo log

Before image log stored in virtual addressspace of user program

Separate log for each thread Aborts can be handled in software

Replays log entries in LIFO order Breaks dependence on cache for 2nd

copy

Page 20: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 20

Speculative Transactions

ULTM does not require logging Processors can still execute

transactions speculatively Non-speculative transactions will be

rare for many applications

Page 21: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 21

Transaction Read Set Size

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 10 20 30 40 50 60

Read Set Size (in 64-Byte Lines)

PD

F BARNES 512

OCEAN 66

Page 22: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 22

Transaction Write Set Size

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 10 20 30 40

Log Size

PD

F BARNES 512

OCEAN 66

Page 23: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 23

Tracking Transaction State

Use conservative estimate oftransaction data sets Allows bounded state

Allows a trade-off between spaceoverhead and performance Results in some unnecessary aborts

Page 24: Thread-Level Transactional Memory - research.cs.wisc.edu · October 21, 2004 Thread-Level Transactional Memory 4 The Interface Matters Many systems implement the same ISA Support

October 21, 2004 Thread-Level Transactional Memory 24

Advantages of TLTM Flexibility for programmers

No hardware-imposed limits on transactioncontent

Allows conservative synchronization Supports recovery for all transactions

Flexibility for memory system designers No minimum size or associativity requirement for

caches, reorder buffers or store queues Can off-load recovery to software