{"id":13667327,"url":"https://github.com/llvm/Polygeist","last_synced_at":"2025-04-26T15:32:32.413Z","repository":{"id":37076252,"uuid":"278118079","full_name":"llvm/Polygeist","owner":"llvm","description":"C/C++ frontend for MLIR. Also features polyhedral optimizations, parallel optimizations, and more!","archived":false,"fork":false,"pushed_at":"2024-10-02T04:54:36.000Z","size":1113790,"stargazers_count":535,"open_issues_count":87,"forks_count":130,"subscribers_count":21,"default_branch":"main","last_synced_at":"2025-04-20T08:24:05.898Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://polygeist.llvm.org","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/llvm.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":"2020-07-08T14:54:25.000Z","updated_at":"2025-04-19T07:36:35.000Z","dependencies_parsed_at":"2024-04-17T17:20:58.304Z","dependency_job_id":"5fca893d-ce70-406e-a9af-c20a521a7a29","html_url":"https://github.com/llvm/Polygeist","commit_stats":{"total_commits":724,"total_committers":28,"mean_commits":"25.857142857142858","dds":0.6022099447513812,"last_synced_commit":"77c04bb2a7a2406ca9480bcc9e729b07d2c8d077"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llvm%2FPolygeist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llvm%2FPolygeist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llvm%2FPolygeist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/llvm%2FPolygeist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/llvm","download_url":"https://codeload.github.com/llvm/Polygeist/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250681319,"owners_count":21470188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-08-02T07:00:35.146Z","updated_at":"2025-04-26T15:32:32.389Z","avatar_url":"https://github.com/llvm.png","language":"C++","funding_links":[],"categories":["C++","Starchart"],"sub_categories":[],"readme":"# Build instructions\n\n## Requirements \n- Working C and C++ toolchains(compiler, linker)\n- cmake\n- make or ninja\n\n## 1. Clone Polygeist\n```sh\ngit clone --recursive https://github.com/llvm/Polygeist\ncd Polygeist\n```\n\n## 2. Install LLVM, MLIR, Clang, and Polygeist\n\n### Option 1: Using pre-built LLVM, MLIR, and Clang\n\nPolygeist can be built by providing paths to a pre-built MLIR and Clang toolchain.\n\n#### 1. Build LLVM, MLIR, and Clang:\n```sh\nmkdir llvm-project/build\ncd llvm-project/build\ncmake -G Ninja ../llvm \\\n  -DLLVM_ENABLE_PROJECTS=\"mlir;clang\" \\\n  -DLLVM_TARGETS_TO_BUILD=\"host\" \\\n  -DLLVM_ENABLE_ASSERTIONS=ON \\\n  -DCMAKE_BUILD_TYPE=DEBUG\nninja\nninja check-mlir\n```\n\nTo enable compilation to cuda add `-DMLIR_ENABLE_CUDA_RUNNER=1` and remove `-DLLVM_TARGETS_TO_BUILD=\"host\"` from the cmake arguments. (You may need to specify `CUDACXX`, `CUDA_PATH`, and/or `-DCMAKE_CUDA_COMPILER`)\n\nTo enable the ROCM backend add `-DMLIR_ENABLE_ROCM_RUNNER=1` and remove `-DLLVM_TARGETS_TO_BUILD=\"host\"` from the cmake arguments. (You may need to specify `-DHIP_CLANG_INCLUDE_PATH`, and/or `ROCM_PATH`)\n\nFor ISL-enabled polymer, `polly` must be added to the `LLVM_ENABLE_PROJECTS` variable.\n\nFor faster compilation we recommend using `-DLLVM_USE_LINKER=lld`.\n\n#### 2. Build Polygeist:\n```sh\nmkdir build\ncd build\ncmake -G Ninja .. \\\n  -DMLIR_DIR=$PWD/../llvm-project/build/lib/cmake/mlir \\\n  -DCLANG_DIR=$PWD/../llvm-project/build/lib/cmake/clang \\\n  -DLLVM_TARGETS_TO_BUILD=\"host\" \\\n  -DLLVM_ENABLE_ASSERTIONS=ON \\\n  -DCMAKE_BUILD_TYPE=DEBUG\nninja\nninja check-polygeist-opt \u0026\u0026 ninja check-cgeist\n```\n\nFor faster compilation we recommend using `-DPOLYGEIST_USE_LINKER=lld`.\n\n##### GPU backends\n\nTo enable the CUDA backend add `-DPOLYGEIST_ENABLE_CUDA=1`\n\nTo enable the ROCM backend add `-DPOLYGEIST_ENABLE_ROCM=1`\n\n##### Polymer\n\nTo enable polymer, add `-DPOLYGEIST_ENABLE_POLYMER=1`\n\nThere are two configurations of polymer that can be built - one with Pluto and one with ISL. \n\n###### Pluto\nAdd `-DPOLYGEIST_POLYMER_ENABLE_PLUTO=1`\nThis will cause the cmake invokation to pull and build the dependencies for polymer. To specify a custom directory for the dependencies, specify `-DPOLYMER_DEP_DIR=\u003cabsolute-dir\u003e`. The dependencies will be build using the `tools/polymer/build_polymer_deps.sh`.\n\nTo run the polymer pluto tests, use `ninja check-polymer`.\n\n###### ISL\n\nAdd `-DPOLYGEIST_POLYMER_ENABLE_ISL=1`\nThis requires an `llvm-project` build with `polly` enabled as a subproject.\n\n\n### Option 2: Using unified LLVM, MLIR, Clang, and Polygeist build\n\nPolygeist can also be built as an external LLVM project using [LLVM_EXTERNAL_PROJECTS](https://llvm.org/docs/CMake.html#llvm-related-variables).\n\n1. Build LLVM, MLIR, Clang, and Polygeist:\n```sh\nmkdir build\ncd build\ncmake -G Ninja ../llvm-project/llvm \\\n  -DLLVM_ENABLE_PROJECTS=\"clang;mlir\" \\\n  -DLLVM_EXTERNAL_PROJECTS=\"polygeist\" \\\n  -DLLVM_EXTERNAL_POLYGEIST_SOURCE_DIR=.. \\\n  -DLLVM_TARGETS_TO_BUILD=\"host\" \\\n  -DLLVM_ENABLE_ASSERTIONS=ON \\\n  -DCMAKE_BUILD_TYPE=DEBUG\nninja\nninja check-polygeist-opt \u0026\u0026 ninja check-cgeist\n```\n\n`ninja check-polygeist-opt` runs the tests in `Polygeist/test/polygeist-opt`\n`ninja check-cgeist` runs the tests in `Polygeist/tools/cgeist/Test`\n\n# Citing Polygeist\n\nIf you use Polygeist, please consider citing the relevant publications:\n\n``` bibtex\n@inproceedings{polygeistPACT,\n  title = {Polygeist: Raising C to Polyhedral MLIR},\n  author = {Moses, William S. and Chelini, Lorenzo and Zhao, Ruizhe and Zinenko, Oleksandr},\n  booktitle = {Proceedings of the ACM International Conference on Parallel Architectures and Compilation Techniques},\n  numpages = {12},\n  location = {Virtual Event},\n  series = {PACT '21},\n  publisher = {Association for Computing Machinery},\n  year = {2021},\n  address = {New York, NY, USA},\n  keywords = {Polygeist, MLIR, Polyhedral, LLVM, Compiler, C++, Pluto, Polly, OpenScop, Parallel, OpenMP, Affine, Raising, Transformation, Splitting, Automatic-Parallelization, Reduction, Polybench},\n}\n@inproceedings{10.1145/3572848.3577475,\n  author = {Moses, William S. and Ivanov, Ivan R. and Domke, Jens and Endo, Toshio and Doerfert, Johannes and Zinenko, Oleksandr},\n  title = {High-Performance GPU-to-CPU Transpilation and Optimization via High-Level Parallel Constructs},\n  year = {2023},\n  isbn = {9798400700156},\n  publisher = {Association for Computing Machinery},\n  address = {New York, NY, USA},\n  url = {https://doi.org/10.1145/3572848.3577475},\n  doi = {10.1145/3572848.3577475},\n  booktitle = {Proceedings of the 28th ACM SIGPLAN Annual Symposium on Principles and Practice of Parallel Programming},\n  pages = {119–134},\n  numpages = {16},\n  keywords = {MLIR, polygeist, CUDA, barrier synchronization},\n  location = {Montreal, QC, Canada},\n  series = {PPoPP '23}\n}\n@inproceedings{10444828,\n  author = {Ivanov, Ivan R. and Zinenko, Oleksandr and Domke, Jens and Endo, Toshio and Moses, William S.},\n  booktitle = {2024 IEEE/ACM International Symposium on Code Generation and Optimization (CGO)},\n  title = {Retargeting and Respecializing GPU Workloads for Performance Portability},\n  year = {2024},\n  volume = {},\n  issn = {},\n  pages = {119-132},\n  doi = {10.1109/CGO57630.2024.10444828},\n  url = {https://doi.ieeecomputersociety.org/10.1109/CGO57630.2024.10444828},\n  publisher = {IEEE Computer Society},\n  address = {Los Alamitos, CA, USA},\n  month = {mar}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllvm%2FPolygeist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fllvm%2FPolygeist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fllvm%2FPolygeist/lists"}