SlideShare a Scribd company logo
1 of 36
Memory Models

Dr. C.V. Suresh Babu
Memory Consistency Models
Parallelism for the masses!
Shared-memory most common
Memory model = Legal values for reads
Memory Consistency Models
Parallelism for the masses!
Shared-memory most common
Memory model = Legal values for reads
Memory Consistency Models
Parallelism for the masses!
Shared-memory most common
Memory model = Legal values for reads
Memory Consistency Models
Parallelism for the masses!
Shared-memory most common
Memory model = Legal values for reads
Memory Consistency Models
Parallelism for the masses!
Shared-memory most common
Memory model = Legal values for reads
20 Years of Memory Models
• Memory model is at the heart of concurrency semantics
– 20 year journey from confusion to convergence at last!
– Hard lessons learned
– Implications for future

• Current way to specify concurrency semantics is too hard
– Fundamentally broken

• Must rethink parallel languages and hardware
• Implications for broader CS disciplines
What is a Memory Model?
• Memory model defines what values a read can return
Initially A=B=C=Flag=0
Thread 1
Thread 2
A = 26
while (Flag != 1) {;}
90
B = 90
r1 = B
26 0
…
r2 = A
Flag = 1
…
Memory Model is Key to Concurrency Semantics
• Interface between program and transformers of program
– Defines what values a read can return

Compiler

Assembly

C++ program

Dynamic
optimizer

Hardware

• Weakest system component exposed to the programmer
– Language level model has implications for hardware
• Interface must last beyond trends
Desirable Properties of a Memory Model
• 3 Ps
– Programmability
– Performance
– Portability

• Challenge: hard to satisfy all 3 Ps
– Late 1980’s - 90’s: Largely driven by hardware
• Lots of models, little consensus
– 2000 onwards: Largely driven by languages/compilers
• Consensus model for Java, C++ (C, others ongoing)
• Had to deal with mismatches in hardware models

Path to convergence has lessons for future
Programmability – SC [Lamport79]
• Programmability: Sequential consistency (SC) most intuitive
– Operations of a single thread in program order
– All operations in a total order or atomic

• But Performance?
– Recent (complex) hardware techniques boost performance with SC
– But compiler transformations still inhibited

• But Portability?
– Almost all h/w, compilers violate SC today

⇒SC not practical, but…
Next Best Thing – SC Almost Always
• Parallel programming too hard even with SC
– Programmers (want to) write well structured code
– Explicit synchronization, no data races
Thread 1

Thread 2

Lock(L)

Lock(L)

Read Data1

Read Data2

Write Data2

Write Data1

…

…

Unlock(L)

Unlock(L)

– SC for such programs much easier: can reorder data accesses

⇒ Data-race-free model [AdveHill90]
– SC for data-race-free programs
– No guarantees for programs with data races
Definition of a Data Race
• Distinguish between data and non-data (synchronization) accesses
• Only need to define for SC executions ⇒ total order
• Two memory accesses form a race if
– From different threads, to same location, at least one is a write
– Occur one after another
Thread 1
Write, A, 26
Write, B, 90

Thread 2

Read, Flag, 0
Write, Flag, 1
Read, Flag, 1
Read, B, 90
Read, A, 26

• A race with a data access is a data race
• Data-race-free-program = No data race in any SC execution
Data-Race-Free Model
Data-race-free model = SC for data-race-free programs
– Does not preclude races for wait-free constructs, etc.
• Requires races be explicitly identified as synchronization
• E.g., use volatile variables in Java, atomics in C++

– Dekker’s algorithm
Initially Flag1 = Flag2 = 0
volatile Flag1, Flag2
Thread1
Flag1 = 1
if Flag2 == 0
//critical section

Thread2
Flag2 = 1
if Flag1 == 0
//critical section

SC prohibits both loads returning 0
Data-Race-Free Approach
• Programmer’s model: SC for data-race-free programs
• Programmability
– Simplicity of SC, for data-race-free programs

• Performance
– Specifies minimal constraints (for SC-centric view)

• Portability
– Language must provide way to identify races
– Hardware must provide way to preserve ordering on races
– Compiler must translate correctly
1990's in Practice (The Memory Models Mess)
• Hardware
– Implementation/performance-centric view

LD

LD

LD

– Various ordering guarantees + fences to impose other orders
– Many ambiguities - due to complexity, by design(?), …

• High-level languages
– Most shared-memory programming with Pthreads, OpenMP
• Incomplete, ambiguous model specs
• Memory model property of language, not library [Boehm05]
– Java – commercially successful language with threads
• Chapter 17 of Java language spec on memory model
• But hard to interpret, badly broken

