Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ repos:
rev: "3e8a8703264a2f4a69428a0aa4dcb512790b2c8c" # frozen: v6.0.0
hooks:
- id: check-added-large-files
exclude: cuda_bindings/cuda/bindings/nvml.pyx
exclude: cuda_bindings/cuda/bindings/nvml.pyx|cuda_bindings/cuda/bindings/_v2/driver.pyx
- id: check-case-conflict
- id: check-docstring-first
- id: check-merge-conflict
Expand Down
8 changes: 5 additions & 3 deletions cuda_bindings/cuda/bindings/_example_helpers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import numpy as np

from cuda import pathfinder
from cuda.bindings import driver as cuda
from cuda.bindings import runtime as cudart
from cuda.bindings._v2 import driver as cuda
from cuda.bindings._v2 import nvrtc

from .helper_cuda import check_cuda_errors
Expand Down Expand Up @@ -84,7 +84,9 @@ def __init__(self, code, dev_id):
else:
data = nvrtc.get_ptx(prog)

self.module = check_cuda_errors(cuda.cuModuleLoadData(np.char.array(data)))
self.module = cuda.module_load_data(np.char.array(data))

def get_function(self, name):
return check_cuda_errors(cuda.cuModuleGetFunction(self.module, name))
if isinstance(name, bytes):
name = name.decode()
return cuda.module_get_function(self.module, name)
5 changes: 3 additions & 2 deletions cuda_bindings/cuda/bindings/_example_helpers/helper_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from cuda.bindings import driver as cuda
from cuda.bindings import nvrtc
from cuda.bindings import runtime as cudart
from cuda.bindings._v2 import driver as cuda_v2

from .helper_string import check_cmd_line_flag, get_cmd_line_argument_int

Expand Down Expand Up @@ -43,6 +44,6 @@ def find_cuda_device_drv():
dev_id = 0
if check_cmd_line_flag("device="):
dev_id = get_cmd_line_argument_int("device=")
check_cuda_errors(cuda.cuInit(0))
cu_device = check_cuda_errors(cuda.cuDeviceGet(dev_id))
cuda_v2.init(0)
cu_device = cuda_v2.device_get(dev_id)
return cu_device
13 changes: 12 additions & 1 deletion cuda_bindings/cuda/bindings/_internal/_fast_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0


# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=581469c1fadb5f72c43b478d73f2b905562136c8723a25e2f4240b5b681e2894
# CYTHON-BINDINGS-GENERATED-DO-NOT-MODIFY-THIS-FILE: format=1; content-sha256=8e5f9b5cdfa1966fc26d3fd6782a41f08bc8b6c24321b0fe5fd1ddd92393bea8
"""
This is a replacement for the stdlib enum.IntEnum.

Expand All @@ -22,6 +22,7 @@ def __init__(cls, name, bases, namespace):

cls.__singletons__ = {}
cls.__members__ = {}
aliases = {}
for name, value in cls.__dict__.items():
if name.startswith("__") and name.endswith("__"):
continue
Expand All @@ -33,6 +34,14 @@ def __init__(cls, name, bases, namespace):
else:
continue

# A name sharing a value with an already-processed member is an
# alias (e.g. a deprecated name kept for backward compatibility):
# it resolves to the same singleton, but isn't a distinct member
# (excluded from __members__, iteration, and len()).
if value in cls.__singletons__:
aliases[name] = cls.__singletons__[value]
continue

singleton = int.__new__(cls, value)
singleton.__doc__ = doc
singleton._name = name
Expand All @@ -41,6 +50,8 @@ def __init__(cls, name, bases, namespace):

for name, member in cls.__members__.items():
setattr(cls, name, member)
for name, member in aliases.items():
setattr(cls, name, member)

def __repr__(cls) -> str:
return f"<enum '{cls.__name__}'>"
Expand Down
725 changes: 725 additions & 0 deletions cuda_bindings/cuda/bindings/_v2/driver.pxd

Large diffs are not rendered by default.

Loading
Loading