GPU Acceleration of BCP Procedure for SAT Algorithms

Similar documents
From SAT To SMT: Part 1. Vijay Ganesh MIT

Parallel Rabin-Karp Algorithm Implementation on GPU (preliminary version)

Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber Aug 31, 2011

VLSI CAD: Lecture 4.1. Logic to Layout. Computational Boolean Algebra Representations: Satisfiability (SAT), Part 1

SAT-based Combinational Equivalence Checking

Formal Verification Methods 1: Propositional Logic

An instance of SAT is defined as (X, S)

A CUDA Solver for Helmholtz Equation

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

Integrating a SAT Solver with an LCF-style Theorem Prover

S0214 : GPU Based Stacking Sequence Generation For Composite Skins Using GA

Lecture Notes on SAT Solvers & DPLL

SAT-Solving: From Davis- Putnam to Zchaff and Beyond Day 3: Recent Developments. Lintao Zhang

arxiv: v1 [hep-lat] 7 Oct 2010

Fast SAT-based Answer Set Solver

Pythagorean Triples and SAT Solving

Propositional and First Order Reasoning

The Calculus of Computation: Decision Procedures with Applications to Verification. Part I: FOUNDATIONS. by Aaron Bradley Zohar Manna

FPGA Implementation of a Predictive Controller

Introduction to numerical computations on the GPU

Using a CUDA-Accelerated PGAS Model on a GPU Cluster for Bioinformatics

Chapter 7 R&N ICS 271 Fall 2017 Kalev Kask

Practical SAT Solving

Tutorial 1: Modern SMT Solvers and Verification

Planning as Satisfiability

Knowledge base (KB) = set of sentences in a formal language Declarative approach to building an agent (or other system):

#A32 INTEGERS 10 (2010), TWO NEW VAN DER WAERDEN NUMBERS: w(2; 3, 17) AND w(2; 3, 18)

LOGIC PROPOSITIONAL REASONING

Automated Program Verification and Testing 15414/15614 Fall 2016 Lecture 3: Practical SAT Solving

Using Graph-Based Representation to Derive Hard SAT instances

Propositional Logic: Evaluating the Formulas

Foundations of Artificial Intelligence

CRYPTOGRAPHIC COMPUTING

Propositional Logic: Methods of Proof (Part II)

Lecture 9: The Splitting Method for SAT

CS156: The Calculus of Computation

Incremental QBF Solving by DepQBF

SMT Unsat Core Minimization

A Lower Bound of 2 n Conditional Jumps for Boolean Satisfiability on A Random Access Machine

Verification using Satisfiability Checking, Predicate Abstraction, and Craig Interpolation. Himanshu Jain THESIS ORAL TALK

Propositional Logic. Methods & Tools for Software Engineering (MTSE) Fall Prof. Arie Gurfinkel

GPU Accelerated Markov Decision Processes in Crowd Simulation

Welcome to MCS 572. content and organization expectations of the course. definition and classification

Logical Agents. Chapter 7

Propositional Logic: Models and Proofs

Satisfiability and SAT Solvers. CS 270 Math Foundations of CS Jeremy Johnson

Calculation of ground states of few-body nuclei using NVIDIA CUDA technology

Lecture 2 Propositional Logic & SAT

Parallel stochastic simulation using graphics processing units for the Systems Biology Toolbox for MATLAB

Research into GPU accelerated pattern matching for applications in computer security

Satisifiability and Probabilistic Satisifiability

Hybrid CPU/GPU Acceleration of Detection of 2-SNP Epistatic Interactions in GWAS

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

Warm-Up Problem. Is the following true or false? 1/35

Comp487/587 - Boolean Formulas

NP-Completeness. NP-Completeness 1

Foundations of Artificial Intelligence

TR A Comparison of the Performance of SaP::GPU and Intel s Math Kernel Library (MKL) for Solving Dense Banded Linear Systems

Parallel Longest Common Subsequence using Graphics Hardware

An Exact Optimization Algorithm for Linear Decomposition of Index Generation Functions

Intelligent Agents. Pınar Yolum Utrecht University

Multiphase Flow Simulations in Inclined Tubes with Lattice Boltzmann Method on GPU

Solving PDEs with CUDA Jonathan Cohen

Enrico Giunchiglia, Massimo Narizzano, and Armando Tacchella

Title: Logical Agents AIMA: Chapter 7 (Sections 7.4 and 7.5)

Introduction Algorithms Applications MINISAT. Niklas Sörensson Chalmers University of Technology and Göteborg University

SAT Solvers: Theory and Practice

Accelerating Linear Algebra on Heterogeneous Architectures of Multicore and GPUs using MAGMA and DPLASMA and StarPU Schedulers

