Presentation is loading. Please wait.

Presentation is loading. Please wait.

Bit-Vector Optimization ALEXANDER NADER AND VADIM RYVCHIN INTEL TACAS 2016.

Similar presentations


Presentation on theme: "Bit-Vector Optimization ALEXANDER NADER AND VADIM RYVCHIN INTEL TACAS 2016."— Presentation transcript:

1 Bit-Vector Optimization ALEXANDER NADER AND VADIM RYVCHIN INTEL TACAS 2016

2  Bit-vector – (example: unsinged 7 bit type)  Logical Operands (OR, AND, XOR, IMPLIES, ITE…)  Basic math operands (+, -, *, /, mod, >, <, …)  Assertions  … 2 Bit-Vector SMT V 1 : Bitvector[16] V 2 : Bitvector[16] V 1 := 0x4 Assert(V 2 > 3) U := V 1 + V 2 (check-sat) Satisfiable V 1 = 0x4 V 2 = 0x6 U = 0xA

3  Input:  BV Formula F  Term t[n]=[t n-1, t n-2, …, t 0 ]  Output:  Satisfiable solution for F which maximizes t. 3 Optimization Bit-Vector (OBV) V 1 : Bitvector[16] V 2 : Bitvector[16] V 1 := 0x4 U := V 1 + V 2 M := ¬U (maximize M) Satisfiable V 1 = 0x4 V 2 = 0x0 U = 0x4 M = 0xFFFB

4  Naïve Approaches : Linear and Binary search  Weighted MAX-SAT : applied in extension to Z3, vZ 4 OBV – Previous Work

5  Given a satisfiable formula F and the optimization target t[n]: 1. Solve F with SMT Solver 2. while Solve return SAT do 1. res = value(t) 2. Assert t > res 3. Solve F with an SMT Solver 3. return last model returned by Solve 5 Naïve Linear Search (NLS) t=v 0  t=v 1  t=v 2 … : v 0 < v 1 < v 2 …

6  Given a satisfiable formula F and the optimization target t[n]: 1. Solve F with SMT Solver 2. min = value(t), max = 2 n -1 3. while min < max do 1. Assert t > (min + (max – min)/2) 2. Solve F with an SMT Solver 3. If SAT: min = (min + (max – min)/2) 4. If UNSAT: max = (min + (max – min)/2) 4. return last model returned by Solve 6 Naïve Binary Search (NBS) 0 2 n -1 v0v0 max min t > mid

7  Given a satisfiable formula F and the optimization target t[n]: 1. Solve F with SMT Solver 2. min = value(t), max = 2 n -1 3. while min < max do 1. Assert t > (min + (max – min)/2) 2. Solve F with an SMT Solver 3. If SAT: min = (min + (max – min)/2) 4. If UNSAT: max = (min + (max – min)/2) 4. return last model returned by Solve 7 Naïve Binary Search (NBS) 0 2 n -1 v0v0 max min

8  MAX-SAT:  Input: hard clauses and soft weighted clauses  Solution: satisfies all hard clauses and maximizes the weight of soft clauses.  Given a satisfiable formula F and the optimization target t[n]:  Preprocess and Translate F to MAX-SAT Format:  Each CNF clause is a hard clause  Weighted Soft: { ( t i ), w=2 i : i = 0..n-1}  Run MAX-SAT Solver 8 Weighted MAX-SAT Approach

9  Naïve Linear Search  Naïve Binary Search  Weighted MAX-SAT approach  Weak Assumptions Optimization  Inline Binary Search 9 How to solve OBV? Our approaches

10  Use Minisat’s Assumptions scheme for the solution  Given a satisfiable formula F and the optimization target t[n]: 1. Pre-process and Translate F to CNF 2. Solve F with SAT Solver with t[n] as weak assumptions: t n-1, t n-2, …, t 0 10 Optimization with Weak Assumptions – OBV-WA

11  First decisions with specific order starting from MSB t n-1 toward LSB t 0.  If negation of one assumption is implied by other assumptions (during BCP):  It continues to the next assumption (in contrast to Minisat’s approach) 11 Weak Assumptions

12  t n-1 - The first decision OBV-WA Example t n-1 v1v1v1v1 ¬v 2 decision level 1 First Decision t n- 1 BCP

