Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Integrate LogicBlocks #79

Merged
merged 59 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
0eec332
Extracting Changes
Jun 27, 2022
e8daad5
Fixing LogicBlocks
Jun 27, 2022
8583758
Fixing Bugs in LogicBlocks
Jun 29, 2022
9cbfa66
Remove Cliffordsynthesis file
Jun 29, 2022
5f64b31
Remove Cliffordsynthesis file
Jun 29, 2022
2ced7ae
Fixed last Problems in Exact mapper
Jun 29, 2022
4df8272
updated logicblocks
Jun 29, 2022
315b1cf
Code Formatting
Jun 29, 2022
9ab56c2
Code Formatting
Jun 29, 2022
249f745
Updating LogicBlocks
Jun 30, 2022
e97cb95
Update LogicBlocks
Jun 30, 2022
26e4786
Fixed WNCF Problem
Jun 30, 2022
5b77bbc
fixup! Fixed WCNF Problem
Jun 30, 2022
86ef9ea
Update LogicBlocks
Jun 30, 2022
7ecb9d5
Fixed Codestyle
Jun 30, 2022
a9e453c
Fixed Accidental File Changes
Jun 30, 2022
a0c3175
Merge remote-tracking branch 'origin/main' into LogicBlocks
burgholzer Jul 4, 2022
e73a66c
🎨 code format in CMake and related files
burgholzer Jul 4, 2022
16bfdf1
🎨 add missing newline and `shallow` clone
burgholzer Jul 4, 2022
5ca19ce
Incorporating Change requests
Jul 5, 2022
0e67936
Update LogicBlocks
Jul 5, 2022
937ee3a
Merge branch 'LogicBlocks' of github.com:IsFairy/qmap into LogicBlocks
Jul 5, 2022
73071f5
Formatting
Jul 5, 2022
c0f5184
🐛🔧 fix `MANIFEST.in`
burgholzer Jul 5, 2022
87b3399
🎨 code format
burgholzer Jul 5, 2022
6e7d18e
Update LogicBlocks
Jul 6, 2022
fc279c8
Merge branch 'LogicBlocks' of github.com:IsFairy/qmap into LogicBlocks
Jul 6, 2022
9544523
Update LogicBlocks
Jul 7, 2022
7d47d71
Updated Logicblocks
Aug 11, 2022
19d68d4
Merge branch 'cda-tum:main' into LogicBlocks
IsFairy Aug 11, 2022
ac0dfc5
Updated Logicblocks & Update CI
Aug 12, 2022
f0ff0b7
Merge branch 'LogicBlocks' of github.com:IsFairy/qmap into LogicBlocks
Aug 12, 2022
2db248e
Update CI
Aug 12, 2022
8876ee3
Updating LogicBlocks to include the latest fixes
Aug 19, 2022
d68fd29
Added Small test to check some untested utility functions
Aug 22, 2022
ee8a0a4
Merge branch 'cda-tum:main' into LogicBlocks
IsFairy Aug 22, 2022
6a01ce0
Added Test to check Error Message
Aug 22, 2022
706ef1f
Merge remote-tracking branch 'origin/LogicBlocks' into LogicBlocks
Aug 22, 2022
7b55fd8
Codestyle
Aug 22, 2022
660adbf
Merge branch 'cda-tum:main' into LogicBlocks
IsFairy Aug 26, 2022
c5aaeab
Fixes for Requested Changes
Aug 29, 2022
bdf80fb
Merge branch 'LogicBlocks' of github.com:IsFairy/qmap into LogicBlocks
Aug 29, 2022
a8762e8
Merge branch 'cda-tum:main' into LogicBlocks
IsFairy Aug 29, 2022
753e074
Updated CI
Aug 29, 2022
5f70a15
Fixed inconsistent cost calculation
Aug 29, 2022
f4b7335
Updated lgtm config
Aug 29, 2022
2bac699
Reformated code
Aug 29, 2022
974ae4a
Patch for LGTM config
Aug 29, 2022
4399758
Fix for python build system
Aug 30, 2022
39f64af
update LogicBlocks
Aug 30, 2022
3e5c2d8
Remove unnecessary block in codeql
Aug 30, 2022
2cc1e86
Update LogicBlocks
Aug 30, 2022
6d5ef3a
Fix CMakeLists.txt
Aug 30, 2022
5b2bbb3
LGTM patch
Aug 30, 2022
eb7995d
Revert "Fix CMakeLists.txt"
Aug 30, 2022
49e3a63
Update LogicBlocks
Aug 30, 2022
404cd17
Re added FindZ3.cmake
Aug 30, 2022
1bf4563
Removed Version Check for z3
Aug 30, 2022
3a36023
Removed Unnecessary Lines
Aug 31, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 47 additions & 8 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,58 @@ on:
- cron: '15 21 * * 6'

jobs:
analyze:
name: Analyze
analyze-cpp:
name: Analyze C++
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'cpp', 'python' ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: 'cpp'

- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.10'

