MCPcopy Create free account
hub / github.com/PKU-IDEA/OpenPARF

github.com/PKU-IDEA/OpenPARF @2.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 2.0.0 ↗ · + Follow
11,920 symbols 31,943 edges 968 files 3,591 documented · 30% updated 14mo ago★ 1782 open issues

Browse by type

Functions 9,719 Types & classes 2,201
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

OpenPARF

🕹 OpenPARF is an open-source FPGA placement and routing framework build upon the deep learning toolkit PyTorch. It is designed to be flexible, efficient, and extensible.

News

  • 🎉 (2024/02/02) We are excited to announce the release of OpenPARF 2.0! This release includes a number of significant improvements and new features, including multi-die FPGA placement support and a new architecture definition format Flexshelf. We have also made a number of improvements to unit tests and documentation. We encourage all users to upgrade to this new version.

More About OpenPARF

OpenPARF is an open-source framework for FPGA rapid placement and routing, which can run on both CPU and GPU. OpenPARF provides a number of APIs to enable researchers to quickly prototype their own FPGA algorithms and evaluate their performance on real FPGA hardware.

At a granular level, OpenPARF is a framework that consists of the following components:

Component Description
openparf The core placement and routing tool
openparf.ops A collection of operators that allow the implementation of various P&R algorithms
openparf.placement A set of APIs for performing placement tasks
openparf.routing A set of APIs for performing routing tasks
openparf.py_utils Provides other utility functions for Python convenience

OpenPARF provides a compilation stack to integrate your placement and routing algorithms into operators that can be used in Python. You can extend OpenPARF as needed, making it the ideal environment for FPGA optimization enthusiasts.

Elaborating Further:

A Multi-Electrostatic-based FPGA P&R Framework

OpenPARF is a powerful FPGA P&R framework that utilizes a multi-electrostatic-based approach to achieve optimal results with respect to routed wirelength and placement speed. OpenPARF supports the following features:

- A wide range of logical unit types including LUT, FF, DSP, BRAM, IO, Distributed RAM, and Shift Register
- Support for SLICEL and SLICEM CLB heterogeneous types
- Clock routing constraints
- Advanced support for multi-die FPGA placement
- ...

OpenPARF has proven to be a powerful tool, outperforming the state-of-the-art academic FPGA P&R tools in terms of wired length and placement speed. With a 0.4-12.7% improvement in routed wirelength and a speedup of over 2X in placement, OpenPARF is a highly efficient FPGA P&R framework that offers optimized results with minimal manual intervention.

Single-Die Reference Flow

overflow

Demo

The following are the visualization for electrostatic fields in benchmark ISPD2016/FPGA06.

LUT FF DSP BRAM
LUT ff dsp BRAM

Multi-Die Placement for OpenPARF

Brief Introduction

In the ongoing endeavor to enhance OpenPARF, we have integrated a key feature from the LEAPS - a specialized solution aimed at minimizing super long line (SLL) counts in multi-die FPGA placement. This integration not only enriches OpenPARF's capabilities but also addresses the complexities of modern multi-die FPGA designs.

Compared to the existing state-of-the-art method, OpenPARF demonstrates significant superiority, achieving an average reduction of 43.08% in the SLL counts and a 9.99% optimization in half-perimeter wirelength (HPWL). Notably, OpenPARF leverages GPU acceleration technology, achieving a remarkable runtime improvement of up to 34.34X.

Multi-Die Reference Flow

multi-die_overflow

Prerequisites

OpenPARF is written in C++ and Python. The following are the prerequisites for building OpenPARF.

  • Python 3.7 or above.
  • C++ compiler with C++14 support, recommended to use GCC 7.5. Other version may also work, but have not been tested.
  • PyTorch 1.7.1. Other version may also work, but have not been tested. Please refer to the next section to install PyTorch through conda environment.
  • Gurobi 9.5 (optional, if the router is compiled). Other version may also work, but have not been tested. Please make sure to obtain a valid license and follow the installation instructions provided on the Gurobi website. Note that only the router uses gurobi in OpenPARF. If you do not need a router, you can leave gurobi uninstalled and set ENABL_ROUTER to OFF when compiling OpenPARF.
  • NVIDIA CUDA 11.0 (optional, if compiled with CUDA support). Other versions may also work, but have not been tested. If CUDA is found, the project can run on the GPU implementation, otherwise it will only run on the CPU implementation.

We have provided two ways to build OpenPARF,

Build from Source

Install Dependencies

We highly recommend installing an Anaconda or Mamba environment. You will get controlled dependency versions regardless of your Linux distro.

# * create and activate conda environment
mamba create --name openparf python=3.7
mamba activate openparf

# * common packages
mamba install cmake boost bison

# * Pytorch 1.7.1. Other version may also work, but have not been tested.
mamba install pytorch==1.7.1 torchvision==0.8.2 cudatoolkit=11.0 -c pytorch

# * python packages
pip install hummingbird-ml pyyaml networkx tqdm

Install Gurobi (Optional)

Permit me to illuminate the exquisite process of installing Gurobi, using the recommended Gurobi 9.5.1 as a quintessential example:

  1. Download the gurobi9.5.1_linux64.tar.gz, and then extract it to a location of your choosing, aptly referred to as <your Gurobi home>.
  2. Next, you must obtain a license for Gurobi. To do so, you must first create an account on the Gurobi website. Once you have created an account, you will be able to request an license. Once you receive your license, you will be able to download it from the Gurobi website. The license will be a file with the extension .lic. Save this file to a location of your choosing, aptly referred to as <your Gurobi license path>.
  3. Finally, you must set the following environment variables. You can do so by adding the following lines to your ~/.bashrc file.
