An open API service indexing awesome lists of open source software.

https://github.com/rocm/rocm-llvm-python

Low-level Cython and Python bindings to the (ROCm) LLVM and AMD COMGR C API. Also ships the official LLVM Clang bindings.
https://github.com/rocm/rocm-llvm-python

ai clang compiler gpu hip hpc jit llvm ml radeon-instinct-mi-series x86

Last synced: about 1 month ago
JSON representation

Low-level Cython and Python bindings to the (ROCm) LLVM and AMD COMGR C API. Also ships the official LLVM Clang bindings.

Awesome Lists containing this project

README

          

# ROCm LLVM Python Source Repository

This repository provides low-level Python and Cython Bindings for ROCm LLVM
and ROCm AMD COMGR.

## Requirements

* Currently, only Linux is supported (prebuilt packages and code).
* Prebuilt packages distributed via PyPI (or Test PyPI) are only provided for
Linux systems that agree with the `manylinux_2_17_x86_64` tag.
* Requires that a compatible ROCm™ HIP SDK is installed on your system.
* Source code is provided only for particular ROCm versions.
* See the git branches tagged with `release/rocm-rel-X.Y[.Z]`
* Prebuilt packages are built only for particular ROCm versions.

> [!NOTE]
> You may find that packages for one ROCm™ release might be compatible
> with the ROCm™ HIP SDK of another release as the ROCm LLVM Python
> functions load HIP C functions in a lazy manner.

## Install Prebuilt Package(s)

> [!NOTE]
> Prebuilt packages for some ROCm releases are published to Test PyPI first.
> Check the `simple` lists to see if your operating system and Python version
> is supported: [rocm-llvm-python](https://test.pypi.org/simple/rocm-llvm-python/).

---

> [!WARNING]
> Currently, we have not uploaded any ROCm LLVM Python to PyPI yet. So far
> we have only uploaded packages to TestPyPI, mainly intended for internal
> testing purposes. If you find similar named packages on PyPI they may been
> provided by others, possibly with malicious intent.

---

> [!IMPORTANT]
> Ensure that `pip` has at least version `24.0`, please upgrade it otherwise.

### Via TestPyPI

First identify the first two or three digits of the version number of your
ROCm™ installation. Then install the ROCm LLVM Python package(s) as
follows:

```shell
python3 -m pip install -i https://test.pypi.org/simple rocm-llvm-python~=$rocm_version
```

### Via Wheel in Local Filesystem

If you have ROCm LLVM Python package wheels somewhere in your filesystem, you can
also run:

```shell
python3 -m pip install .whl
```

> [!NOTE]
> See the ROCm LLVM Python user guide for more details:
>

## Build From Source

> [!NOTE]
> The `main` branch is used for tracking updates to the docs, examples and CI scripts.
> The source code can be found on the release branches `release/rocm-rel-X.Y[.Z]`.

1. Install ROCM
2. Install `pip`, virtual environment and development headers for Python 3:

```bash
# Ubuntu:
sudo apt install python3-pip python3-venv python3-dev
```

3. Check out the feature branch `release/rocm-rel-X.Y[.Z]` for your particular
ROCm™ installation:
4. Finally run:

```bash
./build.sh --post-clean
```

> [!NOTE]
> See the ROCm LLVM Python developer guide for more details:
>

### Build Options

```text
Usage: ./build.sh [OPTIONS]

Options:
--rocm-path Path to a ROCm installation, defaults to variable 'ROCM_PATH' if set or '/opt/rocm'.
--libs Libraries to build as comma separated list without whitespaces, defaults to variable 'ROCM_LLVM_PYTHON_LIBS' if set or '*'.
Add a prefix '^' to NOT build the comma-separated list of libraries that follows but all other libraries.
--no-build Do not build package 'rocm-llvm-python'.
--no-docs Do not build the docs of package 'rocm-llvm-python'.
--no-build-librocmllvm Do not build the librocmllvm shared object.
--no-api-docs Temporarily move the 'rocm-llvm-python/docs/python_api' subfolder so that sphinx does not see it.
--no-clean-docs Do not generate docs from scratch, i.e. don't run sphinx with -E switch.
--run-tests Run the tests.
--no-archive Do not put previously created packages into the archive folder.
-j,--num-jobs Number of build jobs to use. Defaults to 1.
--pre-clean Remove the virtual Python environment subfolder '_venv' --- if it exists --- before all other tasks.
--post-clean Remove the virtual Python environment subfolder '_venv' --- if it exists --- after all other tasks.
-n, --no-venv Do not create and use a virtual Python environment.
-h, --help Show this help message.
```

> [!NOTE]
> See the ROCm LLVM Python developer guide for more details:
>

## Documentation

> [!NOTE]
> Documentation pages have not been published yet.

For examples, guides and API reference, please take a
look at the official ROCm LLVM Python documentation pages: