Lecture 19: Coherence and Synchronization. Topics: synchronization primitives (Sections )

Similar documents
Lecture: Coherence and Synchronization. Topics: synchronization primitives, consistency models intro (Sections )

Lecture: Coherence, Synchronization. Topics: directory-based coherence, synchronization primitives (Sections )

250P: Computer Systems Architecture. Lecture 14: Synchronization. Anton Burtsev March, 2019

Lecture 18: Coherence and Synchronization. Topics: directory-based coherence protocols, synchronization primitives (Sections

M4 Parallelism. Implementation of Locks Cache Coherence

Synchronization. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Chapter 8. Multiprocessors. In-Cheol Park Dept. of EE, KAIST

Synchronization. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Multiprocessor Synchronization

Synchronization. Coherency protocols guarantee that a reading processor (thread) sees the most current update to shared data.

The MESI State Transition Graph

Lecture: Consistency Models, TM

MULTIPROCESSORS AND THREAD LEVEL PARALLELISM

Chapter 5. Thread-Level Parallelism

Lecture 25: Multiprocessors

Role of Synchronization. CS 258 Parallel Computer Architecture Lecture 23. Hardware-Software Trade-offs in Synchronization and Data Layout

Flynn's Classification

Chapter 5. Multiprocessors and Thread-Level Parallelism

Chapter 5 Thread-Level Parallelism. Abdullah Muzahid

Chapter 5. Multiprocessors and Thread-Level Parallelism

The need for atomicity This code sequence illustrates the need for atomicity. Explain.

Introduction. Coherency vs Consistency. Lec-11. Multi-Threading Concepts: Coherency, Consistency, and Synchronization

Parallel Computer Architecture Spring Distributed Shared Memory Architectures & Directory-Based Memory Coherence

Computer Architecture. A Quantitative Approach, Fifth Edition. Chapter 5. Multiprocessors and Thread-Level Parallelism

EN2910A: Advanced Computer Architecture Topic 05: Coherency of Memory Hierarchy Prof. Sherief Reda School of Engineering Brown University

Lecture 33: Multiprocessors Synchronization and Consistency Professor Randy H. Katz Computer Science 252 Spring 1996

Shared Memory Multiprocessors

Lecture 19: Synchronization. CMU : Parallel Computer Architecture and Programming (Spring 2012)

Module 7: Synchronization Lecture 13: Introduction to Atomic Primitives. The Lecture Contains: Synchronization. Waiting Algorithms.

Multiprocessors II: CC-NUMA DSM. CC-NUMA for Large Systems

Lecture 25: Multiprocessors. Today s topics: Snooping-based cache coherence protocol Directory-based cache coherence protocol Synchronization

Aleksandar Milenkovic, Electrical and Computer Engineering University of Alabama in Huntsville. Review: Small-Scale Shared Memory

SHARED-MEMORY COMMUNICATION

Synchronization. Erik Hagersten Uppsala University Sweden. Components of a Synchronization Even. Need to introduce synchronization.

Page 1. Lecture 12: Multiprocessor 2: Snooping Protocol, Directory Protocol, Synchronization, Consistency. Bus Snooping Topology

Chapter-4 Multiprocessors and Thread-Level Parallelism

CSC2/458 Parallel and Distributed Systems Scalable Synchronization

CPE 631 Lecture 21: Multiprocessors

Review: Multiprocessor. CPE 631 Session 21: Multiprocessors (Part 2) Potential HW Coherency Solutions. Bus Snooping Topology

EN2910A: Advanced Computer Architecture Topic 05: Coherency of Memory Hierarchy

Multiprocessor Cache Coherence. Chapter 5. Memory System is Coherent If... From ILP to TLP. Enforcing Cache Coherence. Multiprocessor Types

Page 1. Outline. Coherence vs. Consistency. Why Consistency is Important

Lecture 26: Multiprocessors. Today s topics: Directory-based coherence Synchronization Consistency Shared memory vs message-passing

Lecture 18: Coherence Protocols. Topics: coherence protocols for symmetric and distributed shared-memory multiprocessors (Sections

5008: Computer Architecture

Parallel and Distributed Systems. Programming Models. Why Parallel or Distributed Computing? What is a parallel computer?

Lecture 9: Multiprocessor OSs & Synchronization. CSC 469H1F Fall 2006 Angela Demke Brown

Thread-Level Parallelism

CS654 Advanced Computer Architecture Lec 14 Directory Based Multiprocessors

Data-Centric Consistency Models. The general organization of a logical data store, physically distributed and replicated across multiple processes.

CS 347 Parallel and Distributed Data Processing

EN164: Design of Computing Systems Lecture 34: Misc Multi-cores and Multi-processors

Lecture 13: Consistency Models. Topics: sequential consistency, requirements to implement sequential consistency, relaxed consistency models

CS 347 Parallel and Distributed Data Processing

Computer Architecture Lecture 10: Thread Level Parallelism II (Chapter 5) Chih Wei Liu 劉志尉 National Chiao Tung University

Lecture 8: Directory-Based Cache Coherence. Topics: scalable multiprocessor organizations, directory protocol design issues

Scalable Locking. Adam Belay

Lecture 7: Implementing Cache Coherence. Topics: implementation details

Lecture 2: Snooping and Directory Protocols. Topics: Snooping wrap-up and directory implementations

Cache Coherence and Atomic Operations in Hardware

Computer Architecture and Engineering CS152 Quiz #5 April 27th, 2016 Professor George Michelogiannakis Name: <ANSWER KEY>

Lecture 3: Snooping Protocols. Topics: snooping-based cache coherence implementations

Suggested Readings! What makes a memory system coherent?! Lecture 27" Cache Coherency! ! Readings! ! Program order!! Sequential writes!! Causality!

Lecture 5: Directory Protocols. Topics: directory-based cache coherence implementations

CS5460: Operating Systems

Computer Science 146. Computer Architecture

Algorithms for Scalable Synchronization on Shared Memory Multiprocessors by John M. Mellor Crummey Michael L. Scott

MultiJav: A Distributed Shared Memory System Based on Multiple Java Virtual Machines. MultiJav: Introduction

Computer Architecture and Engineering CS152 Quiz #5 May 2th, 2013 Professor Krste Asanović Name: <ANSWER KEY>

CS433 Homework 6. Problem 1 [15 points] Assigned on 11/28/2017 Due in class on 12/12/2017

Lecture 4: Directory Protocols and TM. Topics: corner cases in directory protocols, lazy TM

Lecture 21: Transactional Memory. Topics: consistency model recap, introduction to transactional memory

ECE 669 Parallel Computer Architecture

Basic Architecture of SMP. Shared Memory Multiprocessors. Cache Coherency -- The Problem. Cache Coherency, The Goal.

CSE502: Computer Architecture CSE 502: Computer Architecture

Advanced Operating Systems (CS 202) Memory Consistency, Cache Coherence and Synchronization

Page 1. Cache Coherence

INSTITUTO SUPERIOR TÉCNICO. Architectures for Embedded Computing

Goldibear and the 3 Locks. Programming With Locks Is Tricky. More Lock Madness. And To Make It Worse. Transactional Memory: The Big Idea

Lecture 26: Multiprocessors. Today s topics: Synchronization Consistency Shared memory vs message-passing

Lecture 8: Snooping and Directory Protocols. Topics: split-transaction implementation details, directory implementations (memory- and cache-based)

Advance Operating Systems (CS202) Locks Discussion

NUMA-aware Reader-Writer Locks. Tom Herold, Marco Lamina NUMA Seminar

GLocks: Efficient Support for Highly- Contended Locks in Many-Core CMPs

Symmetric Multiprocessors: Synchronization and Sequential Consistency

CS377P Programming for Performance Multicore Performance Cache Coherence

Computer Architecture

Agenda. Lecture. Next discussion papers. Bottom-up motivation Shared memory primitives Shared memory synchronization Barriers and locks

Multiprocessors and Locking

Synchronization. Han Wang CS 3410, Spring 2012 Computer Science Cornell University. P&H Chapter 2.11

6.852: Distributed Algorithms Fall, Class 15

Lecture 10: Cache Coherence: Part I. Parallel Computer Architecture and Programming CMU , Spring 2013

Speculative Lock Elision: Enabling Highly Concurrent Multithreaded Execution

Speculative Locks. Dept. of Computer Science

Multiprocessor Cache Coherency. What is Cache Coherence?

CS433 Homework 6. Problem 1 [15 points] Assigned on 11/28/2017 Due in class on 12/12/2017

Midterm Exam 02/09/2009

Reminder from last time

Towards Thousand-Core RISC-V Shared Memory Systems. Quan Nguyen Massachusetts Institute of Technology 30 November 2016

CSE 5306 Distributed Systems

Transcription:

Lecture 19: Coherence and Synchronization Topics: synchronization primitives (Sections 5.4-5.5) 1

Caching Locks Spin lock: to acquire a lock, a process may enter an infinite loop that keeps attempting a read-modify till it succeeds If the lock is in memory, there is heavy bus traffic other processes make little forward progress Locks can be cached: cache coherence ensures that a lock update is seen by other processors the process that acquires the lock in exclusive state gets to update the lock first spin on a local copy the external bus sees little traffic 2

Coherence Traffic for a Lock If every process spins on an exchange, every exchange instruction will attempt a write many invalidates and the locked value keeps changing ownership Hence, each process keeps reading the lock value a read does not generate coherence traffic and every process spins on its locally cached copy When the lock owner releases the lock by writing a 0, other copies are invalidated, each spinning process generates a read miss, acquires a new copy, sees the 0, attempts an exchange (requires acquiring the block in exclusive state so the write can happen), first process to acquire the block in exclusive state acquires the lock, others keep spinning 3

Test-and-Test-and-Set lock: test register, location bnz register, lock t&s register, location bnz register, lock CS st location, #0 4

Load-Linked and Store Conditional LL-SC is an implementation of atomic read-modify-write with very high flexibility LL: read a value and update a table indicating you have read this address, then perform any amount of computation SC: attempt to store a result into the same memory location, the store will succeed only if the table indicates that no other process attempted a store since the local LL (success only if the operation was effectively atomic) SC implementations do not generate bus traffic if the SC fails hence, more efficient than test&test&set 5

Spin Lock with Low Coherence Traffic lockit: LL R2, 0(R1) ; load linked, generates no coherence traffic BNEZ R2, lockit ; not available, keep spinning DADDUI R2, R0, #1 ; put value 1 in R2 SC R2, 0(R1) ; store-conditional succeeds if no one ; updated the lock since the last LL BEQZ R2, lockit ; confirm that SC succeeded, else keep trying If there are i processes waiting for the lock, how many bus transactions happen? 6

Spin Lock with Low Coherence Traffic lockit: LL R2, 0(R1) ; load linked, generates no coherence traffic BNEZ R2, lockit ; not available, keep spinning DADDUI R2, R0, #1 ; put value 1 in R2 SC R2, 0(R1) ; store-conditional succeeds if no one ; updated the lock since the last LL BEQZ R2, lockit ; confirm that SC succeeded, else keep trying If there are i processes waiting for the lock, how many bus transactions happen? 1 write by the releaser + i read-miss requests + i responses + 1 write by acquirer + 0 (i-1 failed SCs) + i-1 read-miss requests + i-1 responses 7

Further Reducing Bandwidth Needs Ticket lock: every arriving process atomically picks up a ticket and increments the ticket counter (with an LL-SC), the process then keeps checking the now-serving variable to see if its turn has arrived, after finishing its turn it increments the now-serving variable Array-Based lock: instead of using a now-serving variable, use a now-serving array and each process waits on a different variable fair, low latency, low bandwidth, high scalability, but higher storage Queueing locks: the directory controller keeps track of the order in which requests arrived when the lock is available, it is passed to the next in line (only one process 8 sees the invalidate and update)

Lock Vs. Optimistic Concurrency lockit: LL R2, 0(R1) BNEZ R2, lockit DADDUI R2, R0, #1 SC R2, 0(R1) BEQZ R2, lockit Critical Section ST 0(R1), #0 LL-SC is being used to figure out if we were able to acquire the lock without anyone interfering we then enter the critical section tryagain: LL R2, 0(R1) DADDUI R2, R2, R3 SC R2, 0(R1) BEQZ R2, tryagain If the critical section only involves one memory location, the critical section can be captured within the LL-SC instead of spinning on the lock acquire, you may now be spinning trying to atomically execute the CS 9

Barriers Barriers are synchronization primitives that ensure that some processes do not outrun others if a process reaches a barrier, it has to wait until every process reaches the barrier When a process reaches a barrier, it acquires a lock and increments a counter that tracks the number of processes that have reached the barrier it then spins on a value that gets set by the last arriving process Must also make sure that every process leaves the spinning state before one of the processes reaches the next barrier 10

Barrier Implementation LOCK(bar.lock); if (bar.counter == 0) bar.flag = 0; mycount = bar.counter++; UNLOCK(bar.lock); if (mycount == p) { bar.counter = 0; bar.flag = 1; } else while (bar.flag == 0) { }; 11

Sense-Reversing Barrier Implementation local_sense =!(local_sense); LOCK(bar.lock); mycount = bar.counter++; UNLOCK(bar.lock); if (mycount == p) { bar.counter = 0; bar.flag = local_sense; } else { while (bar.flag!= local_sense) { }; } 12

Title Bullet 13