ST

Fence

– Different vendors had different models – most non-SC
• Alpha, Sun, x86, Itanium, IBM, AMD, HP, Cray, …

ST

ST

LD

ST
2000 – 2004: Java Memory Model
• ~ 2000: Bill Pugh publicized fatal flaws in Java model
• Lobbied Sun to form expert group to revise Java model
• Open process via mailing list
–
–
–
–

Diverse participants
Took 5 years of intense, spirited debates
Many competing models
Final consensus model approved in 2005 for Java 5.0
[MansonPughAdve POPL 2005]
Java Memory Model Highlights
• Quick agreement that SC for data-race-free was required
• Missing piece: Semantics for programs with data races
– Java cannot have undefined semantics for ANY program
– Must ensure safety/security guarantees
– Limit damage from data races in untrusted code

• Goal: Satisfy security/safety, w/ maximum system flexibility
– Problem: “safety/security, limited damage” w/ threads very vague
Java Memory Model Highlights
Initially X=Y=0
Thread 1
r1 = X
Y = r1

Thread 2

r2 = Y
X = r2
Is r1=r2=42 allowed?

Data races produce causality loop!
Definition of a causality loop was surprisingly hard
Common compiler optimizations seem to violate“causality”
Java Memory Model Highlights
• Final model based on consensus, but complex
– Programmers can (must) use “SC for data-race-free”
– But system designers must deal with complexity
– Correctness tools, racy programs, debuggers, …??
– Recent discovery of bugs [SevcikAspinall08]
2005 - :C++, Microsoft Prism, Multicore
• ~ 2005: Hans Boehm initiated C++ concurrency model
– Prior status: no threads in C++, most concurrency w/ Pthreads

• Microsoft concurrently started its own internal effort
• C++ easier than Java because it is unsafe
– Data-race-free is plausible model

• BUT multicore ⇒ New h/w optimizations, more scrutiny
– Mismatched h/w, programming views became painfully obvious
– Debate that SC for data-race-free inefficient w/ hardware models
C++ Challenges
2006: Pressure to change Java/C++ to remove SC baseline
To accommodate some hardware vendors

• But what is alternative?
– Must allow some hardware optimizations
– But must be teachable to undergrads

• Showed such an alternative (probably) does not exist
C++ Compromise
• Default C++ model is data-race-free
• AMD, Intel, … on board
• But
– Some systems need expensive fence for SC
– Some programmers really want more flexibility
• C++ specifies low-level atomics only for experts
• Complicates spec, but only for experts
• We are not advertising this part
– [BoehmAdve PLDI 2008]
Summary of Current Status
• Convergence to “SC for data-race-free” as baseline
• For programs with data races
– Minimal but complex semantics for safe languages
– No semantics for unsafe languages
Lessons Learned
• Specifying semantics for programs with data races is HARD
– But “no semantics for data races” also has problems
• Not an option for safe languages
• Debugging, correctness checking tools

• Hardware-software mismatch for some code
– “Simple” optimizations have unintended consequences

⇒State-of-the-art is fundamentally broken
Lessons Learned
• Specifying semantics for programs with data races is HARD
– But “no semantics for data races” also has problems
• Not an option for safe languages
• Debugging, correctness checking tools

Banish mismatch for some code
• Hardware-softwareshared-memory?
– “Simple” optimizations have unintended consequences

⇒State-of-the-art is fundamentally broken
Lessons Learned
• Specifying semantics for programs with data races is HARD
– But “no semantics for data races” also has problems
• Not an option for safe languages
• Debugging, correctness checking tools

Banish wild shared-memory!
• Hardware-software mismatch for some code
– “Simple” optimizations have unintended consequences

⇒State-of-the-art is fundamentally broken
• We need
– Higher-level disciplined models that enforce discipline
– Hardware co-designed with high-level models
Research Agenda for Languages
• Disciplined shared-memory models
– Simple
– Enforceable
– Expressive
– Performance
Key: What discipline?
How to enforce it?
Data-Race-Free
• A near-term discipline: Data-race-free
• Enforcement
– Ideally, language prohibits by design
– e.g., ownership types [Boyapati+02]

– Else, runtime catches as exception
e.g., Goldilocks [Elmas+07]

• But work still needed for expressivity and/or performance
• But data-race-free still not sufficiently high level
Deterministic-by-Default Parallel Programming
• Even data-race-free parallel programs are too hard
– Multiple interleavings due to unordered synchronization (or races)
– Makes reasoning and testing hard