Incremental Deterministic Planning

Propositional Logic: Methods of Proof. Chapter 7, Part II

CS-206 Concurrency. Lecture 13. Wrap Up. Spring 2015 Prof. Babak Falsafi parsa.epfl.ch/courses/cs206/

SAT-Solvers: propositional logic in action

An Introduction to SAT Solving

Auto-Tuning Complex Array Layouts for GPUs - Supplemental Material

Preprocessing QBF: Failed Literals and Quantified Blocked Clause Elimination

Dynamic Scheduling for Work Agglomeration on Heterogeneous Clusters

Worst-Case Upper Bound for (1, 2)-QSAT

GPU accelerated Monte Carlo simulations of lattice spin models

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

Propositional Calculus

Satisfiability Modulo Theories

GPU Acceleration of Cutoff Pair Potentials for Molecular Modeling Applications

Research on GPU-accelerated algorithm in 3D finite difference neutron diffusion calculation method

Proof Methods for Propositional Logic

Sums of Products. Pasi Rastas November 15, 2005

Propositional Logic: Methods of Proof (Part II)

SP-CNN: A Scalable and Programmable CNN-based Accelerator. Dilan Manatunga Dr. Hyesoon Kim Dr. Saibal Mukhopadhyay

Accelerating linear algebra computations with hybrid GPU-multicore systems.

Unit 1A: Computational Complexity

Introduction to SAT (constraint) solving. Justyna Petke

A Probabilistic Algorithm for -SAT Based on Limited Local Search and Restart

Foundations of Artificial Intelligence

Introduction to Artificial Intelligence Propositional Logic & SAT Solving. UIUC CS 440 / ECE 448 Professor: Eyal Amir Spring Semester 2010

CS156: The Calculus of Computation Zohar Manna Autumn 2008

Tips Geared Towards R. Adam J. Suarez. Arpil 10, 2015

Population annealing study of the frustrated Ising antiferromagnet on the stacked triangular lattice

An Implementation of SPELT(31, 4, 96, 96, (32, 16, 8))

GPU Based Parallel Ising Computing for Combinatorial Optimization Problems in VLSI Physical Design

Julian Merten. GPU Computing and Alternative Architecture

GPU acceleration of Newton s method for large systems of polynomial equations in double double and quad double arithmetic

Transcription:

GPU Acceleration of BCP Procedure for SAT Algorithms Hironori Fujii 1 and Noriyuki Fujimoto 1 1 Graduate School of Science Osaka Prefecture University 1-1 Gakuencho, Nakaku, Sakai, Osaka 599-8531, Japan Abstract The satisfiability problem (SAT) is widely applicable and one of the most basic NP-complete problems. This problem has been required to be solved as fast as possible because of its significance, but it takes exponential time in the worst case to solve. Therefore, we aim to save the computation time by parallel computing on a GPU. We propose parallelization of BCP (Boolean Constraint Propagation) procedure, one of the most effective techniques for SAT, on a GPU. For a 2.93GHz Intel Core i3 CPU and an NVIDIA GeForce GTX480, our experiment shows that the GPU accelerates our SAT solver based on our BCPembedded divide and conquer algorithm 6.7 times faster than the CPU counterpart Keywords: Satisfiability problem, Boolean constraint propagation, GPGPU, CUDA 1. Introduction The satisfiability problem (SAT for short) [1] is a problem of determining if a given boolean expression (usually in the conjunctive normal form) can be true by assigning some boolean values into the boolean variables in the expression. Formally, SAT is defined as follows: Let V = {V 1, V 2,, V n } be a set of n boolean variables. Let C = {C 1, C 2,, C m } be a set of m clauses where C j = (L j1 L j2 L jkj ) L i {V p, V p } Question: Is there assignment to the variables in V such that C 1 C 2 C m = true? where is a logical not operator, is a logical or operator, is a logical and operator. L i is called a literal which is either affirmation or negation of a boolean variable. SAT problem such that clauses are of exactly three literals is called 3SAT. Any SAT instance can be transformed to a 3SAT instance with the same solution. Therefore, without loss of generality, for simplicity, our SAT solver accepts 3SAT instance only. SAT is widely applicable and one of the most basic NP-complete problems. This problem has been required to be solved as fast as possible because of its significance, but it takes exponential time in the worst case to solve. Recent SAT algorithms can solve problem instances with several million variables in a few hours. SAT algorithms can be categorized into complete-type and incomplete-type. Complete-type algorithms can identify whether any given problem instance is satisfiable or unsatisfiable. In contrast, incomplete-type algorithms can not identify unsatisfiability but satisfiability. Many of common complete-type algorithms can be categorized into so-called DPLL algorithm [2], [3]. DPLL algorithm performs BCP(Boolean Constraint Propagation) procedure, which is a dominant part of the algorithm. BCP procedure occupies 80% to 90% of the whole execution. On the other hand, Davis et al. proposed a method [4] to accelerate BCP procedure by parallel processing with an FPGA. Davis et al. parallelized only BCP procedure for their method to be applicable to various DPLL algorithms. With Xilinx Virtex 5 LX110T and 3.6GHz Intel Pentium 4, Davis et al. experimentally showed that zchaff [5], [6], [7] with FPGA accelerated BCP procedure runs 5 to 16 times faster than the zchaff with the CPU only. This paper proposes parallelization of BCP procedure on a GPU, rather than an FPGA. Similar to Davis et al. s method, the proposed method can be used with various DPLL algorithms. However, we adopt divide-and-conquer algorithm [14] (3SAT-DC for short) with BCP procedure as our SAT solver used in the experiments in this paper. 3SAT- DC is complete-type. For a 2.93GHz Intel Core i3 CPU and an NVIDIA GeForce GTX480, our experiment showed that the GPU accelerates our SAT solver based on our BCPembedded divide and conquer algorithm 6.7 times faster than the corresponding CPU implementation. The remainder of this paper is organized as follows. Section 2 briefly reviews DPLL algorithm, BCP procedure, and SAT-DC. Section 3 presents the proposed algorithm. Experiments to show the performance of the proposed algorithm are reported in Section 4. Section 5 briefly surveys the related works. Section 6 gives some concluding remarks and future works. Due to the limited space, this paper include no description on CUDA. Readers unfamiliar with CUDA GPU architecture are recommended the literature [8], [9], [10], [11], [12], [13]. 2. Preliminaries 2.1 DPLL Algorithm Basically, DPLL algorithm finds an optimal solution by checking all the patterns of boolean value assignment to the variables in a given boolean expression while discarding hopeless sets of patterns without checking them. One of the methods to identify a hopeless set of patterns is

