NB-FEB: A Universal Scalable Easy- to-Use Synchronization Primitive for Manycore Architectures Phuong H. Ha (Univ. of Tromsø, Norway) Philippas Tsigas (Chalmers Univ., Sweden) Otto J. Anshus (Univ. of Tromsø, Norway) Presentation at OPODIS ’09 December 15-18, 2009, Nimes, France
Problem Manycores require scalable strong synchronization primitives. Conventional strong primitives do not scale well enough for manycores [UCB Landscape]. Contention on a synchronization variable increases with the number of processing cores. OPODIS '09, Nimes, France 2 cores16 cores1000 cores
Desired features New synch. primitives for manycores should be: Scalable 1000s of cores Universal powerful enough to support any kind of synchronization (like CAS, LL/SC) Feasible able to implement in hardware Easy-to-use OPODIS '09, Nimes, France
Our main contributions A novel synch. primitve with all these features OPODIS '09, Nimes, France Non-blocking Full/Empty Bit (NB-FEB) NBFEB-STM: a non-blocking STM
Road-map NB-FEB Feasible Universal Scalable Easy-to-use NBFEB-STM: a non-blocking STM OPODIS '09, Nimes, France
Feasibility Key idea: slight modifications of a widely deployed primitive A variant of the original FEB that always returns a value instead of waiting for a conditional flag OPODIS '09, Nimes, France Test-Flag-and-Set TFAS( x, v) { (o, flag o ) (x, flag x ); if flag x = false then (x, flag x ) (v, true); end if return (o, flag o ); } Store-And-Clear SAC( x, v) { (o, flag o ) (x, flag x ); (x, flag x ) (v, false); return (o, flag o ); } Store-And-Set SAS( x, v) { (o, flag o ) (x, flag x ); (x, flag x ) (v, true); return (o, flag o ); } Load Load( x) { return (x, flag x ); } Original FEB: Store-if-Clear-and-Set SICAS(x,v) { Wait for flag x to be false; (x, flag x ) (v, true); }
Universality Key idea: write-once objects with 3+ states TFAS Wait-free consensus, n OPODIS '09, Nimes, France Decision ( , false); TFAS_Consensus( proposal) { (first, ) TFAS(Decision, proposal); if first = then return proposal; else return first; }
Scalability Key idea: Combinability eliminates contention & reduce load Ex: TFAS OPODIS '09, Nimes, France x= TFAS(x,1) TFAS(x,2) TFAS(x,3) TFAS(x,4) TFAS(x,1) TFAS(x,3) TFAS(x,1) x=1 1 TFAS( var x, value v) atomically { (o, flag o ) (x, flag x ); if flag x = false then (x, flag x ) (v, true); end if return (o, flag o ); } TFAS( var x, value v) atomically { (o, flag o ) (x, flag x ); if flag x = false then (x, flag x ) (v, true); end if return (o, flag o ); } Note: CAS or LL/SC is not combinable
NB-FEB combining logic OPODIS '09, Nimes, France (x, [v 1 ])Successive primitive with parameter (x, [v 2 ]) LoadSACSASTFAS Load SAC(v 2 )SAS(v 2 )TFAS(v 2 ) SACSAC(v 1 )SAC(v 2 )SAS(v 2 ) SASSAS(v 1 )SAC(v 2 )SAS(v 2 )SAS(v 1 ) TFASTFAS(v 1 )SAC(v 2 )SAS(v 2 )TFAS(v 1 )
Easy-to-use Key idea: abstractions for productivity-layer programmers Non-blocking software transactional memory NBFEB-STM OPODIS '09, Nimes, France
Road-map NB-FEB Feasible Universal Scalable Easy-to-use NBFEB-STM: a non-blocking STM OPODIS '09, Nimes, France
NBFEB-STM Models Objects are accessed within transactions No nested transactions Garbage collected programming languages (e.g. Java) Features Obstruction-free STM Eliminate conventional synch. hot spots in STMs Optimal space complexity (N) OPODIS '09, Nimes, France
Challenge 1: TFAS-SAC interleaving CAS-based STMs NBFEB-STM Need SAC to clear pointer’s flag Overlapping TFAS 1 & TFAS 2 both may succeed due to SAC’s interference. violate TMObj’s semantics OPODIS '09, Nimes, France TMObj Old New TM 0 Old New TM 1 Copy CAS 1 Old New TM 2 Copy CAS 2 locator
Key idea 1 Keep a linked list of locators write-once pointer next OPODIS '09, Nimes, France locator Old New TM 0 Old New TM 1 Old New TM 2 eliminate SAC interference TFAS
Challenge 2: Space complexity OPODIS '09, Nimes, France CAS-based STMsNBFEB-STM TMObj Old New TM 0 Old New TM 1 Old New TM 2 CAS 2 locator Old New TM 0 Old New TM 1 Old New TM 2
Key idea 2 Only the head is needed for further accesses break the list of obsolete locators OPODIS '09, Nimes, France locator Old New TM 0 Old New TM 1 Old New TM 2 pipi pipi SAC Optimal space complexity (N)
Challenge 3: Find the head OPODIS '09, Nimes, France locator Old New TM 0 Old New TM 1 Old New TM 2 pipi pipi Head X
Key idea 3 No nested transactions one active locator / thread OPODIS '09, Nimes, France i 0 1 … … N TMObj locator Old New TM 0 Old New TM 1 Old New TM 2 pipi pipi SAC
Correctness NBFEB-STM fulfills the essential aspects of TM [Guerraoui, PPoPP ’08] Instantaneous commit Precluding inconsistent views Preserving real-time order OPODIS '09, Nimes, France
Conclusions Introduce a novel non-blocking full/empty bit primitive (NB-FEB) Scalable, universal, feasible and easy-to-use Provide an abstraction, NBFEB-STM, built on top of the primitive. OPODIS '09, Nimes, France
Thanks for your attention!