• But many algorithms are deterministic
– Fixed input gives fixed output
– Standard model for sequential programs
– Also holds for many transformative parallel programs
• Parallelism not part of problem specification, only for performance

Why write such an algorithm in non-deterministic style,
then struggle to understand and control its behavior?
Deterministic-by-Default Model
• Parallel programs should be deterministic-by-default
– Sequential semantics (easier than SC!)

• If non-determinism is needed
– should be explicitly requested, encapsulated
– should not interfere with guarantees for the rest of the program

• Enforcement:
– Ideally, language prohibits by design
– Else, runtime catches violations as exceptions
State-of-the-art
• Many deterministic languages today
– Functional, pure data parallel, some domain-specific, …
– Much recent work on runtime, library-based approaches
– E.g., Allen09, Divietti09, Olszewski09, …

• Our work: Language approach for modern O-O methods
– Deterministic Parallel Java (DPJ) [V. Adve et al.]
Deterministic Parallel Java (DPJ)
• Object-oriented type and effect system
–
–
–
–

Aliasing information: partition the heap into “regions”
Effect specifications: regions read or written by each method
Language guarantees determinism through type checking
Side benefit: regions, effects are valuable documentation

• Implemented as extension to base Java type system
–
–
–
–

Initial evaluation for expressivity, performance [Bocchino+09]
Semi-automatic tool for region annotations [Vakilian+09]
Recent work on encapsulating frameworks and unchecked code
Ongoing work on integrating non-determinism
Implications for Hardware
• Current hardware not matched even to current model
• Near term: ISA changes, speculation
• Long term: Co-design hardware with new software models
– Use disciplined software to make more efficient hardware
– Use hardware to support disciplined software
Illinois DeNovo Project
• How to design hardware from the ground up to
– Exploit disciplined parallelism
• for better performance, power, …

– Support disciplined parallelism
• for better dependability

• Working with DPJ to exploit region, effect information
– Software-assisted coherence, communication, scheduling
– New hardware/software interface
– Opportune time as we determine how to scale multicore
Conclusions
• Current way to specify concurrency semantics fundamentally broken
– Best we can do is SC for data-race-free
• But cannot hide from programs with data races

– Mismatched hardware-software
• Simple optimizations give unintended consequences

• Need
– High-level disciplined models that enforce discipline
– Hardware co-designed with high-level models
• E.g., DPJ, DeNovo

– Implications for many CS communities

More Related Content

What's hot

What's hot (20)

Kernel module in linux os.
Kernel module in linux os.Kernel module in linux os.
Kernel module in linux os.
 
pushdown automata
pushdown automatapushdown automata
pushdown automata
 
Parallel Algorithms
Parallel AlgorithmsParallel Algorithms
Parallel Algorithms
 
Boot process
Boot processBoot process
Boot process
 
Lecture 1 introduction to parallel and distributed computing
Lecture 1   introduction to parallel and distributed computingLecture 1   introduction to parallel and distributed computing
Lecture 1 introduction to parallel and distributed computing
 
Multithreading models.ppt
Multithreading models.pptMultithreading models.ppt
Multithreading models.ppt
 
Introduction to Parallel and Distributed Computing
Introduction to Parallel and Distributed ComputingIntroduction to Parallel and Distributed Computing
Introduction to Parallel and Distributed Computing
 
Cache memory
Cache memoryCache memory
Cache memory
 
Pthread
PthreadPthread
Pthread
 
Shortest path algorithm
Shortest  path algorithmShortest  path algorithm
Shortest path algorithm
 
Demand paging
Demand pagingDemand paging
Demand paging
 
Introduction to pandas
Introduction to pandasIntroduction to pandas
Introduction to pandas
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Multiprocessor
MultiprocessorMultiprocessor
Multiprocessor
 
Ui disk & terminal drivers
Ui disk & terminal driversUi disk & terminal drivers
Ui disk & terminal drivers
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Addressing sequencing
Addressing sequencingAddressing sequencing
Addressing sequencing
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 
File system Os
File system OsFile system Os
File system Os
 
String matching algorithms
String matching algorithmsString matching algorithms
String matching algorithms
 

Viewers also liked

Tulving episodic semantic
Tulving episodic semanticTulving episodic semantic
Tulving episodic semanticJohn Turner
 
Human Memory (Psychology)
Human Memory (Psychology)Human Memory (Psychology)
Human Memory (Psychology)Shara Mae Reloj
 