BCP procedure. Listing 1 shows a pseudo code of DPLL algorithm with BCP procedure. DPLL algorithm performs BCP procedure every decision phase which heuristically determines the value of a variable. Other features of DPLL algorithm are not used in the proposed method, and therefore not described in this paper. See the literatures [2], [3] for more detail of DPLL algorithm. 2.2 BCP Procedure BCP procedure consists of "implication" process and "conflict" process. The "implication" process finds a literal whose value is consequently determined by other literals in the same clause, and then repeat this process until no such a literal is found. The "conflict" process finds a clause with all literals false. Listing 2 shows a C code of BCP procedure. In the following C codes, literals and clauses are respectively stored in arrays named "atom" and "clause". The number of literals and clauses are hold in variables named "numatom" and "numclause". Value of a literal is true, false, or unknown, which are represented as 1, -1, and 0 respectively. BCP procedure repeatedly calls function BCPEngine (line 7 in Listing 2) until no more implication occurs or conflict is detected. Listing 3 shows a C code of function BCPEngine. After "implication" process, BCPEngine scans all clauses to detect implication or conflict in O(m). If every literal in a clause is false, then BCPEngine finishes after updating flag variable "conf" to indicate that conflict occurs (line 5 to 8 in Listing 3). Otherwise, BCPEngine performs "implication" process. If exactly one literal is unknown (line 11 to 13 in Listing 3) and any other literal is false, then BCPEngine detects implication and assigns the value which makes the unknown literal true into the corresponding element of array "atom" (line 20 to 22 in Listing 3). Then, BCPEngine pushes the index value of the modified element of array "atom" to array "implicated" and increments the stack pointer "sp" (line 23 in Listing 3). Finally, BCPEngine updates flag variable "imp" to indicate the detection of implication (line 24 in Listing 3). 2.3 3SAT-DC Listing 4 shows a pseudo code of 3SAT-DC where the parameter "f" of function "3SAT-DC" is a given logical expression and notation "f(x=propositional constant)" represents the logical expression such that "f" is simplified by substituting the constant to propositional variable "x". 3SAT- DC is a recursive procedure for a clause with the minimum unknown literals at that time. The time complexity of 3SAT- DC is O(m1.84 n ) [14]. 3. The Proposed Algorithm 3.1 An Overview BCP procedure is inherently sequential because it consists of iterations of O(m) time. Therefore, we parallelize only each iteration on a GPU and performs the other part on a CPU. To do so, we partition m clauses. Listing 5 shows a pseudo code of the proposed CPU code for DPLL algorithm with parallelized BCP procedure. After partitioning given clauses, DPLL algorithm with parallelized BCP procedure searches a solution while transferring data on the current status of search to memory on a CPU or a GPU every decision. The difference between serial DPLL algorithm in Section 2.1 and the parallel version is addition of clause partitioning in line 2 of Listing 5. 3.2 Clause Partitioning We partition clauses into groups in order to parallelize BCP procedure. Each group is processed by a thread block. Hence, we partition clauses into groups the same number of clauses for load balance. The maximum number of active thread blocks is eight times the number nummp of multiprocessors. Hence, we set the number numsubclause of clauses in a group at (numclause + nummp * 8-1) / (nummp * 8). Due to this, the number of groups is at most the maximum number of active thread blocks. 3.3 Parallelized BCP Procedure This section describes how to parallelize the serial BCP procedure in Section 2.2. 3.3.1 Calling from a CPU Listing 6 shows a CUDA C code of the proposed parallelized BCP procedure called from line 5 in Listing 5. The differences between the serial BCP in Listing 2 and the parallel version are: Status data are packed into the same array as many as possible. Data transfers between a CPU and a GPU are inserted before and after do-while statement and kernel function call. The reason why status data are packed into the same array is to reduce the number of cudamemcpy execution. The overhead of cudamemcpy invocation is heavy. Therefore, memory transfer time can be reduced by reduce the nuber of the invocations. In the proposed CUDA C code, flag variables "conf" and "imp" are packed into array "flag". Also, stack pointer "sp" and array "implicated" are packed into array "sp_implicated". Due to these packings, the whole execution time is reduced to about 90%. The proposed CUDA C code transfers array "atom" and "sp_implicated" before and after executing parallelized BCP procedure (line 7 to 10 and 18 to 21 in Listing 6). However, if no conflict occurs, the latter transfer is not performed to avoid excess transfer. After executing kernel function BCPEngine, variable "flag" is transfered (line 15 in Listing 6).