export GUROBI_HOME="<your Gurobi home>/linux64"
# For example,
# export GUROBI_HOME="/home/jingmai/softwares/gurobi951/linux64"
export GRB_LICENSE_FILE="<your Gurobi license path>"
# For example,
# export GRB_LICENSE_FILE="/home/jingmai/licenses/gurobi.lic"
export PATH="${PATH}:${GUROBI_HOME}/bin"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib"

Now, please go to the Build and Install OpenPARF section to build and install OpenPARF.

Build with Docker

Docker Image

Using pre-built images

You can also pull a pre-built docker image from Docker Hub.

docker pull magic3007/openparf:2.0
Building the image yourself

You can also build the docker image yourself. The dockerfile is located in docker/openparf.dockerfile. To build the image, run the following command:

cd 

/docker
docker build . -t openparf:2.0 -f openparf.dockerfile

Running the Docker Image

We recommend that you have the following two directories/files on your host before running docker:

  1. `

: The directory where you store the OpenPARF source code on host. See [Get the OpenPARF Source](#get-the-openparf-source) for more details. 2.`: The directory where you store the ISPD 2016/2017 benchmarks on host. See Obtaining Benchmarks for more details.

Without CUDA Support To run the docker image without CUDA support, run the following command:

docker run -itd --restart=always --network host -e TERM=$TERM \
  --name openparf \
  -v /etc/localtime:/etc/localtime:ro \
  -v <project directory on host>:/root/OpenPARF \
  -v <benchmark directory on host>:/root/benchmarks \
  openparf:2.0 \
  /bin/bash;

With CUDA Support To run the docker image with CUDA support, run the following command:

docker run -itd --restart=always --network host -e TERM=$TERM \
  --name openparf \
  --gpus all \
  -v /etc/localtime:/etc/localtime:ro \
  -v <project directory on host>:/root/OpenPARF \
  -v <benchmark directory on host>:/root/benchmarks \
  openparf:2.0 \
  /bin/bash;

Entering the Docker Container

Once the docker image is running, you can enter the docker container by running the following command:

docker exec -it openparf /bin/bash

Within the docker container:

  • the OpenPARF source code will be located in /root/OpenPARF.
  • the ISPD 2016/2017 benchmarks will be located in /root/benchmarks.

NOTE that though we have gurobi 9.5.1 installed in docker (located in /opt/gurobi), due to permission reasons, if you need router, you still need to get gurobi license and place it as /root/gurobi.lic.

Now, please go to the Build and Install OpenPARF section to build and install OpenPARF.

Build and Install OpenPARF

Get the OpenPARF Source

git clone --recursive https://github.com/PKU-IDEA/OpenPARF.git

If you have already clone the repository, e.g., the repository is mounted in the docker container, you can skip this step.

Install OpenPARF

Assuming that OpenAPRF is a subfolder in the current directory, i.e., ./OpenPARF is the path to the OpenPARF source code.

mkdir build
cd build
cmake ../OpenPARF -DCMAKE_PREFIX_PATH=$CONDA_PREFIX -DPYTHON_EXECUTABLE=$(which python) -DPython3_EXECUTABLE=$(which python) -DCMAKE_INSTALL_PREFIX=<installation directory>
make -j8
make install

Where <installation directory> is the directory where you want to install OpenPARF (e.g., ../install).

Adjust Build Options (Optional)

You can adjust the configuration of cmake variables optionally (without buiding first), by doing the following.

  • CMAKE_INSTALL_PREFIX: The directory where you want to install OpenPARF (e.g., ../install).
  • CMAKE_BUILD_TYPE: The build type, can be Release or Debug. Default is Release.
  • USE_CCACHE: Whether to use ccache to speed up compilation. Default is OFF.
  • ENABLE_ROUTER: Whether to compile the router. Default is OFF.

Core symbols most depended-on inside this repo

Shape

Method 7,684
Class 2,066
Function 2,035
Enum 135

Languages

C++90%
Python6%
C4%
TypeScript1%

Modules by API surface

openparf/routing/fpga-router/3rdparty/pugixml/pugixml/pugixml.cpp542 symbols
openparf/routing/fpga-router/3rdparty/clipp/clipp/clipp.h426 symbols
openparf/routing/fpga-router/3rdparty/lemon/lemon/adaptors.h352 symbols
openparf/routing/fpga-router/3rdparty/lemon/lemon/maps.h300 symbols
openparf/routing/fpga-router/3rdparty/lemon/lemon/list_graph.h255 symbols
openparf/routing/fpga-router/3rdparty/lemon/lemon/edge_set.h194 symbols
openparf/routing/fpga-router/3rdparty/lemon/lemon/smart_graph.h188 symbols
openparf/routing/fpga-router/3rdparty/lemon/lemon/concepts/graph_components.h183 symbols
openparf/routing/fpga-router/3rdparty/lemon/lemon/full_graph.h177 symbols
openparf/routing/fpga-router/3rdparty/gdstk/gdstk/clipperlib/clipper.cpp174 symbols
openparf/routing/fpga-router/3rdparty/lemon/lemon/lp_base.h133 symbols
openparf/routing/fpga-router/3rdparty/lemon/lemon/core.h133 symbols

For agents

$ claude mcp add OpenPARF \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page