Psychology- Memory
Psychology- MemoryPsychology- Memory
Psychology- MemoryMya007
 
Attention and Consciousness
Attention and ConsciousnessAttention and Consciousness
Attention and Consciousnessorengomoises
 
The Feature-Integration of Attention_Jing
The Feature-Integration of Attention_JingThe Feature-Integration of Attention_Jing
The Feature-Integration of Attention_JingJing Chen
 
HSA Memory Model Hot Chips 2013
HSA Memory Model Hot Chips 2013HSA Memory Model Hot Chips 2013
HSA Memory Model Hot Chips 2013HSA Foundation
 
Memory and Models of Memory
Memory and Models of MemoryMemory and Models of Memory
Memory and Models of Memorycowmoo83
 
Chapter 4 Psych 1 Online Stud
Chapter 4 Psych 1 Online StudChapter 4 Psych 1 Online Stud
Chapter 4 Psych 1 Online StudMosslera
 
Computer Architecture: A quantitative approach - Cap4 - Section 6
Computer Architecture: A quantitative approach - Cap4 - Section 6Computer Architecture: A quantitative approach - Cap4 - Section 6
Computer Architecture: A quantitative approach - Cap4 - Section 6Marcelo Arbore
 
Dynamic data race detection in concurrent Java programs
Dynamic data race detection in concurrent Java programsDynamic data race detection in concurrent Java programs
Dynamic data race detection in concurrent Java programsDevexperts
 
INSTRUCTION LEVEL PARALLALISM
INSTRUCTION LEVEL PARALLALISMINSTRUCTION LEVEL PARALLALISM
INSTRUCTION LEVEL PARALLALISMKamran Ashraf
 
Instruction Level Parallelism (ILP) Limitations
Instruction Level Parallelism (ILP) LimitationsInstruction Level Parallelism (ILP) Limitations
Instruction Level Parallelism (ILP) LimitationsJose Pinilla
 
Attention
Attention Attention
Attention gsjus
 
Forgetting and theories of forgetting
Forgetting and theories of forgettingForgetting and theories of forgetting
Forgetting and theories of forgettingsamreennaz5
 
Pipelining and ILP (Instruction Level Parallelism)
Pipelining and ILP (Instruction Level Parallelism) Pipelining and ILP (Instruction Level Parallelism)
Pipelining and ILP (Instruction Level Parallelism) A B Shinde
 
Sensory memory
Sensory memorySensory memory
Sensory memoryDonitarose
 

Viewers also liked (20)

Working memory model
Working memory modelWorking memory model
Working memory model
 
Tulving episodic semantic
Tulving episodic semanticTulving episodic semantic
Tulving episodic semantic
 
Human Memory (Psychology)
Human Memory (Psychology)Human Memory (Psychology)
Human Memory (Psychology)
 
Psychology- Memory
Psychology- MemoryPsychology- Memory
Psychology- Memory
 
Attention and Consciousness
Attention and ConsciousnessAttention and Consciousness
Attention and Consciousness
 
The Feature-Integration of Attention_Jing
The Feature-Integration of Attention_JingThe Feature-Integration of Attention_Jing
The Feature-Integration of Attention_Jing
 
HSA Memory Model Hot Chips 2013
HSA Memory Model Hot Chips 2013HSA Memory Model Hot Chips 2013
HSA Memory Model Hot Chips 2013
 
Memory and Models of Memory
Memory and Models of MemoryMemory and Models of Memory
Memory and Models of Memory
 
Java Memory Model
Java Memory ModelJava Memory Model
Java Memory Model
 
Chapter 4 Psych 1 Online Stud
Chapter 4 Psych 1 Online StudChapter 4 Psych 1 Online Stud
Chapter 4 Psych 1 Online Stud
 
Computer Architecture: A quantitative approach - Cap4 - Section 6
Computer Architecture: A quantitative approach - Cap4 - Section 6Computer Architecture: A quantitative approach - Cap4 - Section 6
Computer Architecture: A quantitative approach - Cap4 - Section 6
 
Dynamic data race detection in concurrent Java programs
Dynamic data race detection in concurrent Java programsDynamic data race detection in concurrent Java programs
Dynamic data race detection in concurrent Java programs
 
INSTRUCTION LEVEL PARALLALISM
INSTRUCTION LEVEL PARALLALISMINSTRUCTION LEVEL PARALLALISM
INSTRUCTION LEVEL PARALLALISM
 
Instruction Level Parallelism (ILP) Limitations
Instruction Level Parallelism (ILP) LimitationsInstruction Level Parallelism (ILP) Limitations
Instruction Level Parallelism (ILP) Limitations
 
