Commit ffc4e4ce authored by Mateusz Rychlicki's avatar Mateusz Rychlicki
Browse files

Add SylvanUBDD.h

parent 8a8f325e
......@@ -5,6 +5,7 @@ project(PoorMascot VERSION 1.0.1 DESCRIPTION "Poor Mascot ")
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
add_link_options(--coverage -pthread)
add_subdirectory(fairsyn)
......
......@@ -10,11 +10,14 @@ list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(MIN_Cudd_VERSION 3.0)
find_package(Cudd ${MIN_Cudd_VERSION} REQUIRED)
set(MIN_Sylvan_VERSION 1.6)
find_package(Sylvan REQUIRED)
##############################################
# Create target and set properties
add_library(poorfairsyn
src/CuddUBDD.cpp)
src/ubdd/CuddUBDD.cpp
src/ubdd/SylvanUBDD.cpp)
#Add an alias so that library can be used inside the build tree, e.g. when testing
......@@ -32,9 +35,10 @@ target_include_directories(poorfairsyn
target_compile_features(poorfairsyn PRIVATE cxx_auto_type)
target_compile_options(poorfairsyn PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall -Wextra -Wpedantic>)
-Wall -Wextra -Wpedantic> )
target_link_libraries(poorfairsyn PRIVATE Cudd::Cudd)
target_link_libraries(poorfairsyn PRIVATE Cudd::Cudd Sylvan::Sylvan)
add_link_options(--coverage -pthread )
##############################################
# Installation instructions
......@@ -79,6 +83,7 @@ configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/PoorFairSynConfig.
#Install the config, configversion and custom find modules
install(FILES
${CMAKE_CURRENT_LIST_DIR}/cmake/FindCudd.cmake
${CMAKE_CURRENT_LIST_DIR}/cmake/FindSylvan.cmake
${CMAKE_CURRENT_BINARY_DIR}/PoorFairSynConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/PoorFairSynConfigVersion.cmake
DESTINATION ${INSTALL_CONFIGDIR}
......@@ -90,6 +95,10 @@ configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/FindCudd.cmake
${CMAKE_CURRENT_BINARY_DIR}/FindCudd.cmake
COPYONLY)
configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/FindSylvan.cmake
${CMAKE_CURRENT_BINARY_DIR}/FindSylvan.cmake
COPYONLY)
export(EXPORT poorfairsyn-targets
FILE ${CMAKE_CURRENT_BINARY_DIR}/PoorFairSynTargets.cmake
NAMESPACE PoorFairSyn::)
......@@ -100,4 +109,4 @@ export(PACKAGE PoorFairSyn)
##############################################
## Add test
enable_testing()
add_subdirectory(test)
\ No newline at end of file
add_subdirectory(test)
message(mascot/fairsyn/cmake/FindSylvan.cmake)
find_package(PkgConfig)
pkg_check_modules(PC_Sylvan QUIET Sylvan)
find_path(Sylvan_INCLUDE_DIR NAMES sylvan.h)
find_library(Sylvan_STATIC_LIB_DIR NAMES libSylvan.a)
find_library(Sylvan_SHARED_LIB_DIR NAMES libSylvan.so)
set(Sylvan_VERSION ${PC_Sylvan_VERSION})
mark_as_advanced(Sylvan_FOUND Sylvan_INCLUDE_DIR Sylvan_VERSION)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Sylvan
REQUIRED_VARS Sylvan_INCLUDE_DIR
VERSION_VAR Sylvan_VERSION
)
if(Sylvan_FOUND)
#Set include dirs to parent, to enable includes like #include <Sylvan/document.h>
get_filename_component(Sylvan_INCLUDE_DIRS ${Sylvan_INCLUDE_DIR} DIRECTORY)
endif()
if(Sylvan_FOUND AND NOT TARGET Sylvan::Sylvan)
add_library(Sylvan::Sylvan STATIC IMPORTED)
set_target_properties(
Sylvan::Sylvan
PROPERTIES
IMPORTED_LOCATION ${Sylvan_STATIC_LIB_DIR}
INTERFACE_INCLUDE_DIRECTORIES "${Sylvan_INCLUDE_DIRS}"
)
endif()
#add_link_options(--coverage)
......@@ -3,10 +3,13 @@ get_filename_component(POORFAIRSYN_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(CMakeFindDependencyMacro)
list(APPEND CMAKE_MODULE_PATH ${POORFAIRSYN_CMAKE_DIR})
# NOTE: to find FindCudd.cmake
# NOTE: to find FindSylvan.cmake
find_dependency(Sylvan @MIN_Sylvan_VERSION@)
find_dependency(Cudd @MIN_Cudd_VERSION@)
list(REMOVE_AT CMAKE_MODULE_PATH -1)
if(NOT TARGET PoorFairSyn::PoorFairSyn)
include("${POORFAIRSYN_CMAKE_DIR}/PoorFairSynTargets.cmake")
endif()
......
//
// Created by mrychlicki on 9/8/21.
//
#pragma once
#include "BaseUBDD.h"
#include "sylvan_obj.hpp"
#include "sylvan_bdd.h"
namespace poorfairsyn {
class PoorSylvanUBDD : public poorfairsyn::PoorBaseUBDD {
private:
std::string folder;
sylvan::Bdd bdd;
public:
PoorSylvanUBDD(std::string s) {
init_sylvan();
folder = s;
bdd = bdd.bddVar(0) | bdd.bddVar(1);
}
~PoorSylvanUBDD() {
stop_sylvan();
}
void print_bdd();
void init_sylvan() {
/* initiate the lace work-stealing framework and the sylvan parallel bdd library */
int dqsize = 100000;
lace_start(2, dqsize);
// use at most 1 GB, nodes:cache ratio 2:1, initial size 1/32 of maximum
sylvan::sylvan_set_limits(1 * 1024 * 1024 * 1024, 1, 5);
sylvan::sylvan_init_package();
sylvan::sylvan_init_mtbdd();
}
void stop_sylvan() {
sylvan::sylvan_stats_report(stdout);
sylvan::sylvan_quit();
lace_stop();
}
};
}
\ No newline at end of file
//
// Created by mrychlicki on 9/8/21.
//
#include <iostream>
#include <assert.h>
#include "ubdd/CuddUBDD.h"
namespace poorfairsyn {
......
//
// Created by mrychlicki on 9/8/21.
//
#include "ubdd/SylvanUBDD.h"
namespace poorfairsyn {
void PoorSylvanUBDD::print_bdd() {
std::cout << "Sylvan Works: " + folder << "\n";
assert(bdd.SatCount(2) == 3);
}
}
include(GoogleTest) # For Terminal
find_package(GTest REQUIRED) # For Clion
# Now simply link against gtest as needed. Eg
message(mascot/farisyn/test)
add_executable(poorfairsyn_test src/main.cpp)
add_executable(poorfairsyn_test
src/ubdd/CuddUBDDTests.cpp
src/ubdd/SylvanUBDDTests.cpp
tests.cpp
)
target_compile_features(poorfairsyn_test PRIVATE cxx_auto_type)
target_link_libraries(poorfairsyn_test PoorFairSyn::poorfairsyn)
target_link_libraries(poorfairsyn_test PoorFairSyn::poorfairsyn GTest::GTest GTest::Main)
......@@ -2,11 +2,10 @@
// Created by mrychlicki on 9/8/21.
//
#include <gtest/gtest.h>
#include "ubdd/CuddUBDD.h"
#include "ubdd/BaseUBDD.h"
int main()
{
poorfairsyn::PoorCuddUBDD p("PoorFairSyn");
TEST(CuddUBDDTest, simple) {
poorfairsyn::PoorCuddUBDD p("fairsyn - cudd");
p.print_bdd();
}
}
\ No newline at end of file
//
// Created by mrychlicki on 9/8/21.
//
#include <gtest/gtest.h>
#include "ubdd/SylvanUBDD.h"
TEST(SylvanUBDDTest, simple) {
poorfairsyn::PoorSylvanUBDD p("fairsyn - Sylvan");
p.print_bdd();
}
\ No newline at end of file
//
// Created by mrychlicki on 7/27/21.
//
#include "gtest/gtest.h"
int main(int argc, char *argv[]) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
\ No newline at end of file
......@@ -3,7 +3,11 @@
//
#include "ubdd/CuddUBDD.h"
#include "ubdd/SylvanUBDD.h"
int main() {
poorfairsyn::PoorCuddUBDD p("mascot");
p.print_bdd();
poorfairsyn::PoorCuddUBDD c("mascot");
c.print_bdd();
poorfairsyn::PoorSylvanUBDD s("mascot");
s.print_bdd();
}
\ No newline at end of file
cmake_minimum_required(VERSION 3.13...3.16 FATAL_ERROR)
project(OtherProject VERSION 0.0.1 LANGUAGES CXX)
message("other_project")
add_link_options(--coverage -pthread)
add_executable(OtherProject src/test.cpp)
target_compile_features(OtherProject PRIVATE cxx_auto_type)
......
//
// Created by mrychlicki on 9/8/21.
//
#include "ubdd/CuddUBDD.h"
#include "ubdd/SylvanUBDD.h"
int main() {
poorfairsyn::PoorCuddUBDD p("other_project");
p.print_bdd();
poorfairsyn::PoorCuddUBDD c("other_project");
c.print_bdd();
poorfairsyn::PoorSylvanUBDD s("other_project");
s.print_bdd();
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment