Skip to content
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
3 changes: 0 additions & 3 deletions cuda_core/cuda/core/_device_resources.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#
# SPDX-License-Identifier: Apache-2.0

cimport cython

from cuda.bindings cimport cydriver
from cuda.core._resource_handles cimport ContextHandle, GreenCtxHandle

Expand All @@ -17,7 +15,6 @@ cdef class SMResource:
unsigned int _flags
bint _is_usable
object __weakref__
cython.pymutex _split_mutex

@staticmethod
cdef SMResource _from_dev_resource(cydriver.CUdevResource res, int device_id)
Expand Down
9 changes: 4 additions & 5 deletions cuda_core/cuda/core/_device_resources.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,10 @@ cdef class SMResource:
)
_resolve_group_count(opts)
_check_green_ctx_support()
with self._split_mutex:
if _can_use_structured_sm_split():
return _split_with_general_api(self, opts, dry_run)
# SplitByCount requires the same 12.4+ as green ctx support (already checked above)
return _split_with_count_api(self, opts, dry_run)
if _can_use_structured_sm_split():
return _split_with_general_api(self, opts, dry_run)
# SplitByCount requires the same 12.4+ as green ctx support (already checked above)
return _split_with_count_api(self, opts, dry_run)


cdef class WorkqueueResource:
Expand Down
12 changes: 12 additions & 0 deletions cuda_core/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ def wrapper(*args, **kwargs):
kwargs["mempool_device_x2"] = _mempool_device_impl(2)
if "mempool_device_x3" in kwargs:
kwargs["mempool_device_x3"] = _mempool_device_impl(3)

# These are used by test_green_context.py. The original fixtures include
# pytest.skip() but that should have correctly fired by this time.
if "sm_resource" in kwargs:
kwargs["sm_resource"] = device.resources.sm
if "wq_resource" in kwargs:
kwargs["wq_resource"] = device.resources.workqueue
if "green_ctx" in kwargs:
from cuda.core import ContextOptions, SMResourceOptions

groups, _ = device.resources.sm.split(SMResourceOptions(count=None))
kwargs["green_ctx"] = device.create_context(ContextOptions(resources=[groups[0]]))
return func(*args, **kwargs)

wrapper._cuda_core_worker_cuda_wrapped = True
Expand Down
2 changes: 2 additions & 0 deletions cuda_core/tests/test_green_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
# ---------------------------------------------------------------------------
# Fixtures
# ---------------------------------------------------------------------------
# Note that the following fixtures (except fill_kernel) require per-thread setup
# and are currently special cased to work with pytest-run-parallel in conftest.


@pytest.fixture
Expand Down
Loading