Skip to content

Commit 2b76b22

Browse files
committed
check for nvidia gpu correctly
1 parent 366f718 commit 2b76b22

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ jobs:
7676
with:
7777
cuda: '12.4.1'
7878
linux-local-args: '["--toolkit"]'
79-
use-local-cache: false
80-
use-github-cache: false
79+
log-file-suffix: "${{ matrix.os }}-${{ matrix.py_version }}.txt"
8180

8281
- name: Install and configure
8382
shell: bash

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)