Listing 1: A pseudo code, focusing on BCP procedure, of DPLL algorithm 1 p r e p r o c e s s t o d e t e c t t r i v i a l u n s a t i s f i a b i l i t y 2 while ( 1 ) { 3 D e c i s i o n 4 while (BCP ( ) == c o n f l i c t ) { i f ( no more b a c k t r a c k ) return FALSE ; b a c k t r a c k } 5 } Listing 2: Serial BCP procedure 1 i n t BCP( i n t numclause, i n t (* c l a u s e ) [ 3 ], i n t 2 { * atom ) 3 i n t c onf = 0, imp ; 4 do { 5 imp = 0 ; BCPEngine ( numclause, c l a u s e, atom, &conf, &imp ) ; 6 } while (! conf && imp ) ; 7 return conf ; 8 } Listing 3: Serial BCP Engine 1 void BCPEngine ( i n t numclause, i n t (* c l a u s e ) [ 3 ], i n t * atom, i n t * conf, i n t 2 { *imp ) 3 * c onf = 0 ; *imp = 0 ; 4 f o r ( i n t i = 0 ; i < m; i ++) { 5 i f ( c l a u s e [ i ] [ 0 ] * atom [ abs ( c l a u s e [ i ] [ 0 ] ) ] >= 0) goto F ; 6 i f ( c l a u s e [ i ] [ 1 ] * atom [ abs ( c l a u s e [ i ] [ 1 ] ) ] >= 0) goto F ; 7 i f ( c l a u s e [ i ] [ 2 ] * atom [ abs ( c l a u s e [ i ] [ 2 ] ) ] >= 0) goto F ; 8 * conf = 1 ; return ; 9 F : 10 i n t numunknown = 0 ; i n t idxunknown ; 11 i f ( atom [ abs ( c l a u s e [ i ] [ 0 ] ) ] == 0) { numunknown++; idxunknown = 0 ; } 12 i f ( atom [ abs ( c l a u s e [ i ] [ 1 ] ) ] == 0) { numunknown++; idxunknown = 1 ; } 13 i f ( atom [ abs ( c l a u s e [ i ] [ 2 ] ) ] == 0) { numunknown++; idxunknown = 2 ; } 14 i f ( numunknown == 1) { 15 / / There i s e x a c t l y one l i t e r a l o f unknown v a l u e i n c l a u s e [ i ] 16 i f ( c l a u s e [ i ] [ 0 ] * atom [ abs ( c l a u s e [ i ] [ 0 ] ) ] > 0) c o n t i n u e ; 17 i f ( c l a u s e [ i ] [ 1 ] * atom [ abs ( c l a u s e [ i ] [ 1 ] ) ] > 0) c o n t i n u e ; 18 i f ( c l a u s e [ i ] [ 2 ] * atom [ abs ( c l a u s e [ i ] [ 2 ] ) ] > 0) c o n t i n u e ; 19 / / Any o t h e r l i t e r a l i s f a l s e 20 i n t litunknown = c l a u s e [ i ] [ idxunknown ] ; 21 i n t v a l = ( litunknown > 0)? TRUE : FALSE ; 22 atom [ abs ( litunknown ) ] = v a l ; 23 i m p l i c a t e d [ sp ++] = abs ( litunknown ) ; 24 25 }}} (* imp ) + + ; Listing 4: A pseudo code of 3SAT-DC 1 3SAT DC( f ) 2 { 3 i f ( f == FALSE) return FALSE ; 4 min_c = a c l a u s e w ith minimum number of l i t e r a l s ; 5 i f ( min_c == an empty c l a u s e ) return TRUE; 6 i f ( min_c == ( x ) ) return 3SAT DC( f ( x = t r u e ) ) ; 7 e l s e i f ( min_c == ( x or y ) ) 8 return 3SAT DC( f ( x = t r u e ) ) 3SAT DC( f ( x = f a l s e, y = t r u e ) ) ; 9 e l s e / * min_c==( x or y or z ) * / 10 return 3SAT DC( f ( x = t r u e ) ) 3SAT DC( f ( x = f a l s e, y = t r u e ) ) 11 3SAT DC( f ( x = f a l s e, y = f a l s e, z = t r u e ) ) ; 12 }

