Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
- name: Run lit-enabled examples as tests
run: |
export FILECHECK=FileCheck-18 # Ubuntu's llvm-dev appends a version number.
uv run lit python/examples # Makes sure to substitute FileCheck for $FILECHECK
uv run lit python/examples --verbose # Makes sure to substitute FileCheck for $FILECHECK
84 changes: 84 additions & 0 deletions python/examples/xegpu_matmul/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# XeGPU matrix multiplication benchmark

## Installation

### 1. GPU Drivers and Level Zero

Install Intel GPU drivers and Level Zero runtime on your system.

### 2. Compile LLVM with Intel GPU support

To use Lighthouse with Intel GPUs, LLVM must be built with LevelZero runtime.

Set up a Python environment and install Python packages:

```bash
pip install pybind11 nanobind PyYAML numpy
```

Set `LLVM_INSTALL_DIR` and use the below script to checkout and compile LLVM locally.

```bash
export LLVM_INSTALL_DIR=<...>
LLVM_VERSION=83765f435d1c
git checkout https://github.com/llvm/llvm-project.git -b $LLVM_VERSION

cd llvm-project
mkdir -p build
cd build

cmake ../llvm -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_BUILD_EXAMPLES=OFF \
-DLLVM_TARGETS_TO_BUILD="host" \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="SPIRV" \
-DLLVM_INSTALL_GTEST=ON \
-DMLIR_ENABLE_LEVELZERO_RUNNER=1 \
-DMLIR_ENABLE_BINDINGS_PYTHON=1 \
-DPython3_EXECUTABLE=$(which python3) \
-DLLVM_INSTALL_UTILS=ON \
-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
cmake --build .
cmake --install .
```

If cmake cannot find LevelZero, set environment variable `LEVEL_ZERO_DIR=<path-to-level-zero-install-root>`.

### Install Lighthouse

Install Lighthouse as instructed in the main [README](../../../README.md).

Override the default LLVM package by setting `PYTHONPATH` to the local LLVM Python bindings:

```bash
export PYTHONPATH=${LLVM_INSTALL_DIR}/python_packages/mlir_core
```

## Usage

Run the default 4k (float16, float16) -> float32 matrix multiplication benchmark with correctness test:

```bash
python matmul.py --check-result
```

Set different M, N, K problem size

```bash
python matmul.py --sizes 1024 2048 4096 ...
```

Run with ReLU post-op:

```bash
python matmul.py --relu ...
```

See all command line arguments:

```bash
python matmul.py --help
```
1 change: 1 addition & 0 deletions python/examples/xegpu_matmul/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
config.excludes = ["mlir_utils.py", "payload.py", "runner.py", "schedule.py"]
Loading