Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update benchmarks and enable them #407

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cuda_bindings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Empty file.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand All @@ -47,7 +47,7 @@ def init_cuda():
ASSERT_DRV(err)


@pytest.fixture
@pytest.fixture(scope="function")
def load_module():
module = None

Expand Down
2 changes: 1 addition & 1 deletion cuda_bindings/benchmarks/kernels.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 7 additions & 10 deletions cuda_bindings/benchmarks/test_cupy.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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=()):
Expand Down
7 changes: 3 additions & 4 deletions cuda_bindings/benchmarks/test_launch_latency.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion cuda_bindings/benchmarks/test_numba.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 2 additions & 3 deletions cuda_bindings/benchmarks/test_pointer_attributes.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
Loading