{"id":19416837,"url":"https://github.com/acceleratehs/accelerate-llvm","last_synced_at":"2025-04-07T10:26:54.284Z","repository":{"id":14334789,"uuid":"17044339","full_name":"AccelerateHS/accelerate-llvm","owner":"AccelerateHS","description":"LLVM backend for Accelerate","archived":false,"fork":false,"pushed_at":"2024-09-14T18:47:42.000Z","size":3847,"stargazers_count":164,"open_issues_count":15,"forks_count":54,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-03-31T07:08:19.126Z","etag":null,"topics":["accelerate","compiler","cuda","gpu","gpu-computing","hacktoberfest","haskell","llvm","parallel-computing"],"latest_commit_sha":null,"homepage":"http://www.acceleratehs.org","language":"Haskell","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/AccelerateHS.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":"2014-02-21T03:26:03.000Z","updated_at":"2025-03-05T06:36:04.000Z","dependencies_parsed_at":"2024-09-15T04:22:28.709Z","dependency_job_id":null,"html_url":"https://github.com/AccelerateHS/accelerate-llvm","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AccelerateHS%2Faccelerate-llvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AccelerateHS%2Faccelerate-llvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AccelerateHS%2Faccelerate-llvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AccelerateHS%2Faccelerate-llvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AccelerateHS","download_url":"https://codeload.github.com/AccelerateHS/accelerate-llvm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247634329,"owners_count":20970510,"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":["accelerate","compiler","cuda","gpu","gpu-computing","hacktoberfest","haskell","llvm","parallel-computing"],"created_at":"2024-11-10T13:05:46.276Z","updated_at":"2025-04-07T10:26:54.255Z","avatar_url":"https://github.com/AccelerateHS.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\u003cimg width=\"450\" src=\"https://github.com/AccelerateHS/accelerate/raw/master/images/accelerate-logo-text-v.png?raw=true\" alt=\"henlo, my name is Theia\"/\u003e\n\n# LLVM backends for the Accelerate array language\n\n[![CI](https://github.com/tmcdonell/accelerate-llvm/actions/workflows/ci.yml/badge.svg)](https://github.com/tmcdonell/accelerate-llvm/actions/workflows/ci.yml)\n[![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/AccelerateHS/Lobby)\n[![Hackage](https://img.shields.io/hackage/v/accelerate-llvm.svg)](https://hackage.haskell.org/package/accelerate-llvm)\n[![Docker Automated build](https://img.shields.io/docker/automated/tmcdonell/accelerate-llvm.svg)](https://hub.docker.com/r/tmcdonell/accelerate-llvm/)\n[![Docker status](https://images.microbadger.com/badges/image/tmcdonell/accelerate-llvm.svg)](https://microbadger.com/images/tmcdonell/accelerate-llvm)\n\n\u003c/div\u003e\n\nThis package compiles Accelerate code to LLVM IR, and executes that code on\nmulticore CPUs as well as NVIDIA GPUs. This avoids the need to go through `nvcc`\nor `clang`. For details on Accelerate, refer to the [main repository][GitHub].\n\nWe love all kinds of contributions, so feel free to open issues for missing\nfeatures as well as report (or fix!) bugs on the [issue tracker][Issues].\n\n  [GitHub]:  https://github.com/AccelerateHS/accelerate\n  [Issues]:  https://github.com/AccelerateHS/accelerate/issues\n\n\n * [Dependencies](#dependencies)\n * [Docker](#docker)\n * [Installing LLVM](#installing-llvm)\n   * [Homebrew](#homebrew)\n   * [Debian/Ubuntu](#debianubuntu)\n   * [Building from source](#building-from-source)\n * [Installing Accelerate-LLVM](#installing-accelerate-llvm)\n   * [libNVVM](#libNVVM)\n\n\nDependencies\n------------\n\nHaskell dependencies are available from Hackage, but there are several external\nlibrary dependencies that you will need to install as well:\n\n * [`LLVM`](http://llvm.org)\n * [`libFFI`](http://sourceware.org/libffi/) (if using the `accelerate-llvm-native` backend for multicore CPUs)\n * [`CUDA`](https://developer.nvidia.com/cuda-downloads) (if using the `accelerate-llvm-ptx` backend for NVIDIA GPUs)\n    [`Note that not all versions of CUDA support all NVIDIA GPUs`](https://en.wikipedia.org/wiki/CUDA#GPUs_supported)\n\nDocker\n------\n\nA [docker](https://www.docker.com) container is provided with this package\npreinstalled (via stack) at `/opt/accelerate-llvm`. Note that if you wish to use\nthe `accelerate-llvm-ptx` GPU backend, you will need to install the [NVIDIA\ndocker](https://github.com/NVIDIA/nvidia-docker) plugin; see that page for more\ninformation.\n\n```sh\n$ docker run -it tmcdonell/accelerate-llvm\n```\n\n\nInstalling LLVM\n---------------\n\nWhen installing LLVM, make sure that it includes the `libLLVM` shared library.\nIf you want to use the GPU targeting `accelerate-llvm-ptx` backend, make sure\nyou install (or build) LLVM with the 'nvptx' target.\n\n## Homebrew\n\nExample using [Homebrew](http://brew.sh) on macOS:\n\n```sh\n$ brew install llvm@15\n```\n\n## Debian/Ubuntu\n\nFor Debian/Ubuntu based Linux distributions, the LLVM.org website provides\nbinary distribution packages. Check [apt.llvm.org](http://apt.llvm.org) for\ninstructions for adding the correct package database for your OS version, and\nthen:\n\n```sh\n$ apt-get install llvm-15-dev\n```\n\n## Building from source\n\nIf your OS does not have an appropriate LLVM distribution available, you can also build from source. Detailed build instructions are available on the [LLVM.org website](http://releases.llvm.org/6.0.0/docs/CMake.html). Note that you will require at least [CMake 3.4.3](http://www.cmake.org/cmake/resources/software.html) and a recent C++ compiler; at least Clang 3.1, GCC 4.8, or Visual Studio 2015 (update 3).\n\n  1. Download and unpack the [LLVM source code](https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/llvm-15.0.7.src.tar.xz). We'll refer to\n     the path that the source tree was unpacked to as `LLVM_SRC`. Only the main\n     LLVM source tree is required, but you can optionally add other components\n     such as the Clang compiler or Polly loop optimiser. See the [LLVM releases](https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.7)\n     page for the complete list.\n\n  2. Create a temporary build directory and `cd` into it, for example:\n     ```sh\n     $ mkdir /tmp/build\n     $ cd /tmp/build\n     ```\n\n  3. Execute the following to configure the build. Here `INSTALL_PREFIX` is\n     where LLVM is to be installed, for example `/usr/local` or\n     `$HOME/opt/llvm`:\n     ```sh\n     $ cmake $LLVM_SRC -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_BUILD_LLVM_DYLIB=ON -DLLVM_LINK_LLVM_DYLIB=ON\n     ```\n     See [options and variables](http://llvm.org/docs/CMake.html#options-and-variables)\n     for a list of additional build parameters you can specify.\n\n  4. Build and install:\n     ```sh\n     $ cmake --build .\n     $ cmake --build . --target install\n     ```\n\n  5. For macOS only, some additional steps are useful to work around issues related\n     to [System Integrity Protection](https://en.wikipedia.org/wiki/System_Integrity_Protection):\n     ```sh\n     cd $INSTALL_PREFIX/lib\n     ln -s libLLVM.dylib libLLVM-15.dylib\n     install_name_tool -id $PWD/libLTO.dylib libLTO.dylib\n     install_name_tool -id $PWD/libLLVM.dylib libLLVM.dylib\n     install_name_tool -change '@rpath/libLLVM.dylib' $PWD/libLLVM.dylib libLTO.dylib\n     ```\n\n\nInstalling Accelerate-LLVM\n--------------------------\n\nOnce the dependencies are installed, we are ready to install `accelerate-llvm`.\n\nFor example, installation using [`stack`](http://docs.haskellstack.org/en/stable/README.html)\njust requires you to point it to the appropriate configuration file:\n```sh\n$ stack setup\n$ stack install\n```\n\nNote that the version of [`llvm-hs`](https://hackage.haskell.org/package/llvm-hs)\nused must match the installed version of LLVM, which is currently 15.\n\n\n## libNVVM\n\nThe `accelerate-llvm-ptx` backend can optionally be compiled to generate GPU\ncode using the `libNVVM` library, rather than LLVM's inbuilt NVPTX code\ngenerator. `libNVVM` is a closed-source library distributed as part of the\nNVIDIA CUDA toolkit, and is what the `nvcc` compiler itself uses internally when\ncompiling CUDA C code.\n\nUsing `libNVVM` _may_ improve GPU performance compared to the code generator\nbuilt in to LLVM. One difficulty with using it however is that since `libNVVM`\nis also based on LLVM, and typically lags LLVM by several releases, you must\ninstall `accelerate-llvm` with a \"compatible\" version of LLVM, which will depend\non the version of the CUDA toolkit you have installed. The following table shows\ncombinations which have been tested:\n\n|               | LLVM-3.3 | LLVM-3.4 | LLVM-3.5 | LLVM-3.8 | LLVM-3.9 | LLVM-4.0 | LLVM-5.0 | LLVM-6.0 | LLVM-7 | LLVM-8 | LLVM-9 |\n| ------------- | :------: | :------: | :------: | :------: | :------: | :------: | :------: | :------: | :----: | :----: | :----: |\n| **CUDA-7.0**  | ⭕       | ❌       |          |          |          |          |          |          |        |        |        |\n| **CUDA-7.5**  |          | ⭕       | ⭕       | ❌       |          |          |          |          |        |        |        |\n| **CUDA-8.0**  |          |          | ⭕       | ⭕       | ❌       | ❌       |          |          |        |        |        |\n| **CUDA-9.0**  |          |          |          |          |          | ❌       | ❌       |          |        |        |        |\n| **CUDA-9.1**  |          |          |          |          |          |          |          |          |        |        |        |\n| **CUDA-9.2**  |          |          |          |          |          |          |          |          |        |        |        |\n| **CUDA-10.0** |          |          |          |          |          |          |          |          |        |        |        |\n| **CUDA-10.1** |          |          |          |          |          |          |          |          |        |        |        |\n\nWhere ⭕ = Works, and ❌ = Does not work.\n\nThe above table is incomplete! If you try a particular combination and find that\nit does or does not work, please let us know!\n\nNote that the above restrictions on CUDA and LLVM version exist _only_ if you\nwant to use the NVVM component. Otherwise, you should be free to use any\ncombination of CUDA and LLVM.\n\nAlso note that `accelerate-llvm-ptx` itself currently requires at least LLVM-4.0.\n\nUsing `stack`, either edit the `stack.yaml` and add the following section:\n\n```yaml\nflags:\n  accelerate-llvm-ptx:\n    nvvm: true\n```\n\nOr install using the following option on the command line:\n\n```sh\n$ stack install accelerate-llvm-ptx --flag accelerate-llvm-ptx:nvvm\n```\n\nIf installing via `cabal`:\n\n```sh\n$ cabal install accelerate-llvm-ptx -fnvvm\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facceleratehs%2Faccelerate-llvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facceleratehs%2Faccelerate-llvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facceleratehs%2Faccelerate-llvm/lists"}