Listing 5: A pseudo code of the proposed CPU code for DPLL algorithm with parallelized BCP procedure 1 p r e p r o c e s s t o d e t e c t t r i v i a l u n s a t i s f i a b i l i t y 2 p a r t i t i o n c l a u s e s i n t o g r o u p s 3 while ( 1 ) { 4 D e c i s i o n 5 while (BCP ( ) == c o n f l i c t ) { 6 i f ( no more b a c k t r a c k ) return FALSE 7 b a c k t r a c k 8 } 9 } Listing 6: A CUDA C code of the proposed parallelized BCP procedure 1 # d e f i n e BLKSZ 64 2 i n t BCP_GPU( i n t numatom, i n t *atom, i n t s, i n t * s p _ i m p l i c a t e d, i n t * d _ s u b s e t, 3 i n t * d _ o r d e r e d C l a u s e, i n t * d_atom, i n t * d _ f l a g, i n t * d _ s p _ i m p l i c a t e d ) 4 { 5 i n t f l a g [ 2 ] ; / / f l a g [ 0 ] : conf, f l a g [ 1 ] : imp 6 cudamemset(& d _ f l a g [ 0 ], 0, s i z e o f ( i n t ) ) ; / / c o n f = 0; 7 cudamemcpy ( d_atom, atom, s i z e o f ( i n t ) * ( numatom + 1 ), 8 cudamemcpyhosttodevice ) ; 9 cudamemcpy ( d _ s p _ i m p l i c a t e d, s p _ i m p l i c a t e d, s i z e o f ( i n t ) * ( numatom + 1 ), 10 cudamemcpyhosttodevice ) ; 11 do { 12 cudamemset(& d _ f l a g [ 1 ], 0, s i z e o f ( i n t ) ) ; / / imp = 0; 13 BCPEngine <<< s, BLKSZ >>>( d _ s u b s e t, d _ o r d e r e d C l a u s e, 14 d_atom, d _ f l a g, d _ s p _ i m p l i c a t e d ) ; 15 cudamemcpy ( f l a g, d _ f l a g, s i z e o f ( i n t ) * 2, cudamemcpydevicetohost ) ; 16 } while (! f l a g [ 0 ] && f l a g [ 1 ] ) ; / / c o n f == 0 && imp!= 0 17 i f (! f l a g [ 0 ] ) { / / no c o n f l i c t 18 cudamemcpy ( atom, d_atom, s i z e o f ( i n t ) * ( numatom + 1 ), 19 cudamemcpydevicetohost ) ; 20 cudamemcpy ( s p _ i m p l i c a t e d, d _ s p _ i m p l i c a t e d, s i z e o f ( i n t ) * ( numatom + 1 ), 21 cudamemcpydevicetohost ) ; 22 } 23 return f l a g [ 0 ] ; / / r e t u r n c o n f ; 24 } 3.4 Kernel Function BCPEngine Listing 7 shows the CUDA C code of the proposed kernel function BCPEngine. The number of thread blocks is the number s of groups. The number of threads in a thread block is predefined constant BLKSZ. The arguments subset and orderedclause represent partitioned groups together. Each element of orderedclause holds a clause. Clauses in the same group are consecutively stored in array orderedclause. The head index of elements of each group is stored array "subset". The type of orderedclause is int[4] rather than int[3]. Since every clause of 3SAT instance has exactly three literals, int[3] is sufficient to hold each clause. However, the proposed kernel stores each clause into int[4] with padding in order to enable coalesce access. The kernel function BCPEngine works as follows. As preparation, the number "size" of clauses in the group assigned to each thread block is calculated (line 4 in Listing 7). Also, pointer "orderedclause" is moved so as to point at the head clause of the assigned group (line 5 in Listing 7). Hence, in the lines below line 5, each thread block can access the assigned group via orderedclause[0..size- 1]. The processing for each clause is almost same as the serial BCPEngine in Listing 3, but there are four different points. First, flag "conflict" is checked before each clause is processed and if conflict is detected then each thread is finished (line 8 in Listing 3). Second, each clause is loaded into variable "c" of type int4 to realize coalesced access (line 10 in Listing 3). Third, detection of simultaneous implication by multiple threads is processed by CUDA atomic functions (line 27 to 30 in Listing 7). If multiple threads detect implications for the same variable and attempt to assign the variable different values, then conflict should be detected as shown in line 31 in Listing 7. However, even if line 31 is deleted, no problem occurs because it will be detected as conflict at the next invocation of BCPEngine. Preliminary experiments show that the code without line 31 is faster by a few percent. Therefore, we deleted line 31. Fourth, implication flag variable on global memory is not updated immediately. Instead, each thread updates myimplication