Attention
Attention Attention
Attention
 
Forgetting and theories of forgetting
Forgetting and theories of forgettingForgetting and theories of forgetting
Forgetting and theories of forgetting
 
Pipelining and ILP (Instruction Level Parallelism)
Pipelining and ILP (Instruction Level Parallelism) Pipelining and ILP (Instruction Level Parallelism)
Pipelining and ILP (Instruction Level Parallelism)
 
Sensory memory
Sensory memorySensory memory
Sensory memory
 
Memory
MemoryMemory
Memory
 
Memory
MemoryMemory
Memory
 

Similar to Memory models

Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...InfinIT - Innovationsnetværket for it
 
Programming Languages #devcon2013
Programming Languages #devcon2013Programming Languages #devcon2013
Programming Languages #devcon2013Iván Montes
 
Embedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterEmbedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterHossam Hassan
 
Concurrency Programming in Java - 01 - Introduction to Concurrency Programming
Concurrency Programming in Java - 01 - Introduction to Concurrency ProgrammingConcurrency Programming in Java - 01 - Introduction to Concurrency Programming
Concurrency Programming in Java - 01 - Introduction to Concurrency ProgrammingSachintha Gunasena
 
Top schools in gudgao
Top schools in gudgaoTop schools in gudgao
Top schools in gudgaoEdhole.com
 
Top schools in noida
Top schools in noidaTop schools in noida
Top schools in noidaEdhole.com
 
Top schools in gudgao
Top schools in gudgaoTop schools in gudgao
Top schools in gudgaoEdhole.com
 
EuroMPI 2013 presentation: McMPI
EuroMPI 2013 presentation: McMPIEuroMPI 2013 presentation: McMPI
EuroMPI 2013 presentation: McMPIDan Holmes
 
Configuring in the Browser, Really!
Configuring in the Browser, Really!Configuring in the Browser, Really!
Configuring in the Browser, Really!Tim Geisler
 
CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)Dilawar Khan
 
computer architecture and organization.ppt
computer architecture and organization.pptcomputer architecture and organization.ppt
computer architecture and organization.pptmuhammadosama0121
 
CS101- Introduction to Computing- Lecture 45
CS101- Introduction to Computing- Lecture 45CS101- Introduction to Computing- Lecture 45
CS101- Introduction to Computing- Lecture 45Bilal Ahmed
 
Reading Notes : the practice of programming
Reading Notes : the practice of programmingReading Notes : the practice of programming
Reading Notes : the practice of programmingJuggernaut Liu
 
6-9-2017-slides-vFinal.pptx
6-9-2017-slides-vFinal.pptx6-9-2017-slides-vFinal.pptx
6-9-2017-slides-vFinal.pptxSimRelokasi2
 
Peyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futurePeyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futureTakayuki Muranushi
 

Similar to Memory models (20)

Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...
 
Programming Languages #devcon2013
Programming Languages #devcon2013Programming Languages #devcon2013
Programming Languages #devcon2013
 
Introduction to multicore .ppt
Introduction to multicore .pptIntroduction to multicore .ppt
Introduction to multicore .ppt
 
Embedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals masterEmbedded c c++ programming fundamentals master
Embedded c c++ programming fundamentals master
 
intro.pptx
intro.pptxintro.pptx
intro.pptx
 
Concurrency Programming in Java - 01 - Introduction to Concurrency Programming
Concurrency Programming in Java - 01 - Introduction to Concurrency ProgrammingConcurrency Programming in Java - 01 - Introduction to Concurrency Programming
Concurrency Programming in Java - 01 - Introduction to Concurrency Programming
 
Top schools in gudgao
Top schools in gudgaoTop schools in gudgao
Top schools in gudgao
 
Introduction
IntroductionIntroduction
Introduction
 
Top schools in noida
Top schools in noidaTop schools in noida
Top schools in noida
 
Top schools in gudgao
Top schools in gudgaoTop schools in gudgao
Top schools in gudgao
 
EuroMPI 2013 presentation: McMPI
EuroMPI 2013 presentation: McMPIEuroMPI 2013 presentation: McMPI
EuroMPI 2013 presentation: McMPI
 
Compilers.pptx
Compilers.pptxCompilers.pptx
Compilers.pptx
 
Configuring in the Browser, Really!
Configuring in the Browser, Really!Configuring in the Browser, Really!
Configuring in the Browser, Really!
 
_intro.ppt
_intro.ppt_intro.ppt
_intro.ppt
 
CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)
 
computer architecture and organization.ppt
computer architecture and organization.pptcomputer architecture and organization.ppt
computer architecture and organization.ppt
 
CS101- Introduction to Computing- Lecture 45
CS101- Introduction to Computing- Lecture 45CS101- Introduction to Computing- Lecture 45
CS101- Introduction to Computing- Lecture 45
 
Reading Notes : the practice of programming
Reading Notes : the practice of programmingReading Notes : the practice of programming
Reading Notes : the practice of programming
 
6-9-2017-slides-vFinal.pptx
6-9-2017-slides-vFinal.pptx6-9-2017-slides-vFinal.pptx
6-9-2017-slides-vFinal.pptx
 
Peyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futurePeyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_future
 

More from Dr. C.V. Suresh Babu (20)

Data analytics with R
Data analytics with RData analytics with R
Data analytics with R
 
Association rules
Association rulesAssociation rules
Association rules
 
Clustering
ClusteringClustering
Clustering
 
Classification
ClassificationClassification
Classification
 
Blue property assumptions.
Blue property assumptions.Blue property assumptions.
Blue property assumptions.
 
Introduction to regression
Introduction to regressionIntroduction to regression
Introduction to regression
 
DART
DARTDART
DART
 
Mycin
MycinMycin
Mycin
 
Expert systems
Expert systemsExpert systems
Expert systems
 
Dempster shafer theory
Dempster shafer theoryDempster shafer theory
Dempster shafer theory
 
Bayes network
Bayes networkBayes network
Bayes network
 
Bayes' theorem
Bayes' theoremBayes' theorem
Bayes' theorem
 
Knowledge based agents
Knowledge based agentsKnowledge based agents
Knowledge based agents
 
Rule based system
Rule based systemRule based system
Rule based system
 
Formal Logic in AI
Formal Logic in AIFormal Logic in AI
Formal Logic in AI
 
Production based system
Production based systemProduction based system
Production based system
 
Game playing in AI
Game playing in AIGame playing in AI
Game playing in AI
 
Diagnosis test of diabetics and hypertension by AI
Diagnosis test of diabetics and hypertension by AIDiagnosis test of diabetics and hypertension by AI
Diagnosis test of diabetics and hypertension by AI
 
A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”
 
A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”
 

Recently uploaded

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 

Recently uploaded (20)

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 

