1 / 20


ECE 647 TERM PROJECT. MiniSAT parallelization Shahadat Hossain Saud Wasly. Agenda . Introduction MiniSAT Background MiniSAT Algorithm Objectives Difficulties Implemented changes Results Conclusion Questions. The SAT Problem + MiniSAT.

Télécharger la présentation


An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.


Presentation Transcript

  1. ECE 647 TERM PROJECT MiniSAT parallelization ShahadatHossain Saud Wasly

  2. Agenda • Introduction • MiniSAT Background • MiniSAT Algorithm • Objectives • Difficulties • Implemented changes • Results • Conclusion • Questions

  3. The SAT Problem + MiniSAT • Boolean Satisfiablity is a mathematical problem to find if a given set of variables can be assigned in a such a way that all given constraints are met • SAT problems commonly arise in EDA applications • MiniSAT is an open source SAT solver created in 2003 • Designed to be extensible; Original code was ~700 lines • Current code ~1k lines • SAT competition • Main track: Optimize any SAT solver • Parallel track: parallelize any SAT solver • MiniSAT Hack track: minor changes to miniSAT

  4. Format and Terminology • SAT problems are presented in Conjunctive Normal Form (CNF) • F=(x1 v ¬x2 v ¬x3) ∧ (¬ x1 x5 ¬x7 x20) ∧ (...) ∧ ... • Variables: x1, x2, x3, ... • Literals: A variable and its negation • x1 AND ¬ x1, x2 AND ¬ x2, ... • Clause: A collection of variables that have an OR relationship • (x1 v ¬x2 v ¬x3) • A clause can be true, false, free, or asserting

  5. Internal Structures c simple_v3_c2.cnf c p cnf 3 2 1 -3 0 2 3 -1 0 • Clause Database: Contains all clauses (input constraints) and all assigned literals • Learnts: Vector of literals that have been learnt from assertions • Trail: Literal path taken so far • Watches: Vector of literals to watch since they are closely related to those that have been changed • Order Heap: Priority heap • Decision Level: The level an assertion has been propagated to; used for backtracking

  6. MiniSAT Algorithm • MiniSAT uses 2 methods to solve a SAT problem: • Conflict-driven backtracking • Program makes assertions on variables • When clause becomes asserting, MiniSAT ‘learns’ a literal • When a conflict arises, backtrack and ‘unlearn’ literals • Dynamic Variable Ordering* • When literal is asserted, related literal is moved to top of stack • Exit Condition • All literals assigned (SAT), no conflicts • Backtracked to root of tree (UNSAT)

  7. Parallelization • Why Parallelize? • Large problems can take hours to solve • On modern multi-core computers, MiniSAT isn’t taking advantage of total processing power • MiniSAT is essentially a trial-and-error algorithm, should benefit from multiple copies of same program • MiniSAT occasionally learns constraints, data that be shared between threads

  8. Proposed Improvements • Parallelize base program • Task parallel vs. Data parallel • Parallelize tasks (with synchronization) or copy entire program • Assign different heuristics to different threads • Current MiniSAT uses activity based (dynamic) prioritization • Excellent for single thread, but cannot be extended • Divide Literal branches and assign a sequential heuristic* • Assign a random heuristic within a given solution space* • Hybrid heuristic combining all 3 • Share common database between threads** • Difficult to implement because of backtracking • Only clauseDB is global, and frequent R/W will become a bottleneck

  9. Implementation • Currently have multiple threads working in parallel • Threads are synchronized for exit • Thread creation is dynamic, based on the number of cores in the system • Preventing OS from changing core assignment • Currently have 3 working heuristics • Single processor execution results in original miniSAT (activity based stack heuristic) • 2nd thread will be a FIFO search algorithm • Following threads will be random search heuristics* • All new heuristics are activity based, but have different prioritization • Random decisions are randomized based on thread • When there is no chain activity to follow, miniSAT makes a random decision • Random decision is seeded with thread ID and is thus unrelated from thread to thread

  10. Challenges • Testing • CNF files can be extremely large and time consuming to solve • SAT competition benchmark files can have over 200,000 variables and take 30+ mins to solve • Poorly Written Code • Algorithms are clearly defined in documentation, but actual code has very few comments • Variable names are not always descriptive • Thread and data synchronization • Data structures are large and smaller structures are prone to ‘backtracking’ • Multiple solutions • A SAT problem may have more than 1 possible solution • Verifying a solution?

  11. Tradeoffs - Algorithm • Initial activity based heuristic has variable performance • Because of the way MiniSAT is programmed, changing the input variable order has a significant impact on processing time • Ordered Heap is a stack implementation, so removing from the bottom adds considerable processing time • Virtually requires a rebuilding of the stack every time • Ideally, a few threads will execute sequentially, while other threads “learn” randomly for the main threads • Requires a moderate level of communication between threads

  12. Tradeoffs - Parallelization • Frequent access to shared/protected data reduces processing speed • For long literals and deep propagations, parallelization should be useful • More threads result in more memory usage • Leads to frequent garbage collection • Reduces work space of every thread

  13. Work Remaining • Introduce data sharing/synchronization • Small data structures (e.g: learnts list)cannot be shared because of backtracking • Sharing learnt would require tracking of which thread has learned what, so the appropriate part can be ‘unlearnt’ • After unlearning, the entire list would have to be recreated • Requires substantial changes to existing code and algorithm • Large data structures (e.g: clauseDB) are ideal for sharing • Would reduce the overall memory usage • Would slow down processing time because of frequent access • Actual database structure is not well defined

  14. Ideal Implementation • Functions currently built to search branches independently • With data synchronization, separate branches can help each other by learning new information and introducing new constraints

  15. Preliminary Results • The sequential heuristic can beat the miniSAT heuristic in some cases • Because of random variables introduced, the execution time of multiple threads is variable • Tested small problem on 2 cores • Execution time depends on particular CNF file used • Sequential heuristic is occasionally better (by as much as 20%) • Tested small problem on 6 cores (ecelinux), but system has memory/quota issues • Time tracking is potentially incorrect on multicore • Re-implemented to reflect actual time

  16. Preliminary Results 2 Original miniSAT output Parallelized miniSAT output

  17. Conclusion • Synchronization of parallel miniSAT is an extremely complex problem • Provides excellent exposure to SAT solving algorithm (DPLL algorithm) and practical problems faced while implementing • 4 competitors in 2009 SAT competition • No solver could solve hard difficulty SAT problems within time limit

  18. SAT competition Results • MiniSAT performance is hard to beat!! • Only 1 contestant from the parallel group placed in the top 20 (ManySAT) • Modifications can result in previously solvable problems becoming unsolvable

  19. Reference • 2009 Sat Competition Results www.satcompetition.org/2009/sat09comp-slides.pdf • POSIX thread (pthread) libraries http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html

  20. Questions

More Related