flag variable on a register at each iteration and finally updates implication flag variable once (line 34 in Listing 7). 3.4.1 Cache Configuration The proposed kernel function in Listing 7 never use shared memory. Instead, it relies on cache memory of Fermi architecture. Fermi GPUs can configure size of shared memory and L1 cache memory either 16KB/48KB or 48KB/16KB. Our current implementation never use shared memory. Therefore, we set the size of L1 cache memory at 48KB. 4. Experiments This section compares the performance of the proposed CUDA program with a CPU program that performs the same computation. We measured the execution time (average of 10 trials for each test) of not only BCP procedure but also whole execution of 3SAT-DC with BCP procedure. We embedded invocations of BCP procedure just before recursive calls in line 6, 8, 10, and 11 in Listing 4, which correspond to Decisions. Furthermore, we set up the maximum number BCPMAX of invocations of BCP procedure. If our SAT solver executed BCP procedure BCPMAX times, we stopped our SAT solver and measured the execution time at that time. If our SAT solver found a solution or exhausted the search space before BCP procedure was executed BCPMAX times, the execution time at that time is measured. We fixed the number of threads in a thread block at 64 because preliminary experiments showed the number is better. For each test, a single core of 2.93 GHz Intel Core i3 and NVIDIA GeForce GTX480 was used. The OS used is Windows7 Professional SP1 with NVIDIA graphics driver Version 285.62. For compilation, Microsoft Visual Studio 2008 Professional Edition with optimization option /O2 and CUDA 3.2 SDK were used. 4.1 Performance and Problem Size In this section, we compare the performance of GPU with that of CPU for various problem sizes. The used problem instances were generated by Motoki s 3SAT instance generator G3 (n,m) [15], [16] (G3 for short). G3 generates a boolean expression that has exactly one solution with high probability. In general, to solve 3SAT instance with many (a few) solutions is easy (hard). Figure 1, 2, and 3 show a performance comparison between CPU and GPU with problem instances generated by G3. As for Figure 1 and 2, x-axis is the number of variables and y-axis is the execution time in second. Figure 1 shows performance for relatively small instances with BCPMAX 50000. Figure 2 shows performance for relatively large instances with BCPMAX 10000. Figure 3 shows the speedup ratios in case of Figure 1 and 2. As for Figure 3, x-axis is the number of variables and y-axis is speedup ratio. Our GPU solver runs faster with an increase of the problem size (i.e., the number of variables). Although GPU is slower than CPU for small problems, it is reversed for 2500 variables. The best GPU performance is about 4.5 times than CPU for 50000 variables. For more than 50000 variables, the performance of GPU tends to decrease with an increase of the problem size. 4.2 Performance and the Number of BCP Procedure Done In this section, we fix problem size and compare the performance of GPU with that of CPU for various values of BCPMAX. We randomly selected 10 instances from SAT11 Competition [17] with category RANDOM, 50000 variables, and 210000 clauses. Figure 4 shows the result. The x-axis shows the name of instance file name and the y-axis is speedup ratio. The speedup ratio is improved with an increase of BCPMAX. Even if BCPMAX is 1000, GPU is 1.5 times faster than CPU in average. The best performance (6.7 times speedup) of GPU is obtained when BCPMAX is 10000. For BCP- MAX larger than 10000, the performance improvement is negligible. 5. Related Works As far as we know, there exist five existing research on SAT algorithm parallelized on a CUDA GPU, as shown below. In [18], Meyer et al. proposed a complete-type method to parallelize 3SAT-DC like us. However, they did not use BCP procedure. Instead, they proposed a problem partitioning method to parallelize divide-and-conquer itself and their own heuristic for Decision phase. In [19], McDonald et al. proposed an incomplete-type method to parallelize WalkSAT algorithm with clause learning. Their parallelization method is to run many threads such that each thread executes serial WalkSAT algorithm with pseudo random sequence different any other thread. In [20], Gulati et al. proposed a complete-type method named MESP (MiniSAT enhanced with SurveyPropagation). They experimentally showed speedup ratio of 2.35 in average with 2.67GHz Intel i7 CPU and NVIDIA GeForce 280GTX GPU. In [21], Wang et al. proposed an incomplete-type method of a celler genetic algorithm with random walk local search. In [22], Deleau et al. proposed an incomplete-type method such that SAT instance is represented by a 0-1 matrix and 0-1 matrix multiplication is used to search a solution for a given SAT instance. 6. Conclusion and Future Work This paper has proposed a method to parallelize BCP procedure for SAT algorithm and has implemented a CUDA GPU program based on the proposed method. Experimental

