Skip to content

Commit d57288e

Browse files
authored
fix gpu (#95)
1 parent 660dd12 commit d57288e

File tree

3 files changed

+43
-12
lines changed

3 files changed

+43
-12
lines changed

.github/workflows/test.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,25 @@ jobs:
5959
python-version: ${{ matrix.py_version }}
6060
allow-prereleases: true
6161

62+
- name: Free disk space
63+
if: contains(matrix.os, 'ubuntu')
64+
uses: descriptinc/free-disk-space@main
65+
with:
66+
tool-cache: true
67+
android: true
68+
dotnet: true
69+
haskell: true
70+
large-packages: true
71+
swap-storage: false # This frees space on the wrong partition.
72+
73+
- uses: Jimver/[email protected]
74+
if: contains(matrix.os, 'ubuntu')
75+
id: cuda-toolkit
76+
with:
77+
cuda: '12.4.1'
78+
linux-local-args: '["--toolkit"]'
79+
log-file-suffix: "${{ matrix.os }}-${{ matrix.py_version }}.txt"
80+
6281
- name: Install and configure
6382
shell: bash
6483
run: |

mlir/extras/dialects/ext/gpu.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,18 @@ def __init__(
166166
if isinstance(t, str):
167167
targets[i] = Attribute.parse(t)
168168
_ods_context = get_default_loc_context(loc)
169-
super().__init__(targets=ArrayAttr.get(targets), loc=loc, ip=ip)
170-
self.regions[0].blocks.append()
171-
self.operation.attributes["sym_name"] = (
169+
sym_name = (
172170
sym_name
173171
if (
174172
issubclass(type(sym_name), Attribute)
175173
or not AttrBuilder.contains("SymbolNameAttr")
176174
)
177175
else AttrBuilder.get("SymbolNameAttr")(sym_name, context=_ods_context)
178176
)
177+
super().__init__(
178+
sym_name=sym_name, targets=ArrayAttr.get(targets), loc=loc, ip=ip
179+
)
180+
self.regions[0].blocks.append()
179181

180182
@property
181183
def body(self):

tests/test_nvgpu_nvvm.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import re
2+
import subprocess
23
from pathlib import Path
34
from textwrap import dedent
45

@@ -8,28 +9,28 @@
89
from mlir.dialects.memref import cast
910
from mlir.dialects.nvgpu import (
1011
TensorMapDescriptorType,
11-
TensorMapSwizzleKind,
12+
TensorMapInterleaveKind,
1213
TensorMapL2PromoKind,
1314
TensorMapOOBKind,
14-
TensorMapInterleaveKind,
15+
TensorMapSwizzleKind,
16+
tma_create_descriptor,
1517
)
16-
from mlir.dialects.nvgpu import tma_create_descriptor
1718
from mlir.dialects.transform import any_op_t
1819
from mlir.dialects.transform.extras import named_sequence
1920
from mlir.dialects.transform.structured import MatchInterfaceEnum
2021
from mlir.ir import StringAttr, UnitAttr
2122

2223
from mlir import _mlir_libs
2324
from mlir.extras.ast.canonicalize import canonicalize
24-
from mlir.extras.dialects.ext import arith, memref, scf, gpu, linalg, transform, nvgpu
25+
from mlir.extras.dialects.ext import arith, gpu, linalg, memref, nvgpu, scf, transform
2526
from mlir.extras.dialects.ext.func import func
2627
from mlir.extras.dialects.ext.gpu import smem_space
2728
from mlir.extras.dialects.ext.llvm import llvm_ptr_t
28-
from mlir.extras.runtime.passes import run_pipeline, Pipeline
29+
from mlir.extras.runtime.passes import Pipeline, run_pipeline
2930
from mlir.extras.runtime.refbackend import LLVMJITBackend
3031

3132
# noinspection PyUnresolvedReferences
32-
from mlir.extras.testing import mlir_ctx as ctx, filecheck, MLIRContext
33+
from mlir.extras.testing import MLIRContext, filecheck, mlir_ctx as ctx
3334
from mlir.extras.util import find_ops
3435

3536
# needed since the fix isn't defined here nor conftest.py
@@ -200,7 +201,8 @@ def payload():
200201
compute_linspace_val.emit()
201202

202203
@func
203-
def printMemrefF32(x: T.memref(T.f32())): ...
204+
def printMemrefF32(x: T.memref(T.f32())):
205+
...
204206

205207
printMemrefF32_.append(printMemrefF32)
206208

@@ -421,8 +423,15 @@ def main(module: any_op_t()):
421423
CUDA_RUNTIME_LIB_PATH = Path(_mlir_libs.__file__).parent / f"libmlir_cuda_runtime.so"
422424

423425

426+
NVIDIA_GPU = False
427+
try:
428+
subprocess.check_output("nvidia-smi")
429+
NVIDIA_GPU = True
430+
except Exception:
431+
print("No Nvidia GPU in system!")
432+
424433
# based on https://github.com/llvm/llvm-project/blob/9cc2122bf5a81f7063c2a32b2cb78c8d615578a1/mlir/test/Integration/GPU/CUDA/TensorCore/sm80/transform-mma-sync-matmul-f16-f16-accum.mlir#L6
425-
@pytest.mark.skipif(not CUDA_RUNTIME_LIB_PATH.exists(), reason="no cuda library")
434+
@pytest.mark.skipif(not NVIDIA_GPU, reason="no cuda library")
426435
def test_transform_mma_sync_matmul_f16_f16_accum_run(ctx: MLIRContext, capfd):
427436
range_ = scf.range_
428437

@@ -549,7 +558,8 @@ def payload():
549558
compute_linspace_val.emit()
550559

551560
@func
552-
def printMemrefF32(x: T.memref(T.f32())): ...
561+
def printMemrefF32(x: T.memref(T.f32())):
562+
...
553563

554564
printMemrefF32_.append(printMemrefF32)
555565

0 commit comments

Comments
 (0)