Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
t-dillon committed Jun 14, 2019
1 parent 77a638a commit a872672
Show file tree
Hide file tree
Showing 34 changed files with 6,737 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .gitignore
@@ -0,0 +1,22 @@
.idea/

build/
cmake-build-debug/
data/
other/fsss2.cpp
other/fsss2.h
other/t_128.cpp
other/t_128.h
other/JCZSolve.c
other/JCZSolve.h
other/JSolve.c
other/JSolve.h
src/build_info.h

run_benchmark
run_tests
libtdoku.a
Makefile
cmake_install.cmake
CMakeCache.txt
CMakeFiles/
9 changes: 9 additions & 0 deletions BUILD.sh
@@ -0,0 +1,9 @@
#!/bin/sh

mkdir -p build
cd build
rm -f CMakeCache.txt
rm -rf CMakeFiles
cmake .. $*
make
cd ..
85 changes: 85 additions & 0 deletions CMakeLists.txt
@@ -0,0 +1,85 @@
cmake_minimum_required(VERSION 3.5)
project(tdoku VERSION 1.0)
set(CMAKE_CXX_STANDARD 14)

option(OPT "Compile with full optimization" ON)
option(SSE4_1 "Compile with SSE4.1 support" ON)
option(AVX2 "Compile with AVX2 support" OFF)
option(AVX512 "Compile with AVX512BITALG support" OFF)
option(NATIVE "Compile for native architecture" OFF)

option(FSSS2 "Include fsss2" OFF)
option(JCZSOLVE "Include JCZSolve" OFF)
option(JSOLVE "Include JSolve" OFF)
option(MINISAT "Include MiniSat" OFF)

if (OPT)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
endif()

if (NATIVE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
elseif (AVX512)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx512vl -mavx512bitalg")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx512vl -mavx512bitalg")
elseif (AVX2)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2")
elseif (SSE4_1)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
endif()

configure_file (
"${CMAKE_SOURCE_DIR}/src/build_info.h.in"
"${CMAKE_SOURCE_DIR}/src/build_info.h"
)

# a gcc-linkable library with just the fast solver
add_library(tdoku STATIC src/solver_dpll_triad_simd.cc)
target_compile_options(tdoku PUBLIC -fno-exceptions -fno-rtti)

set(BENCHMARK_SOLVER_SOURCES
src/solver_basic.cc
src/solver_dpll_triad_scc.cc
src/solver_dpll_triad_simd.cc
src/other_solvers.cc)

if (FSSS2)
add_definitions(-DFSSS2)
set(BENCHMARK_SOLVER_SOURCES ${BENCHMARK_SOLVER_SOURCES} other/fsss2.cpp other/t_128.cpp)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register")
endif()

if (JCZSOLVE)
add_definitions(-DJCZSOLVE)
set(BENCHMARK_SOLVER_SOURCES ${BENCHMARK_SOLVER_SOURCES} other/JCZSolve.c)
endif()

if (JSOLVE)
add_definitions(-DJSOLVE)
set(BENCHMARK_SOLVER_SOURCES ${BENCHMARK_SOLVER_SOURCES} other/JSolve.c)
endif()

if (MINISAT)
add_definitions(-DMINISAT)
set(BENCHMARK_SOLVER_SOURCES ${BENCHMARK_SOLVER_SOURCES} src/solver_minisat.cc)
endif()

add_executable(run_benchmark src/run_benchmark.cc ${BENCHMARK_SOLVER_SOURCES})
if (MINISAT)
target_link_libraries(run_benchmark minisat)
endif()

add_executable(run_tests src/run_tests.cc ${BENCHMARK_SOLVER_SOURCES})
if (MINISAT)
target_link_libraries(run_tests minisat)
endif()
9 changes: 9 additions & 0 deletions README
@@ -0,0 +1,9 @@
TDOKU: A Sudoku Solver

See https://t-dillon.github.io/tdoku for the why and how.

To run benchmarks:

unzip data.zip
./BUILD.sh
./build/run_benchmark data/*
Binary file added data.zip
Binary file not shown.
Binary file added docs/band_clauses.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions docs/bootstrap.min.css

Large diffs are not rendered by default.

Binary file added docs/box_elimination.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/build.sh
@@ -0,0 +1,4 @@
#!/bin/sh

# the columns arg is necessary to get the tables to format to the same width.
pandoc -o index.html -c pandoc.css --columns=50 --mathjax sudoku.md
Binary file added docs/configurations.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/i-should-write-a-sudoku-solver.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,480 changes: 1,480 additions & 0 deletions docs/index.html

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions docs/jquery-ui.min.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions docs/jquery.min.js

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions docs/jquery.tocify.css
@@ -0,0 +1,80 @@
/*
* jquery.tocify.css 1.9.1
* Author: @gregfranko
*/

/* The Table of Contents container element */
.tocify {
width: 20%;
max-height: 90%;
overflow: auto;
margin-left: 2%;
position: fixed;
border: 1px solid #ccc;
webkit-border-radius: 6px;
moz-border-radius: 6px;
border-radius: 6px;
}

/* The Table of Contents is composed of multiple nested unordered lists. These styles remove the default styling of an unordered list because it is ugly. */
.tocify ul, .tocify li {
list-style: none;
margin: 0;
padding: 0;
border: none;
line-height: 30px;
}

/* Top level header elements */
.tocify-header {
text-indent: 10px;
}

/* Top level subheader elements. These are the first nested items underneath a header element. */
.tocify-subheader {
text-indent: 20px;
display: none;
}

/* Makes the font smaller for all subheader elements. */
.tocify-subheader li {
font-size: 12px;
}

/* Further indents second level subheader elements. */
.tocify-subheader .tocify-subheader {
text-indent: 30px;
}

/* Further indents third level subheader elements. You can continue this pattern if you have more nested elements. */
.tocify-subheader .tocify-subheader .tocify-subheader {
text-indent: 40px;
}

/* Twitter Bootstrap Override Style */
.tocify .tocify-item > a, .tocify .nav-list .nav-header {
margin: 0px;
}

/* Twitter Bootstrap Override Styles */
.tocify .tocify-item a, .tocify .list-group-item {
padding: 5px;
}

.tocify .nav-pills > li {
float: none;
}

/* We don't override the bootstrap colors because this gives us the
wrong selection colors when using bootstrap themes
.tocify .list-group-item:hover, .tocify .list-group-item:focus {
background-color: #f5f5f5;
}
.tocify .list-group-item.active:hover, .tocify .list-group-item.active:focus {
background-color: #428bca;
}
*/

/* End Twitter Bootstrap Override Styles */

0 comments on commit a872672

Please sign in to comment.