Listing 7: A CUDA C code of the proposed parallelized BCP procedure 1 g l o b a l void BCPEngine ( i n t * s u b s e t, i n t (* o r d e r e d C l a u s e ) [ 4 ], 2 i n t *atom, i n t * f l a g, i n t * s p _ i m p l i c a t e d ) 3 { 4 i n t s i z e = s u b s e t [ blockidx. x + 1] s u b s e t [ blockidx. x ] ; 5 o r d e r e d C l a u s e += s u b s e t [ blockidx. x ] ; 6 i n t m y I m p l i c a t i o n = 0 ; 7 f o r ( i n t i = threadidx. x ; i < s i z e ; i += blockdim. x ) { 8 i f ( f l a g [ 0 ] ) r e t u r n ; / / Another t h r e a d d e t e c t e d c o n f l i c t 9 i n t c [ 4 ] ; 10 * ( ( i n t 4 *) c ) = * ( ( i n t 4 *) o r d e r e d C l a u s e [ i ] ) ; 11 i f ( c [ 0 ] * atom [ abs ( c [ 0 ] ) ] >= 0) goto F ; 12 i f ( c [ 1 ] * atom [ abs ( c [ 1 ] ) ] >= 0) goto F ; 13 i f ( c [ 2 ] * atom [ abs ( c [ 2 ] ) ] >= 0) goto F ; 14 f l a g [ 0 ] = 1 ; / / c o n f = 1; 15 r e t u r n ; 16 F : 17 i n t numunknown = 0 ; i n t idxunknown ; 18 i f ( atom [ abs ( c [ 0 ] ) ] = =UNKNOWN) {numunknown++; idxunknown =0;} 19 i f ( atom [ abs ( c [ 1 ] ) ] = =UNKNOWN) {numunknown++; idxunknown =1;} 20 i f ( atom [ abs ( c [ 2 ] ) ] = =UNKNOWN) {numunknown++; idxunknown =2;} 21 i f ( numunknown == 1) { / / e x a c t l y one l i t e r a l o f unknown v a l u e i n o r d e r e d C l a u s e [ i ] 22 i f ( c [ 0 ] * atom [ abs ( c [ 0 ] ) ] > 0) c o n t i n u e ; 23 i f ( c [ 1 ] * atom [ abs ( c [ 1 ] ) ] > 0) c o n t i n u e ; 24 i f ( c [ 2 ] * atom [ abs ( c [ 2 ] ) ] > 0) c o n t i n u e ; 25 i n t litunknown = c [ idxunknown ] ; 26 i n t v a l = ( litunknown > 0)? TRUE : FALSE ; 27 i n t o l d = atomiccas(&atom [ abs ( litunknown ) ], UNKNOWN, v a l ) ; 28 i f ( o l d == UNKNOWN) { m y I m p l i c a t i o n ++; 29 s p _ i m p l i c a t e d [ atomicadd (& s p _ i m p l i c a t e d [ 0 ], 1 ) ] 30 = abs ( litunknown ) ; } 31 / / e l s e i f ( o l d!= v a l ) { f l a g [ 0 ] = 1; r e t u r n ; } 32 } 33 } 34 i f ( m y I m p l i c a t i o n ) f l a g [ 1 ] = 1 ; / / imp = 1; 35 } 36 } Fig. 1: A performance comparison between CPU and GPU (small instance) Fig. 2: A performance comparison between CPU and GPU (large instance) results show that the proposed GPU SAT solver runs maximum 6.7 times faster than the corresponding CPU solver. One of future works is to realize more speedup by improving clause partitioning method and so on. References [1] Garey, M. R. and Johnson, D. S. : Computers and Intractability: A Guide to the Theory of NP-Completeness, W.H. Freeman (1979) [2] Davis, M. and Putnum, H. : A Computing Procedure for Quantification Theory, Journal of the ACM, Vol.7, No.3, pp.201-215 (1960) [3] Davis, M., Logemann, G., and Loveland, D. : A Machine Program for

