Skip to content

Commit

Permalink
Update benchmarks and enable them
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhurba01 committed Jan 16, 2025
1 parent 4aa2874 commit 0e2e5f0
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 27 deletions.
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

0 comments on commit 0e2e5f0

Please sign in to comment.