Skip to content

Commit

Permalink
add all the things
Browse files Browse the repository at this point in the history
  • Loading branch information
superlopuh committed Jan 9, 2025
1 parent b58a183 commit b7a57f2
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 7 deletions.
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
# Add assignees
assignees:
- "superlopuh"
commit-message:
prefix: "pip prod"
prefix-development: "pip dev"
include: "scope"
52 changes: 52 additions & 0 deletions .github/workflows/ci-wgpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This workflow will install MLIR, Python dependencies, run tests and lint with a single version of Python

name: CI - MLIR-based Testing

on:
# Trigger the workflow on push or pull request,
# but only for the main branch
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']

env:
LLVM_SYMBOLIZER_PATH: /usr/lib/llvm-11/bin/llvm-symbolizer
MLIR-Version: d401987fe349a87c53fe25829215b080b70c0c1a
steps:
- uses: actions/checkout@v4
with:
path: xdsl
fetch-depth: 2

- name: Install native dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: mesa-vulkan-drivers
version: 1.0

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
cache-dependency-glob: "xdsl/uv.lock"

- name: Set up Python ${{ matrix.python-version }}
run: |
# Change directory so that xdsl-opt can be found during installation.
cd xdsl
uv python install ${{ matrix.python-version }}
- name: Install the package locally and nbval
run: uv sync

- name: Execute lit tests
run: uv run lit -v tests/filecheck/
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,11 @@ cython_debug/

# PyPI configuration file
.pypirc

# lit tests results
**/.lit_test_times.txt
tests/**/Output/*
*.out

# Mac
.DS_Store
6 changes: 0 additions & 6 deletions hello.py

This file was deleted.

6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ dependencies = [

[dependency-groups]
dev = ["xdsl[dev]"]

[project.scripts]
xdsl-webgpu-run = "xdsl_webgpu.tools.xdsl_webgpu_run:main"

[tool.uv]
package = true
48 changes: 48 additions & 0 deletions tests/filecheck/global_id_inc.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// RUN: xdsl-webgpu-run --index-bitwidth=32 %s | filecheck %s

builtin.module attributes {gpu.container_module} {
"gpu.module"() ({
"gpu.func"() ({
^0(%arg : memref<4x4xindex>):
%0 = "arith.constant"() {"value" = 2 : index} : () -> index
%1 = "gpu.global_id"() {"dimension" = #gpu<dim x>} : () -> index
%2 = "gpu.global_id"() {"dimension" = #gpu<dim y>} : () -> index
%3 = "arith.constant"() {"value" = 4 : index} : () -> index
%4 = "arith.muli"(%1, %3) : (index, index) -> index
%5 = "arith.addi"(%4, %2) : (index, index) -> index
"memref.store"(%5, %arg, %1, %2) {"nontemporal" = false} : (index, memref<4x4xindex>, index, index) -> ()
"gpu.return"() : () -> ()
}) {"function_type" = (memref<4x4xindex>) -> (),
"gpu.kernel",
"sym_name" = "fill"
} : () -> ()
"gpu.func"() ({
^0(%arg : memref<4x4xindex>):
%0 = "arith.constant"() {"value" = 1 : index} : () -> index
%1 = "gpu.global_id"() {"dimension" = #gpu<dim x>} : () -> index
%2 = "gpu.global_id"() {"dimension" = #gpu<dim y>} : () -> index
%3 = "memref.load"(%arg, %1, %2) {"nontemporal" = false} : (memref<4x4xindex>, index, index) -> (index)
%4 = "arith.addi"(%3, %0) : (index, index) -> index
"memref.store"(%4, %arg, %1, %2) {"nontemporal" = false} : (index, memref<4x4xindex>, index, index) -> ()
"gpu.return"() : () -> ()
}) {"function_type" = (memref<4x4xindex>) -> (),
"gpu.kernel",
"sym_name" = "inc"
} : () -> ()
"gpu.module_end"() : () -> ()
}) {"sym_name" = "gpu"} : () -> ()
func.func @main() -> index {
%four = "arith.constant"() {"value" = 4 : index} : () -> index
%one = "arith.constant"() {"value" = 1 : index} : () -> index
%memref = "gpu.alloc"() {"alignment" = 0 : i64, "operandSegmentSizes" = array<i32: 0, 0, 0>} : () -> memref<4x4xindex>
"gpu.launch_func"(%four, %four, %one, %one, %one, %one, %memref) {"operandSegmentSizes" = array<i32: 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0>, "kernel" = @gpu::@fill} : (index, index, index, index, index, index, memref<4x4xindex>) -> ()
"gpu.launch_func"(%four, %four, %one, %one, %one, %one, %memref) {"operandSegmentSizes" = array<i32: 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0>, "kernel" = @gpu::@inc} : (index, index, index, index, index, index, memref<4x4xindex>) -> ()
%hmemref = "memref.alloc"() {"alignment" = 0 : i64, "operandSegmentSizes" = array<i32: 0, 0>} : () -> memref<4x4xindex>
"gpu.memcpy"(%hmemref, %memref) {"operandSegmentSizes" = array<i32: 0, 1, 1>} : (memref<4x4xindex>, memref<4x4xindex>) -> ()
printf.print_format "Result : {}", %hmemref : memref<4x4xindex>
%zero = "arith.constant"() {"value" = 0 : index} : () -> (index)
"func.return"(%zero) : (index) -> ()
}
}

// CHECK-NEXT{LITERAL}: Result : [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]
23 changes: 23 additions & 0 deletions tests/filecheck/lit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import lit.formats
import os

config.test_source_root = os.path.dirname(__file__)
xdsl_webgpu_src = os.path.dirname(os.path.dirname(config.test_source_root))

config.name = "xDSL WebGPU"
config.test_format = lit.formats.ShTest(preamble_commands=[f"cd {xdsl_webgpu_src}"])
config.suffixes = ['.mlir']

# checking if maxIndividualTestTime is available on the platform and sets
# it to 20sec if so, declares lit-max-individual-test-time feature for
# further checking by tests.
supported, errormsg = lit_config.maxIndividualTestTimeIsSupported
if supported:
config.available_features.add("lit-max-individual-test-time")
lit_config.maxIndividualTestTime = 20
else:
lit_config.warning(
"Setting a timeout per test not supported. "
+ errormsg
+ " Some tests will be skipped."
)
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions xdsl_webgpu/tools/xdsl_webgpu_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python3

from xdsl.interpreter import Interpreter
from xdsl.tools.xdsl_run import xDSLRunMain

from xdsl_webgpu.interpreters.wgpu import WGPUFunctions


class xDSLWebGPURunMain(xDSLRunMain):
def register_implementations(self, interpreter: Interpreter):
super().register_implementations(interpreter)
interpreter.register_implementations(WGPUFunctions())


def main():
return xDSLWebGPURunMain().run()


if __name__ == "__main__":
main()

0 comments on commit b7a57f2

Please sign in to comment.