13  t n-1 - The first decision  t n-2 - The second decision  t n-3 - The third decision OBV-WA Example t n-1 v1v1v1v1 ¬v 2 decision level 1 t n-2 ¬v 3 v4v4v4v4 decision level 2 t n-3 v4v4v4v4 decision level 3

14  t n-1 - The first decision  t n-2 - The second decision  t n-3 - The third decision OBV-WA Example t n-1 v1v1v1v1 ¬v 2 decision level 1 t n-2 ¬v 3 v4v4v4v4 decision level 2 t n-3 v4v4v4v4 decision level 3 BackTrack

15  t n-1 - The first decision  t n-2 - The second decision  ¬t n-3 – Implied by t n-1 OBV-WA Example t n-1 v1v1v1v1 ¬v 2 decision level 1 ¬t n-3 t n-2

16  Check satisfiability of F: from t = 2 n-1 towards t = 0  t is decreased by δ > 1 when no model between [t; t - δ + 1] 16 OBV-WA

17  Given a satisfiable formula F and the optimization target t[n]: 1. Pre-process and Translate F to CNF 2. µ = SAT() // (Solve F with SMT Solver = SAT()) 3. a = {} 4. For i : n–1.. 0 do 1. If t i  µ then a = a U {t i } 2. Else β = SatUnderAssumptions(a U {t i }) 1. If β is a model then µ = β, a = a U {t i } 2. Else a = a U {¬t i } 5. Return µ 17 Optimization with Inline Binary Search – OBV-BS

18 18 OBV-BS Example t n-1 t n-2 t n-3 t n-4 t0t0 Assume

19 19 OBV-BS Example t n-1 t n-2 t n-3 t n-4 t0t0 Assume Run SAT SolverResult SAT

20 20 OBV-BS Example t n-3 t n-4 t0t0 SATUNSAT

21 21 OBV-BS Example t n-3 t n-4 t0t0 Assume

22 22 OBV-BS Example t0t0

23  Which one is better?  Depends on the problem: if almost all t i are 1 then OBV-WA as it assigns 1 to all bits first, otherwise OBV-BS 23 OBV-WA vs. OBV-BS

24 Our Application in Chip Design 24

25 Chip Design Fixer 25 "PhysicalDesign" by Linear77 - Own work. Licensed under CC BY 3.0 via Wikimedia Commons - https://commons.wikimedia.org/wiki/File:PhysicalDesign.png#/media/File:PhysicalDesign.png

26 General Cell Placement Problem  Cell – A basic logic or a memory element  Grid – Set of placement locations  Input:  Set of cells  Placement Grid  Constraints:  Non-overlapping constraints  Timing constraints  Thermal constraints  Output:  A legal placement satisfies all the constraints 26

27 Our Problem - Placement Fixer  Assumption: Placement of standard cells has already been generated  A new set of design constraints of different priority, introduced late in the process  Re-running the placer from scratch is not an option:  Satisfy backward compatibility  Stability  Run-time requirements  Post-processing fixer tool is required 27

28 Placement Fixer Problem  Input:  Grid of size (X; Y )  Set of n non-overlapping (but possibly touching) rectangles placed on the grid  Allowed movement for of cells on the grid  Violations between pairs of touching rectangles  Each violation has a unique priority  Parity preservation : for each rectangle the y- coordinate at the new location must be even if the original y-coordinate is even.  Output:  New cells placement while minimizing violations 28

29 Placement Problem P(b, t, d): b – bottom cell t – top cell d - delta 29

30 Placement Solution 30

31 Our Solution  For every shiftable cell:  Declare two variables x,y representing possible locations on the grid  Limit x,y by the allowed movement  y mod 2 == parity constraint  For every pair of cells:  Prevent overlapping if they can overlap  For each potential violation add bit to bitvector in increasing priority order – receiving a long bitvector  Minimize the bitvector  done efficiently using our SMT solver 31

32  We encoded our problem to LIA  Opti-MathSAT  Zv – LIA 32 Additional Reduction

33 33 Experimental Results

34 34 OBV-WA vs. OBV-BS

35 35


Download ppt "Bit-Vector Optimization ALEXANDER NADER AND VADIM RYVCHIN INTEL TACAS 2016."

Similar presentations


Ads by Google