Giter Club home page Giter Club logo

nanobdd's Introduction

Nanobdd

First-ever high-performance thread-safe BDD (Binary Decision Diagrams) library.

As of our research, Nanobdd is currently the fastest BDD library available, achieving exceptional performance in various benchmarks and use cases.

This project is the public implementation of our SIGCOMM'23 poster:

  • Guo D, Luo J, Gao K, et al. Poster: Scaling Data Plane Verification with Throughput-Optimized Atomic Predicates. In Proceedings of the SIGCOMM '23 Poster and Demo Sessions (SIGCOMM '23), New York, NY, USA, Sep. 10 2023.

Features

  • Fully lock-free concurrency
  • Automatic referencing for BDD nodes
  • User controlled garbage collection
  • Easy-to-use APIs by C++ operator overloading
  • And of course, it is thread-safe!

Install

Dependencies

Nanobdd depends on tbb for concurrent data structures.

CMake (>=v3.2) and g++(>=v9) are required for compilation.

Compile and install

Nanobdd follows the standard CMake project structure, the quick installation steps are as follows:

git clone https://github.com/guodong/nanobdd
cd nanobdd
mkdir build
cd build
cmake ..
make
sudo make install

Basic usage

A simple c++ code to use nanobdd is as follows:

// include the nanobdd header file
#include <nanobdd/nanobdd.h>
#include <assert.h>

int main(int argc, char** argv) {
  // init nanobdd with node table size, cache size, and the number of variables
  nanobdd::init(1000, 1000, 3);

  // get the three variables
  auto x = nanobdd::getVar(0);
  auto y = nanobdd::getVar(1);
  auto z = nanobdd::getVar(2);

  // do magic using c++ operators
  auto xy = x & y;
  auto xyz = xy & z;
  auto xyZ = xy & !z;

  assert(xy == (xyz | xyZ));
  assert(xy != nanobdd::bddFalse());

  return 0;
}

Compile and execute the above code by:

g++ -o exe test.cpp -lnanobdd -ltbb
./exe

If no exceptions, that means the assertions are passed.

Thread-safe concurrency

The most powerful feature of nanobdd is that it is thread-safe, which is achieved lock-free algorithms. One can safely perform any bdd operations in different threads, nanobdd will handle all underlay data contensions. An example for using C++17 parallel STL:

std::for_each(
  std::execution::par,
  somebdds.begin(),
  somebdds.end(),
  [&](auto bdd) {
    // operate your bdd here
  });

See examples/paralle.cpp for full example.

Performance

We have compared nanobdd with other librarys including Buddy, JDD and Sylvan in a network verification project on a 40 CPU cores server. Typically, nanobdd is 2~10x faster than others.

Author and contact

Author: Dong Guo (PhD candidate of Tongji University)

Email: [email protected]

nanobdd's People

Contributors

guodong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.