diff --git a/tests/test_benchmark.py b/tests/test_benchmark.py index fe3946be744dab8c3d281bc7cbdb520a3399d05b..a45fcdd6d93e7ce8fc59169658f1b40bdbf55ae6 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)