diff --git a/cuda_bindings/README.md b/cuda_bindings/README.md index 3ece5667..57e7c2b0 100644 --- a/cuda_bindings/README.md +++ b/cuda_bindings/README.md @@ -105,10 +105,10 @@ To run these samples: * `python -m pytest tests/cython/` against editable installations * `pytest tests/cython/` against installed packages -### Benchmark (WIP) +### Benchmark -Benchmarks were used for performance analysis during initial release of CUDA Python. Today they need to be updated the 12.x toolkit and are work in progress. +Allows for analyzing binding performance using plugin [pytest-benchmark](https://github.com/ionelmc/pytest-benchmark). -The intended way to run these benchmarks was: -* `python -m pytest --benchmark-only benchmark/` against editable installations -* `pytest --benchmark-only benchmark/` against installed packages +To run these benchmarks: +* `python -m pytest --benchmark-only benchmarks/` against editable installations +* `pytest --benchmark-only benchmarks/` against installed packages diff --git a/cuda_bindings/benchmarks/__init__.py b/cuda_bindings/benchmarks/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/cuda_bindings/benchmarks/perf_test_utils.py b/cuda_bindings/benchmarks/conftest.py similarity index 95% rename from cuda_bindings/benchmarks/perf_test_utils.py rename to cuda_bindings/benchmarks/conftest.py index 7cfcf9f9..e1d72d26 100644 --- a/cuda_bindings/benchmarks/perf_test_utils.py +++ b/cuda_bindings/benchmarks/conftest.py @@ -1,4 +1,4 @@ -# Copyright 2021-2024 NVIDIA Corporation. All rights reserved. +# Copyright 2021-2025 NVIDIA Corporation. All rights reserved. # # Please refer to the NVIDIA end user license agreement (EULA) associated # with this source code for terms and conditions that govern your use of @@ -25,7 +25,7 @@ def ASSERT_DRV(err): raise RuntimeError(f"Unknown error type: {err}") -@pytest.fixture +@pytest.fixture(scope="function") def init_cuda(): # Initialize (err,) = cuda.cuInit(0) @@ -47,7 +47,7 @@ def init_cuda(): ASSERT_DRV(err) -@pytest.fixture +@pytest.fixture(scope="function") def load_module(): module = None diff --git a/cuda_bindings/benchmarks/kernels.py b/cuda_bindings/benchmarks/kernels.py index 259c6e3c..119727b2 100644 --- a/cuda_bindings/benchmarks/kernels.py +++ b/cuda_bindings/benchmarks/kernels.py @@ -1,4 +1,4 @@ -# Copyright 2021-2024 NVIDIA Corporation. All rights reserved. +# Copyright 2021-2025 NVIDIA Corporation. All rights reserved. # # Please refer to the NVIDIA end user license agreement (EULA) associated # with this source code for terms and conditions that govern your use of diff --git a/cuda_bindings/benchmarks/test_cupy.py b/cuda_bindings/benchmarks/test_cupy.py index 6e847853..68fdd983 100644 --- a/cuda_bindings/benchmarks/test_cupy.py +++ b/cuda_bindings/benchmarks/test_cupy.py @@ -1,4 +1,4 @@ -# Copyright 2021-2024 NVIDIA Corporation. All rights reserved. +# Copyright 2021-2025 NVIDIA Corporation. All rights reserved. # # Please refer to the NVIDIA end user license agreement (EULA) associated # with this source code for terms and conditions that govern your use of @@ -9,17 +9,14 @@ import pytest -# Always skip since cupy is not CTK 12.x yet -skip_tests = True -if not skip_tests: - try: - import cupy +try: + import cupy - skip_tests = False - except ImportError: - skip_tests = True + skip_tests = False +except ImportError: + skip_tests = True -from .kernels import kernel_string +from kernels import kernel_string def launch(kernel, args=()): diff --git a/cuda_bindings/benchmarks/test_launch_latency.py b/cuda_bindings/benchmarks/test_launch_latency.py index f16e971a..7af5f84c 100755 --- a/cuda_bindings/benchmarks/test_launch_latency.py +++ b/cuda_bindings/benchmarks/test_launch_latency.py @@ -1,4 +1,4 @@ -# Copyright 2021-2024 NVIDIA Corporation. All rights reserved. +# Copyright 2021-2025 NVIDIA Corporation. All rights reserved. # # Please refer to the NVIDIA end user license agreement (EULA) associated # with this source code for terms and conditions that govern your use of @@ -8,12 +8,11 @@ import ctypes import pytest +from conftest import ASSERT_DRV +from kernels import kernel_string from cuda import cuda -from .kernels import kernel_string -from .perf_test_utils import ASSERT_DRV - def launch(kernel, stream, args=(), arg_types=()): cuda.cuLaunchKernel( diff --git a/cuda_bindings/benchmarks/test_numba.py b/cuda_bindings/benchmarks/test_numba.py index f7a4db7e..36361d35 100644 --- a/cuda_bindings/benchmarks/test_numba.py +++ b/cuda_bindings/benchmarks/test_numba.py @@ -1,4 +1,4 @@ -# Copyright 2021-2024 NVIDIA Corporation. All rights reserved. +# Copyright 2021-2025 NVIDIA Corporation. All rights reserved. # # Please refer to the NVIDIA end user license agreement (EULA) associated # with this source code for terms and conditions that govern your use of diff --git a/cuda_bindings/benchmarks/test_pointer_attributes.py b/cuda_bindings/benchmarks/test_pointer_attributes.py index f03be1e1..5c9dbc2b 100644 --- a/cuda_bindings/benchmarks/test_pointer_attributes.py +++ b/cuda_bindings/benchmarks/test_pointer_attributes.py @@ -1,4 +1,4 @@ -# Copyright 2021-2024 NVIDIA Corporation. All rights reserved. +# Copyright 2021-2025 NVIDIA Corporation. All rights reserved. # # Please refer to the NVIDIA end user license agreement (EULA) associated # with this source code for terms and conditions that govern your use of @@ -8,11 +8,10 @@ import random import pytest +from conftest import ASSERT_DRV from cuda import cuda -from .perf_test_utils import ASSERT_DRV - random.seed(0) idx = 0