{"id":49141753,"url":"https://github.com/cornell-zhang/hcl-dialect","last_synced_at":"2026-04-22T01:09:47.632Z","repository":{"id":79683408,"uuid":"429576417","full_name":"cornell-zhang/hcl-dialect","owner":"cornell-zhang","description":"HeteroCL-MLIR dialect for accelerator design","archived":false,"fork":false,"pushed_at":"2024-09-18T17:30:27.000Z","size":3845,"stargazers_count":41,"open_issues_count":27,"forks_count":15,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-09-10T01:37:58.935Z","etag":null,"topics":["compiler","fpga","fpga-programming","high-level-synthesis","intermediate-representation","open-source-hardware"],"latest_commit_sha":null,"homepage":"https://cornell-zhang.github.io/heterocl/index.html","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cornell-zhang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-18T20:52:53.000Z","updated_at":"2025-05-28T19:29:11.000Z","dependencies_parsed_at":"2023-10-29T20:30:31.511Z","dependency_job_id":"346b01fb-27fd-4021-95c2-49e626dc3634","html_url":"https://github.com/cornell-zhang/hcl-dialect","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cornell-zhang/hcl-dialect","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornell-zhang%2Fhcl-dialect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornell-zhang%2Fhcl-dialect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornell-zhang%2Fhcl-dialect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornell-zhang%2Fhcl-dialect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cornell-zhang","download_url":"https://codeload.github.com/cornell-zhang/hcl-dialect/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornell-zhang%2Fhcl-dialect/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32116541,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T00:31:26.853Z","status":"ssl_error","status_checked_at":"2026-04-22T00:30:22.894Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","fpga","fpga-programming","high-level-synthesis","intermediate-representation","open-source-hardware"],"created_at":"2026-04-22T01:09:47.097Z","updated_at":"2026-04-22T01:09:47.627Z","avatar_url":"https://github.com/cornell-zhang.png","language":"C++","readme":"\u003c!--- Copyright HeteroCL authors. All Rights Reserved. --\u003e\n\u003c!--- SPDX-License-Identifier: Apache-2.0  --\u003e\n\n# HeteroCL Dialect\n\n## Overview\n\n![flow](docs/dialect_overview.png)\n\nHeteroCL dialect is an out-of-tree [MLIR](https://mlir.llvm.org/) dialect for accelerator design. HeteroCL dialect decouples algorithm from hardware customizations, and classifies them into compute and data customizations. The HeteroCL dialect is part of the [HeteroCL](https://github.com/cornell-zhang/heterocl) compilation flow. HeteroCL provides an end-to-end flow from Python to LLVM backend or C HLS FPGA backends. With HeteroCL, designers can explore tradeoffs with hardware customizations in a systematic manner and quickly obtain high-performance design with little manual effort.\n\n\n## Building\n\n### Preliminary tools\n- gcc \u003e= 9 (Please make sure you have installed the gcc that supports C++17)\n- cmake \u003e= 3.22\n- python \u003e= 3.8\n\n### Install LLVM 18.x\n- Download LLVM from [llvm-project](https://github.com/llvm/llvm-project) or checkout the Github branch\n```sh\ngit clone https://github.com/llvm/llvm-project.git\ncd llvm-project\ngit checkout tags/llvmorg-18-init\n```\n\n- Build\n   - Without Python binding\n   ```sh\n   mkdir build \u0026\u0026 cd build\n   cmake -G \"Unix Makefiles\" ../llvm \\\n      -DLLVM_ENABLE_PROJECTS=mlir \\\n      -DLLVM_BUILD_EXAMPLES=ON \\\n      -DLLVM_TARGETS_TO_BUILD=\"X86\" \\\n      -DCMAKE_BUILD_TYPE=Release \\\n      -DLLVM_ENABLE_ASSERTIONS=ON \\\n      -DLLVM_INSTALL_UTILS=ON\n   make -j8\n   # You can either use ninja to build\n   # cmake -G Ninja\n   # ninja\n   ```\n   - With Python binding: Please follow the [official guide](https://mlir.llvm.org/docs/Bindings/Python/#generating-_dialect_namespace_ops_genpy-wrapper-modules) to set up the environment. In the following, we set up a virtual environment called `hcl-dev` using Python venv, but we prefer you to install Anaconda3 and create an environment there. If you want to use your own Python environment, please specify the path for `-DPython3_EXECUTABLE`.\n   ```sh\n   # Create a virtual environment. Make sure you have installed Python3.\n   which python3\n   python3 -m venv ~/.venv/hcl-dev\n   source ~/.venv/hcl-dev/bin/activate\n\n   # It is recommended to upgrade pip\n   python3 -m pip install --upgrade pip\n\n   # Install required packages. Suppose you are inside the llvm-project folder.\n   python3 -m pip install -r mlir/python/requirements.txt\n\n   # Run cmake\n   mkdir build \u0026\u0026 cd build\n   cmake -G \"Unix Makefiles\" ../llvm \\\n      -DLLVM_ENABLE_PROJECTS=mlir \\\n      -DLLVM_BUILD_EXAMPLES=ON \\\n      -DLLVM_TARGETS_TO_BUILD=\"host\" \\\n      -DCMAKE_BUILD_TYPE=Release \\\n      -DLLVM_ENABLE_ASSERTIONS=ON \\\n      -DLLVM_INSTALL_UTILS=ON \\\n      -DMLIR_ENABLE_BINDINGS_PYTHON=ON \\\n      -DPython3_EXECUTABLE=`which python3`\n   make -j8\n   # You can either use ninja to build\n   # cmake -G Ninja\n   # ninja\n\n   # Export the LLVM build directory\n   export LLVM_BUILD_DIR=$(pwd)\n\n   # To enable better backtracing for debugging,\n   # we suggest setting the following system path\n   export LLVM_SYMBOLIZER_PATH=$(pwd)/bin/llvm-symbolizer\n   ```\n\n### Build HeteroCL Dialect\nThis setup assumes that you have built LLVM and MLIR in `$LLVM_BUILD_DIR`. Please firstly clone our repository.\n```sh\ngit clone --recursive git@github.com:cornell-zhang/hcl-dialect.git\ncd hcl-dialect\nmkdir build \u0026\u0026 cd build\n```\n\n\u003e **_NOTE:_**  The HeteroCL dialect is a standalone system that works without a frontend. If you are using it with the HeteroCL frontend, the minimum requirement is to build with Python binding. Building with OpenSCoP extraction is optional.\n\n- Build without Python binding\n```sh\ncmake -G \"Unix Makefiles\" .. \\\n   -DMLIR_DIR=$LLVM_BUILD_DIR/lib/cmake/mlir \\\n   -DLLVM_EXTERNAL_LIT=$LLVM_BUILD_DIR/bin/llvm-lit \\\n   -DPYTHON_BINDING=OFF \\\n   -DOPENSCOP=OFF\nmake -j8\n```\n\n- Build with Python binding\n```sh\ncmake -G \"Unix Makefiles\" .. \\\n   -DMLIR_DIR=$LLVM_BUILD_DIR/lib/cmake/mlir \\\n   -DLLVM_EXTERNAL_LIT=$LLVM_BUILD_DIR/bin/llvm-lit \\\n   -DPYTHON_BINDING=ON \\\n   -DOPENSCOP=OFF \\\n   -DPython3_EXECUTABLE=`which python3` \\\n   -DCMAKE_CXX_FLAGS=\"-Wfatal-errors -std=c++17\"\nmake -j8\n\n# Export the generated HCL-MLIR Python library\nexport PYTHONPATH=$(pwd)/tools/hcl/python_packages/hcl_core:${PYTHONPATH}\n```\n\n- Build with OpenSCoP extraction enabled: Set `-DOPENSCOP=ON` and export the library path.\n```sh\nexport LD_LIBRARY_PATH=$(pwd)/openscop/lib:$LD_LIBRARY_PATH\n```\n\n\nLastly, you can use the following integration test to see whether your built dialect works properly.\n```\ncmake --build . --target check-hcl\n```\n\n\n## Run HeteroCL Dialect\n```sh\n# perform loop transformation passes\n./bin/hcl-opt -opt ../test/Transforms/compute/tiling.mlir\n\n# generate C++ HLS code\n./bin/hcl-opt -opt ../test/Transforms/compute/tiling.mlir | \\\n./bin/hcl-translate -emit-vivado-hls\n\n# generate OpenSCoP\n# An hcl.openscop file will be generated in the build folder\n./bin/hcl-opt -opt ../test/Transforms/memory/buffer_add.mlir | \\\n./bin/hcl-translate --extract-scop-stmt\n\n# run code on CPU\n./bin/hcl-opt -opt -jit ../test/Translation/mm.mlir\n```\n\n\n## Integrate with upstream HeteroCL frontend\nMake sure you have correctly built the above HCL-MLIR dialect, and follow the instruction below.\n\n```sh\n# clone the HeteroCL repo\ngit clone https://github.com/cornell-zhang/heterocl.git heterocl-mlir\ncd heterocl-mlir\n\n# install dependencies\npython3 -m pip install -r requirements.txt\n\n# export the library\nexport HCL_HOME=$(pwd)\nexport PYTHONPATH=$HCL_HOME/python:${PYTHONPATH}\n\n# run regression tests in the HeteroCL repo\ncd tests \u0026\u0026 python3 -m pytest\n```\n\n## HeteroCL Dialect Examples\n\n![flow](docs/dialect_examples.png)\n\n\n## Coding Style\n\nWe follow [Google Style Guides](https://google.github.io/styleguide/) and use\n* [clang-format](https://clang.llvm.org/docs/ClangFormat.html) for C/C++\n* [black](https://github.com/psf/black) and [pylint](https://pylint.org/) for Python\n\nTo install `clang-format`, you can reuse the LLVM project by specifying the following CMake options:\n\n```sh\n# Inside the llvm-project folder\nmkdir build-clang \u0026\u0026 cd build-clang\ncmake -G Ninja ../llvm \\\n   -DLLVM_ENABLE_PROJECTS=\"clang\" \\\n   -DLLVM_BUILD_EXAMPLES=ON \\\n   -DLLVM_TARGETS_TO_BUILD=\"host\" \\\n   -DCMAKE_BUILD_TYPE=Release \\\n   -DLLVM_ENABLE_ASSERTIONS=ON \\\n   -DLLVM_INSTALL_UTILS=ON\nninja clang-format\n```\n\n## References\n* [ScaleHLS](https://github.com/hanchenye/scalehls)\n* [Torch-MLIR](https://github.com/llvm/torch-mlir)\n* [Polymer](https://github.com/kumasento/polymer)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcornell-zhang%2Fhcl-dialect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcornell-zhang%2Fhcl-dialect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcornell-zhang%2Fhcl-dialect/lists"}