Fig. 3: Speedup ratios of GPU to CPU [12] NVIDIA: CUDA Programming Guide Version 4.0. http://www.nvidia.com/object/ cuda_develop.html (2011) [13] NVIDIA: CUDA Best Practice Guide 4.0. http://www.nvidia.com/object/ cuda_develop.html (2011) [14] Monien, B. and Speckenmeyer, E. : Solving satisfiability in less than 2n steps, Discrete Applied Mathematics, Vol.10, No.3, pp.287-295 (1985) [15] Motoki, M. : SAT Instance Generation Page, http://www.is.titech.ac.jp/ watanabe/gensat/ [16] Motoki, M. and Uehara, R. : Unique Solution Instance Generation for the 3-Satisfiability (3SAT) Problem, International Conference on Theory and Applications of Satisfiability Testing (SAT), pp.293-307 (2000) [17] Jarvisalo, M., Berre, D. L. and Roussel, O. : SAT Competition 2011, http://www.satcompetition.org/2011/ (2011) [18] Meyer, Q., Schönfeld, F., Stamminger, M., and Wanka, R. : 3-SAT on CUDA: Towards a Massively Parallel SAT Solver, High Performance Computing and Simulation Conference (HPSC), pp.306-313 (2010) [19] McDonald, A. and Gordon, G. : ParallelWalkSAT with Clause Learning, Data Analysis Project Presentation, School of Computer Science, Carnegie Mellon University, http://www.ml.cmu.edu/research/dappapers/dap_mcdonald.pdf (2009) [20] Gulati, K. and Khatri, S. P. : Boolean Satisfiability on a Graphics Processor, the 20th Great Lakes Symposium on VLSI (GLSVLSI), pp.123-126 (2010) [21] Wang, Y. : NVIDIA CUDA Architecture-based Parallel Incomplete SAT Solver, Master Project Final Report, Faculty of Rochester Institute of Technology (2010) [22] Deleau, H., Jaillet, C., and Krajecki, M. : GPU4SAT: Solving the SAT Problem on GPU, http://para08.idi.ntnu.no/docs/submission_49.pdf (2008) Fig. 4: Relation between speedup ratio and BCPMAX Theorem Proving, Communications of the ACM, Vol.5, No.7, pp.394-397 (1962) [4] Davis, J. D., Tan, Z., Yu, F., and Zhang, L. : Designing an Efficient Hardware Implication Accelerator for SAT Solving, LNCS Vol.4996, pp.48-62 (2008) [5] SAT Research Group, Princeton University : zchaff, http://www.princeton.edu/ chaff/zchaff.html [6] Moskewicz, M., Madigan, C., Zhao, Y., Zhang, L., and Malik, S. : Chaff: Engineering an Efficient SAT Solver, 39th Design Automation Conference (DAC), (2001) [7] Mahajan, Y. S., Fu, Z., and Malik S. : Zchaff2004: An efficient SAT solver, International Conference on Theory and Applications of Satisfiability Testing (SAT), pp.360-375 (2004) [8] Kirk, D. B. and Hwu, W. W.; Programming Massively Parallel Processors: A Hands-on Approach. Morgan Kaufmann (2010) [9] Sanders, J. and Kandrot, E.; CUDA by Example: An Introduction to General-Purpose GPU Programming. Addison-Wesley Professional (2010) [10] Lindholm, E., Nickolls, J., Oberman, S., and Montrym, J.: NVIDIA Tesla: A Unified Graphics and Computing Architecture. IEEE Micro, Vol.28, No.2, pp.39 55 (2008) [11] Garland, M. and Kirk, D. B.: Understanding Throughput-Oriented Architectures, Communications of the ACM, Vol.53, No.11, pp.58-66 (2010)