- name: Installing boost
run: sudo apt-get install -y libboost-program-options-dev

- name: Install Z3
run: python -m pip install z3-solver

- name: Configure CMake
run: |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$pythonLocation/lib/python3.10/site-packages/z3/lib
export Z3_ROOT=$pythonLocation/lib/python3.10/site-packages/z3
export Z3_DIR=$pythonLocation/lib/python3.10/site-packages/z3
cmake -S "${{github.workspace}}" -B "${{github.workspace}}/build" -DCMAKE_BUILD_TYPE=Release -DBUILD_QMAP_TESTS=ON -DBINDINGS=ON

- name: Build
run: cmake --build "${{github.workspace}}/build" --parallel 4


- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

analyze-python:
name: Analyze Python
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Checkout repository
Expand All @@ -32,9 +72,8 @@ jobs:
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
languages: 'python'

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
- name: Autobuild
uses: github/codeql-action/autobuild@v2

Expand Down
5 changes: 5 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
url = https://github.com/cda-tum/qfr.git
branch = main
shallow = true
[submodule "extern/LogicBlocks"]
path = extern/LogicBlocks
url = https://github.com/IsFairy/LogicBlocks.git
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this URL has to be changed once the LogicBlocks project has been moved to the cda-tum organisation.

branch = main
shallow = true
6 changes: 5 additions & 1 deletion .lgtm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ extraction:
packages:
- python-pip
after_prepare:
- export PATH=~/.local/bin:$PATH
- export PATH=~/.local/bin:~/.local/lib:$PATH
- pip3 install cmake --user
- pip3 install z3-solver --user
- cmake --version
- pip3 show z3-solver
configure:
command:
- export Z3_ROOT=~/.local/lib/python3.8/site-packages/z3
- export Z3_DIR=~/.local/lib/python3.8/site-packages/z3
- cmake -S . -B build -DBUILD_QMAP_TESTS=ON -DBUILD_QFR_TESTS=ON -DBUILD_DD_PACKAGE_TESTS=ON -DBINDINGS=ON
index:
build_command:
Expand Down
19 changes: 11 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,29 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
endif ()

macro(check_submodule_present MODULENAME)
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/${MODULENAME}/CMakeLists.txt")
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/${MODULENAME}/CMakeLists.txt")
message(FATAL_ERROR "${MODULENAME} submodule not cloned properly. Please run `git submodule update --init --recursive` from the main project directory")
endif()
endif ()
endmacro()

check_submodule_present(qfr)

check_submodule_present(LogicBlocks)

# Add path for custom modules
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# search for Z3
find_package(Z3)
if(Z3_FOUND AND NOT TARGET z3::z3lib)
if (Z3_FOUND AND NOT TARGET z3::z3lib)
message(STATUS "Found Z3 with version ${Z3_VERSION_STRING}")
add_library(z3::z3lib IMPORTED INTERFACE)
set_property(TARGET z3::z3lib PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Z3_CXX_INCLUDE_DIRS})
set_property(TARGET z3::z3lib PROPERTY INTERFACE_LINK_LIBRARIES ${Z3_LIBRARIES})
else()
add_definitions(-DZ3_FOUND)
else ()
message(WARNING "Did not find Z3. Exact library and other depending target will not be available")
endif()
endif ()

# add main library code
add_subdirectory(src)
Expand All @@ -72,6 +75,6 @@ if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
endif ()

# add Python binding code
if(BINDINGS)
if (BINDINGS)
add_subdirectory(mqt/qmap)
endif()
endif ()
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ prune extern/qfr/extern/dd_package/extern
prune extern/qfr/extern/zx/extern/googletest

graft apps

graft extern/LogicBlocks
98 changes: 49 additions & 49 deletions cmake/FindZ3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ INCLUDE(CheckCXXSourceRuns)

# Function to check Z3's version
function(check_z3_version z3_include z3_lib)
# The program that will be executed to print Z3's version.
file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testz3.cpp
"#include <assert.h>
# The program that will be executed to print Z3's version.
file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testz3.cpp
"#include <assert.h>
#include <z3.h>
int main() {
unsigned int major, minor, build, rev;
Expand All @@ -14,70 +14,70 @@ function(check_z3_version z3_include z3_lib)
return 0;
}")

# Get lib path
get_filename_component(z3_lib_path ${z3_lib} PATH)
# Get lib path
get_filename_component(z3_lib_path ${z3_lib} PATH)

try_run(
Z3_RETURNCODE
Z3_COMPILED
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testz3.cpp
COMPILE_DEFINITIONS -I"${z3_include}"
LINK_LIBRARIES -L${z3_lib_path} -lz3
RUN_OUTPUT_VARIABLE SRC_OUTPUT
)
try_run(
Z3_RETURNCODE
Z3_COMPILED
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testz3.cpp
COMPILE_DEFINITIONS -I"${z3_include}"
LINK_LIBRARIES -L${z3_lib_path} -lz3
RUN_OUTPUT_VARIABLE SRC_OUTPUT
)