Memory models

  • 2. Memory Consistency Models Parallelism for the masses! Shared-memory most common Memory model = Legal values for reads
  • 3. Memory Consistency Models Parallelism for the masses! Shared-memory most common Memory model = Legal values for reads
  • 4. Memory Consistency Models Parallelism for the masses! Shared-memory most common Memory model = Legal values for reads
  • 5. Memory Consistency Models Parallelism for the masses! Shared-memory most common Memory model = Legal values for reads
  • 6. Memory Consistency Models Parallelism for the masses! Shared-memory most common Memory model = Legal values for reads
  • 7. 20 Years of Memory Models • Memory model is at the heart of concurrency semantics – 20 year journey from confusion to convergence at last! – Hard lessons learned – Implications for future • Current way to specify concurrency semantics is too hard – Fundamentally broken • Must rethink parallel languages and hardware • Implications for broader CS disciplines
  • 8. What is a Memory Model? • Memory model defines what values a read can return Initially A=B=C=Flag=0 Thread 1 Thread 2 A = 26 while (Flag != 1) {;} 90 B = 90 r1 = B 26 0 … r2 = A Flag = 1 …
  • 9. Memory Model is Key to Concurrency Semantics • Interface between program and transformers of program – Defines what values a read can return Compiler Assembly C++ program Dynamic optimizer Hardware • Weakest system component exposed to the programmer – Language level model has implications for hardware • Interface must last beyond trends
  • 10. Desirable Properties of a Memory Model • 3 Ps – Programmability – Performance – Portability • Challenge: hard to satisfy all 3 Ps – Late 1980’s - 90’s: Largely driven by hardware • Lots of models, little consensus – 2000 onwards: Largely driven by languages/compilers • Consensus model for Java, C++ (C, others ongoing) • Had to deal with mismatches in hardware models Path to convergence has lessons for future
  • 11. Programmability – SC [Lamport79] • Programmability: Sequential consistency (SC) most intuitive – Operations of a single thread in program order – All operations in a total order or atomic • But Performance? – Recent (complex) hardware techniques boost performance with SC – But compiler transformations still inhibited • But Portability? – Almost all h/w, compilers violate SC today ⇒SC not practical, but…
  • 12. Next Best Thing – SC Almost Always • Parallel programming too hard even with SC – Programmers (want to) write well structured code – Explicit synchronization, no data races Thread 1 Thread 2 Lock(L) Lock(L) Read Data1 Read Data2 Write Data2 Write Data1 … … Unlock(L) Unlock(L) – SC for such programs much easier: can reorder data accesses ⇒ Data-race-free model [AdveHill90] – SC for data-race-free programs – No guarantees for programs with data races
  • 13. Definition of a Data Race • Distinguish between data and non-data (synchronization) accesses • Only need to define for SC executions ⇒ total order • Two memory accesses form a race if – From different threads, to same location, at least one is a write – Occur one after another Thread 1 Write, A, 26 Write, B, 90 Thread 2 Read, Flag, 0 Write, Flag, 1 Read, Flag, 1 Read, B, 90 Read, A, 26 • A race with a data access is a data race • Data-race-free-program = No data race in any SC execution
  • 14. Data-Race-Free Model Data-race-free model = SC for data-race-free programs – Does not preclude races for wait-free constructs, etc. • Requires races be explicitly identified as synchronization • E.g., use volatile variables in Java, atomics in C++ – Dekker’s algorithm Initially Flag1 = Flag2 = 0 volatile Flag1, Flag2 Thread1 Flag1 = 1 if Flag2 == 0 //critical section Thread2 Flag2 = 1 if Flag1 == 0 //critical section SC prohibits both loads returning 0
  • 15. Data-Race-Free Approach • Programmer’s model: SC for data-race-free programs • Programmability – Simplicity of SC, for data-race-free programs • Performance – Specifies minimal constraints (for SC-centric view) • Portability – Language must provide way to identify races – Hardware must provide way to preserve ordering on races – Compiler must translate correctly
  • 16. 1990's in Practice (The Memory Models Mess) • Hardware – Implementation/performance-centric view LD LD LD – Various ordering guarantees + fences to impose other orders – Many ambiguities - due to complexity, by design(?), … • High-level languages – Most shared-memory programming with Pthreads, OpenMP • Incomplete, ambiguous model specs • Memory model property of language, not library [Boehm05] – Java – commercially successful language with threads • Chapter 17 of Java language spec on memory model • But hard to interpret, badly broken ST Fence – Different vendors had different models – most non-SC • Alpha, Sun, x86, Itanium, IBM, AMD, HP, Cray, … ST ST LD ST
  • 17. 2000 – 2004: Java Memory Model • ~ 2000: Bill Pugh publicized fatal flaws in Java model • Lobbied Sun to form expert group to revise Java model • Open process via mailing list – – – – Diverse participants Took 5 years of intense, spirited debates Many competing models Final consensus model approved in 2005 for Java 5.0 [MansonPughAdve POPL 2005]
  • 18. Java Memory Model Highlights • Quick agreement that SC for data-race-free was required • Missing piece: Semantics for programs with data races – Java cannot have undefined semantics for ANY program – Must ensure safety/security guarantees – Limit damage from data races in untrusted code • Goal: Satisfy security/safety, w/ maximum system flexibility – Problem: “safety/security, limited damage” w/ threads very vague
  • 19. Java Memory Model Highlights Initially X=Y=0 Thread 1 r1 = X Y = r1 Thread 2 r2 = Y X = r2 Is r1=r2=42 allowed? Data races produce causality loop! Definition of a causality loop was surprisingly hard Common compiler optimizations seem to violate“causality”
  • 20. Java Memory Model Highlights • Final model based on consensus, but complex – Programmers can (must) use “SC for data-race-free” – But system designers must deal with complexity – Correctness tools, racy programs, debuggers, …?? – Recent discovery of bugs [SevcikAspinall08]
  • 21. 2005 - :C++, Microsoft Prism, Multicore • ~ 2005: Hans Boehm initiated C++ concurrency model – Prior status: no threads in C++, most concurrency w/ Pthreads • Microsoft concurrently started its own internal effort • C++ easier than Java because it is unsafe – Data-race-free is plausible model • BUT multicore ⇒ New h/w optimizations, more scrutiny – Mismatched h/w, programming views became painfully obvious – Debate that SC for data-race-free inefficient w/ hardware models
  • 22. C++ Challenges 2006: Pressure to change Java/C++ to remove SC baseline To accommodate some hardware vendors • But what is alternative? – Must allow some hardware optimizations – But must be teachable to undergrads • Showed such an alternative (probably) does not exist
  • 23. C++ Compromise • Default C++ model is data-race-free • AMD, Intel, … on board • But – Some systems need expensive fence for SC – Some programmers really want more flexibility • C++ specifies low-level atomics only for experts • Complicates spec, but only for experts • We are not advertising this part – [BoehmAdve PLDI 2008]
  • 24. Summary of Current Status • Convergence to “SC for data-race-free” as baseline • For programs with data races – Minimal but complex semantics for safe languages – No semantics for unsafe languages
  • 25. Lessons Learned • Specifying semantics for programs with data races is HARD – But “no semantics for data races” also has problems • Not an option for safe languages • Debugging, correctness checking tools • Hardware-software mismatch for some code – “Simple” optimizations have unintended consequences ⇒State-of-the-art is fundamentally broken
  • 26. Lessons Learned • Specifying semantics for programs with data races is HARD – But “no semantics for data races” also has problems • Not an option for safe languages • Debugging, correctness checking tools Banish mismatch for some code • Hardware-softwareshared-memory? – “Simple” optimizations have unintended consequences ⇒State-of-the-art is fundamentally broken
  • 27. Lessons Learned • Specifying semantics for programs with data races is HARD – But “no semantics for data races” also has problems • Not an option for safe languages • Debugging, correctness checking tools Banish wild shared-memory! • Hardware-software mismatch for some code – “Simple” optimizations have unintended consequences ⇒State-of-the-art is fundamentally broken • We need – Higher-level disciplined models that enforce discipline – Hardware co-designed with high-level models
  • 28. Research Agenda for Languages • Disciplined shared-memory models – Simple – Enforceable – Expressive – Performance Key: What discipline? How to enforce it?
  • 29. Data-Race-Free • A near-term discipline: Data-race-free • Enforcement – Ideally, language prohibits by design – e.g., ownership types [Boyapati+02] – Else, runtime catches as exception e.g., Goldilocks [Elmas+07] • But work still needed for expressivity and/or performance • But data-race-free still not sufficiently high level
  • 30. Deterministic-by-Default Parallel Programming • Even data-race-free parallel programs are too hard – Multiple interleavings due to unordered synchronization (or races) – Makes reasoning and testing hard • But many algorithms are deterministic – Fixed input gives fixed output – Standard model for sequential programs – Also holds for many transformative parallel programs • Parallelism not part of problem specification, only for performance Why write such an algorithm in non-deterministic style, then struggle to understand and control its behavior?
  • 31. Deterministic-by-Default Model • Parallel programs should be deterministic-by-default – Sequential semantics (easier than SC!) • If non-determinism is needed – should be explicitly requested, encapsulated – should not interfere with guarantees for the rest of the program • Enforcement: – Ideally, language prohibits by design – Else, runtime catches violations as exceptions
  • 32. State-of-the-art • Many deterministic languages today – Functional, pure data parallel, some domain-specific, … – Much recent work on runtime, library-based approaches – E.g., Allen09, Divietti09, Olszewski09, … • Our work: Language approach for modern O-O methods – Deterministic Parallel Java (DPJ) [V. Adve et al.]
  • 33. Deterministic Parallel Java (DPJ) • Object-oriented type and effect system – – – – Aliasing information: partition the heap into “regions” Effect specifications: regions read or written by each method Language guarantees determinism through type checking Side benefit: regions, effects are valuable documentation • Implemented as extension to base Java type system – – – – Initial evaluation for expressivity, performance [Bocchino+09] Semi-automatic tool for region annotations [Vakilian+09] Recent work on encapsulating frameworks and unchecked code Ongoing work on integrating non-determinism
  • 34. Implications for Hardware • Current hardware not matched even to current model • Near term: ISA changes, speculation • Long term: Co-design hardware with new software models – Use disciplined software to make more efficient hardware – Use hardware to support disciplined software
  • 35. Illinois DeNovo Project • How to design hardware from the ground up to – Exploit disciplined parallelism • for better performance, power, … – Support disciplined parallelism • for better dependability • Working with DPJ to exploit region, effect information – Software-assisted coherence, communication, scheduling – New hardware/software interface – Opportune time as we determine how to scale multicore
  • 36. Conclusions • Current way to specify concurrency semantics fundamentally broken – Best we can do is SC for data-race-free • But cannot hide from programs with data races – Mismatched hardware-software • Simple optimizations give unintended consequences • Need – High-level disciplined models that enforce discipline – Hardware co-designed with high-level models • E.g., DPJ, DeNovo – Implications for many CS communities