From 1e542f17ab15c0551438a1a73535f3530b2dc16e Mon Sep 17 00:00:00 2001
From: Christoph Alt <christoph.alt@fau.de>
Date: Tue, 15 Aug 2023 13:49:45 +0200
Subject: [PATCH] Skipping compiling and running cuda kernels if cuda or gpu is
 not available

---
 tests/test_benchmark.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/tests/test_benchmark.py b/tests/test_benchmark.py
index fe3946b..a45fcdd 100755
--- a/tests/test_benchmark.py
+++ b/tests/test_benchmark.py
@@ -18,6 +18,14 @@ config_kwargs = ({},
                                          'assume_aligned': True}})
 
 
+def nvidia_gpu_available():
+    return subprocess.call(['nvidia-smi']) == 0
+
+
+def nvcc_available():
+    return subprocess.call(['nvcc', '--version']) == 0
+
+
 @pytest.mark.parametrize('compiler', compilers)
 @pytest.mark.parametrize('config_kwarg', config_kwargs)
 def test_generate(compiler, config_kwarg):
@@ -63,5 +71,9 @@ def test_generate_gpu(kwargs):
     with tempfile.TemporaryDirectory(dir=Path.cwd()) as temp_dir:
         temp_dir = Path(temp_dir)
         pb.gpu.generate_benchmark([kernel_vadd, kernel_daxpy], temp_dir, compiler=compiler, **kwargs)
+        if not nvcc_available():
+            return
         subprocess.run(['make', '-C', f'{temp_dir}'], check=True)
+        if not nvidia_gpu_available():
+            return
         subprocess.run([f'{temp_dir}/benchmark-{compiler.name}', '10'], check=True)
-- 
GitLab