if(Z3_COMPILED)
string(REGEX REPLACE "([0-9]*\\.[0-9]*\\.[0-9]*)" "\\1"
z3_version "${SRC_OUTPUT}")
set(Z3_VERSION_STRING ${z3_version} PARENT_SCOPE)
endif()
if (Z3_COMPILED)
string(REGEX REPLACE "([0-9]*\\.[0-9]*\\.[0-9]*)" "\\1"
z3_version "${SRC_OUTPUT}")
set(Z3_VERSION_STRING ${z3_version} PARENT_SCOPE)
endif ()
endfunction(check_z3_version)

# if Z3_ROOT is provided, check there first
set(Z3_ROOT "" CACHE PATH "Root of Z3 distribution.")
if (DEFINED ENV{Z3_ROOT})
set(Z3_ROOT $ENV{Z3_ROOT})
message("Z3_ROOT: ${Z3_ROOT}")
set(Z3_ROOT $ENV{Z3_ROOT})
message("Z3_ROOT: ${Z3_ROOT}")
endif ()
if (NOT ${Z3_ROOT} STREQUAL "")
find_path(Z3_CXX_INCLUDE_DIRS NAMES z3.h z3++.h
NO_DEFAULT_PATH
PATHS ${Z3_ROOT}/include
PATH_SUFFIXES libz3 z3)
find_path(Z3_CXX_INCLUDE_DIRS NAMES z3.h z3++.h
NO_DEFAULT_PATH
PATHS ${Z3_ROOT}/include
PATH_SUFFIXES libz3 z3)

find_library(Z3_LIBRARIES NAMES z3 libz3
NO_DEFAULT_PATH
PATHS ${Z3_ROOT}
PATH_SUFFIXES lib bin)
find_library(Z3_LIBRARIES NAMES z3 libz3
NO_DEFAULT_PATH
PATHS ${Z3_ROOT}
PATH_SUFFIXES lib bin)
endif ()

# see if a config file is available
if (NOT Z3_CXX_INCLUDE_DIRS OR NOT Z3_LIBRARIES)
find_package(Z3 CONFIG)
endif()
find_package(Z3 CONFIG)
endif ()

# try default paths as a last hope
if (NOT Z3_FOUND)
find_path(Z3_CXX_INCLUDE_DIRS NAMES z3.h z3++.h
PATH_SUFFIXES libz3 z3)
find_library(Z3_LIBRARIES NAMES z3 libz3
PATH_SUFFIXES lib bin)
find_path(Z3_CXX_INCLUDE_DIRS NAMES z3.h z3++.h
PATH_SUFFIXES libz3 z3)
find_library(Z3_LIBRARIES NAMES z3 libz3
PATH_SUFFIXES lib bin)

unset(Z3_VERSION_STRING)
unset(Z3_VERSION_STRING)

# Try to check version by compiling a small program that prints Z3's version
if(Z3_CXX_INCLUDE_DIRS AND Z3_LIBRARIES)
check_z3_version(${Z3_CXX_INCLUDE_DIRS} ${Z3_LIBRARIES})
endif()
# Try to check version by compiling a small program that prints Z3's version
if (Z3_CXX_INCLUDE_DIRS AND Z3_LIBRARIES)
check_z3_version(${Z3_CXX_INCLUDE_DIRS} ${Z3_LIBRARIES})
endif ()

if(NOT Z3_VERSION_STRING)
set(Z3_VERSION_STRING "0.0.0")
endif()
if (NOT Z3_VERSION_STRING)
set(Z3_VERSION_STRING "0.0.0")
endif ()

include (FindPackageHandleStandardArgs)
find_package_handle_standard_args(Z3
REQUIRED_VARS Z3_LIBRARIES Z3_CXX_INCLUDE_DIRS
VERSION_VAR Z3_VERSION_STRING)
mark_as_advanced(Z3_CXX_INCLUDE_DIRS Z3_LIBRARIES)
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Z3
REQUIRED_VARS Z3_LIBRARIES Z3_CXX_INCLUDE_DIRS
VERSION_VAR Z3_VERSION_STRING)
mark_as_advanced(Z3_CXX_INCLUDE_DIRS Z3_LIBRARIES)
endif ()
1 change: 1 addition & 0 deletions extern/LogicBlocks
Submodule LogicBlocks added at 6c848a
85 changes: 0 additions & 85 deletions include/Encodings.hpp

This file was deleted.

4 changes: 0 additions & 4 deletions include/exact/ExactMapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#ifndef EXACT_MAPPER_hpp
#define EXACT_MAPPER_hpp

#include "Encodings.hpp"
#include "Mapper.hpp"

#include <algorithm>
Expand All @@ -16,10 +15,7 @@
#include <functional>
#include <set>
#include <unordered_set>
#include <z3++.h>

using namespace z3;
using matrix = std::vector<expr_vector>;
using Swaps = std::vector<std::pair<unsigned short, unsigned short>>;
using QubitChoice = std::set<unsigned short>;

Expand Down
Loading