Greta YorshEran YahavMartin Vechev IBM Research. { ……………… …… …………………. ……………………. ………………………… } P1() Challenge: Correct and Efficient Synchronization { ……………………………

Slides:



Advertisements
Similar presentations
Abstraction of Source Code (from Bandera lectures and talks)
Advertisements

Introduction to Formal Methods for SW and HW Development 09: SAT Based Abstraction/Refinement in Model-Checking Roberto Sebastiani Based on work and slides.
Greta YorshEran YahavMartin Vechev IBM Research. { ……………… …… …………………. ……………………. ………………………… } T1() Challenge: Correct and Efficient Synchronization { ……………………………
SAT Based Abstraction/Refinement in Model-Checking Based on work by E. Clarke, A. Gupta, J. Kukula, O. Strichman (CAV’02)
Introducing Formal Methods, Module 1, Version 1.1, Oct., Formal Specification and Analytical Verification L 5.
Compilation 2011 Static Analysis Johnni Winther Michael I. Schwartzbach Aarhus University.
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
“FENDER” AUTOMATIC MEMORY FENCE INFERENCE Presented by Michael Kuperstein, Technion Joint work with Martin Vechev and Eran Yahav, IBM Research 1.
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
1 Eran Yahav Technion Joint work with Martin Vechev (ETH), Greta Yorsh (ARM), Michael Kuperstein (Technion), Veselin Raychev (ETH)
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 5: Process Synchronization.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 7: Greedy Algorithms
Fall Semantics Juan Carlos Guzmán CS 3123 Programming Languages Concepts Southern Polytechnic State University.
Martin Vechev IBM Research Michael Kuperstein Technion Eran Yahav Technion (FMCAD’10, PLDI’11) 1.
Inferring Synchronization under Limited Observability Martin Vechev Eran Yahav Greta Yorsh IBM T.J. Watson Research Center.
Plan for today Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search.
1 Lecture 09 – Synthesis of Synchronization Eran Yahav.
Chapter 2: Algorithm Discovery and Design
Synthesis of Interface Specifications for Java Classes Rajeev Alur University of Pennsylvania Joint work with P. Cerny, G. Gupta, P. Madhusudan, W. Nam,
1 Completeness and Complexity of Bounded Model Checking.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
The Software Product Life Cycle. Views of the Software Product Life Cycle  Management  Software engineering  Engineering design  Architectural design.
Chapter 2: Algorithm Discovery and Design
Chapter 2: Algorithm Discovery and Design
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
Maria-Cristina Marinescu Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology A Synthesis Algorithm for Modular Design of.
Maria-Cristina Marinescu Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology High-level Specification and Efficient Implementation.
Procedure specifications CSE 331. Outline Satisfying a specification; substitutability Stronger and weaker specifications - Comparing by hand - Comparing.
ARTIST Summer School in Europe 2009 Autrans (near Grenoble), France September 7-11, 2009 Invited Speaker: Eran Yahav IBM T.J. Watson Research Center.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition.
Invitation to Computer Science 6th Edition
Invitation to Computer Science, Java Version, Second Edition.
Race Checking by Context Inference Tom Henzinger Ranjit Jhala Rupak Majumdar UC Berkeley.
Automatic Verification of Finite-State Concurrent Systems Using Temporal Logic Specifications 1.
Type Systems CS Definitions Program analysis Discovering facts about programs. Dynamic analysis Program analysis by using program executions.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
1 Introduction to Software Engineering Lecture 1.
COMP 111 Threads and concurrency Sept 28, Tufts University Computer Science2 Who is this guy? I am not Prof. Couch Obvious? Sam Guyer New assistant.
Lazy Abstraction Jinseong Jeon ARCS, KAIST CS750b, KAIST2/26 References Lazy Abstraction –Thomas A. Henzinger et al., POPL ’02 Software verification.
Inferring Synchronization under Limited Observability Martin Vechev, Eran Yahav, Greta Yorsh IBM T.J. Watson Research Center (work in progress)
Introduction to Problem Solving. Steps in Programming A Very Simplified Picture –Problem Definition & Analysis – High Level Strategy for a solution –Arriving.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization.
Memory Consistency Models. Outline Review of multi-threaded program execution on uniprocessor Need for memory consistency models Sequential consistency.
Symbolic Execution with Abstract Subsumption Checking Saswat Anand College of Computing, Georgia Institute of Technology Corina Păsăreanu QSS, NASA Ames.
Semantics In Text: Chapter 3.
Automated Patch Generation Adapted from Tevfik Bultan’s Lecture.
Pattern-based Synthesis of Synchronization for the C++ Memory Model Yuri Meshman, Noam Rinetzky, Eran Yahav 1.
Ch. 13 Ch. 131 jcmt CSE 3302 Programming Languages CSE3302 Programming Languages (notes?) Dr. Carter Tiernan.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
CIS 842: Specification and Verification of Reactive Systems Lecture INTRO-Examples: Simple BIR-Lite Examples Copyright 2004, Matt Dwyer, John Hatcliff,
Scientific Debugging. Errors in Software Errors are unexpected behaviors or outputs in programs As long as software is developed by humans, it will contain.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles Synchronization Emery Berger and Mark Corner University.
CS182 Intelligent Machines: Reasoning, Actions and Plans Section 4.
CS 153 Design of Operating Systems Winter 2016 Lecture 7: Synchronization.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science.
Exhaustive search Exhaustive search is simply a brute- force approach to combinatorial problems. It suggests generating each and every element of the problem.
Maitrayee Mukerji. INPUT MEMORY PROCESS OUTPUT DATA INFO.
Abstraction and Refinement for Large Scale Model Checking
Memory Consistency Models
Memory Consistency Models
Introduction to Software Verification
Abstraction-Guided Synthesis
Objective of This Course
Over-Approximating Boolean Programs with Unbounded Thread Creation
Synthesis of Memory Fences via Refinement Propagation
Abstraction, Verification & Refinement
Abstraction-Guided Synthesis of synchronization
Presentation transcript:

Greta YorshEran YahavMartin Vechev IBM Research

{ ……………… …… …………………. ……………………. ………………………… } P1() Challenge: Correct and Efficient Synchronization { …………………………… ……………………. … } P2() atomic { ………………….. …… ……………………. ……………… …………………… } P3() atomic Safety Specification: S

Challenge: Correct and Efficient Synchronization { ……………… …… …………………. ……………………. ………………………… } P1() { …………………………… ……………………. … } P2() { ………………….. …… ……………………. ……………… …………………… } P3() Safety Specification: S

Challenge  Assumption: serial executions satisfy the specification  Find minimal synchronization that makes the program satisfy the specification  Avoid all bad interleaving while permitting as many good interleavings as possible  Handle infinite-state programs

Our Approach  Synthesis of synchronization via abstract interpretation  Compute over-approximation of all possible program executions  Add minimal atomics to avoid (over approximation of) bad interleavings  Interplay between abstraction and synchronization  Finer abstraction may enable finer synchronization  Coarse synchronization may enable coarser abstraction

Change the abstraction to match the program Standard Approach: Abstraction Refinement program specification Abstract counter example abstraction Abstraction Refinement  Abstract counter example Verify Valid

program specification Abstract counter example abstraction Abstraction Refinement Change the program to match the abstraction   Verify Our Approach: Abstraction-Guided Synthesis Program Restriction Implement P’ Abstract counter example

AGS Algorithm – High Level  = true while(  P        S) { select   (  P       ) and   S if (?) {  =   avoid(  ) } else {  = refine( ,  ) } return implement(P,  ) Input: Program P, Specification S, Abstraction  Output: Program P’ satisfying S under 

Avoiding an interleaving  By adding atomicity constraints  Atomicity predicate [l1,l2] – no context switch allowed between execution of statements at l1 and l2  avoid(  )  A disjunction of all possible atomicity predicates that would prevent   Example   = A 1 B 1 A 2 B 2  avoid(  ) = [A 1,A 2 ]  [B 1,B 2 ]  (abuse of notation)

Example T1 1: x += z 2: x += z T2 1: z++ 2: z++ T3 1: y1 = f(x) 2: y2 = x 3: assert(y1 != y2) f(x) { if (x == 1) return 3 else if (x == 2) return 6 else return 5 }

Example: Parity Abstraction y2 y1 1 Concrete values y2 y1 1 Parity abstraction (even/odd)

Example: Avoiding Bad Interleavings  = true while(  P        S) { select   (  P       ) and   S if (?) {  =   avoid(  ) } else {  = refine( ,  ) } return implement(P,  ) avoid(  1 ) = [z++,z++]  = [z++,z++]  = true

Example: Avoiding Bad Interleavings  = true while(  P        S) { select   (  P       ) and   S if (?) {  =   avoid(  ) } else {  = refine( ,  ) } return implement(P,  ) avoid(  2 ) =[x+=z,x+=z]  = [z++,z++]  = [z++,z++]  [x+=z,x+=z]

Example: Avoiding Bad Interleavings  = true while(  P        S) { select   (  P       ) and   S if (?) {  =   avoid(  ) } else {  = refine( ,  ) } return implement(P,  ) T1 1: x += z 2: x += z T2 1: z++ 2: z++ T3 1: y1 = f(x) 2: y2 = x 3: assert(y1 != y2)  = [z++,z++]  [x+=z,x+=z]

y2 y1 1 parity  parity x+=z; x+=z z++; y1=f(x) y2=x assert y1!= y2 T1 T2 T3 x+=z; x+=z z++; y1=f(x) y2=x assert y1!= y2 T1 T2 T3 x+=z; x+=z z++; y1=f(x) y2=x assert y1!= y2 T1 T2 T3 Example: Avoiding Bad Interleavings But we can also refine the abstraction…

y2 y parity interval octagon     (a)(b) (c) (d)(e) (f)(g) parity interval octagon x+=z; x+=z z++; y1=f(x) y2=x assert y1!= y2 T1 T2 T3 x+=z; x+=z z++; y1=f(x) y2=x assert y1!= y2 T1 T2 T3 x+=z; x+=z z++; y1=f(x) y2=x assert y1!= y2 T1 T2 T3 x+=z; x+=z z++; y1=f(x) y2=x assert y1!= y2 T1 T2 T3 x+=z; x+=z z++; y1=f(x) y2=x assert y1!= y2 T1 T2 T3 x+=z; x+=z z++; y1=f(x) y2=x assert y1!= y2 T1 T2 T3 x+=z; x+=z z++; y1=f(x) y2=x assert y1!= y2 T1 T2 T3

Quantitative Synthesis  Performance: smallest atomic sections  Interval abstraction for our example produces the atomicity constraint: ([x+=z,x+=z] ∨ [z++,z++]) ∧ ([y1=f(x),y2=x] ∨ [x+=z,x+=z] ∨ [z++,z++])  Minimal satisfying assignments   1 = [z++,z++]   2 = [x+=z,x+=z]

Backward Exploration of Invalid Interleavings. Using  to prune non-feasible interleavings. Order of selection might matter AGS Algorithm – More Details  = true while(  P        S) { select   (  P       ) and   S if (?) {  =   avoid(  ) } else {  = refine( ,  ) } return implement(P,  ) Input: Program P, Specification S, Abstraction  Output: Program P’ satisfying S under  Forward Abstract Interpretation, taking  into account for pruning non-feasible interleavings Choosing between Abstraction Refinement / Program Restricton. -Refinement not always possible - avoidance not always possible (e.g., serial interleaving) - may try and backtrack Up to this point did not commit to an implementation mechanism

Implementability  No program transformations (e.g., loop unrolling)  Memoryless strategy T1 1: while(*) { 2: x++ 3: x++ 4: } T2 1: assert (x != 1)  Separation between schedule constraints and how they are realized  Can realize in program: atomic sections, locks,…  Can realize in scheduler: benevolent scheduler

Examples Intuition  If can show disjoint access can avoid synchronization  Requires abstractions rich enough to capture access pattern to shared data Parity Intervals

Example: “Double Buffering” fill() { L1:if (i < N) { L2:Im[Fill][i] = read(); L3: i += 1; L4: goto L1; } L5: Fill ˆ= 1; L6: Render ˆ= 1; L7: i = 0; L8: goto L1; } render() { L1:if (j < N) { L2: write(Im[Render][j]); L3: j += 1; L4: goto L1; } L5: j = 0; L6: goto 1; } int Fill = 1; int Render = 0; int i = j = 0; main() { fill() || render(); } Render Fill

Experimental Results  Simplified versions of  Double buffering  Defragmentation  … ProgramRefine StepsAvoid Steps Double buffering12 Defragmentation18 3D array update223 Array Removal117 Array Init156

Summary  An algorithm for Abstraction-Guided Synthesis  Synthesize efficient and correct synchronization  Refine the abstraction and/or restrict program behavior  Interplay between abstraction and syncrhonization  Quantitative Synthesis  Separate characterization of solution from choosing optimal solutions (e.g., smallest atomic sections)  Handles infinite-state systems  Based on abstract interpretation  In the near future – more abstract domains…

Invited Questions 1. Why atomic sections? 2. Why not start from the most constrained program and work downwards (relaxing constraints)? 3. Can’t you solve the problem purely by brute force search of all atomic section placements? 4. Why use only a single CEX at a time? Could use information about the whole (abstract) transition system? 5. Is this related to supervisor synthesis?