File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22#
33# SPDX-License-Identifier: Apache-2.0
44
5+ from __future__ import annotations
6+
7+ from collections.abc import Sequence
58from dataclasses import dataclass
69
710from cuda.bindings cimport cydriver
11+ from cuda.core._device_resources import SMResource, WorkqueueResource
812from cuda.core._resource_handles cimport (
913 ContextHandle,
1014 GreenCtxHandle,
@@ -21,6 +25,9 @@ from cuda.core._utils.cuda_utils cimport HANDLE_RETURN
2125__all__ = [' Context' , ' ContextOptions' ]
2226
2327
28+ DeviceResourcesT = SMResource | WorkqueueResource | Sequence[SMResource | WorkqueueResource]
29+
30+
2431cdef class Context:
2532 """ CUDA context wrapper.
2633
@@ -100,12 +107,12 @@ cdef class Context:
100107
101108
102109@dataclass
103- class ContextOptions :
110+ cdef class ContextOptions:
104111 """ Options for context creation.
105112
106113 Attributes
107114 ----------
108- resources : Sequence[SMResource | WorkqueueResource], optional
115+ resources : :obj:`~_context.DeviceResourcesT`
109116 Device resources used to create a green context.
110117 """
111- resources: object = None
118+ resources: DeviceResourcesT
Original file line number Diff line number Diff line change @@ -7,19 +7,14 @@ from __future__ import annotations
77cimport cpython
88
99from cuda.bindings cimport cydriver
10- from cuda.core._utils.cuda_utils cimport HANDLE_RETURN
10+ from cuda.core._utils.cuda_utils cimport check_or_create_options, HANDLE_RETURN
1111from libc.stdlib cimport free, malloc
1212
1313import threading
1414
1515from cuda.core._context cimport Context
1616from cuda.core._context import ContextOptions
1717from cuda.core._device_resources cimport DeviceResources, SMResource, WorkqueueResource
18- from cuda.core._device_resources import (
19- DeviceResources,
20- SMResource,
21- WorkqueueResource,
22- )
2318from cuda.core._event cimport Event as cyEvent
2419from cuda.core._event import Event, EventOptions
2520from cuda.core._memory._buffer cimport Buffer, MemoryResource
@@ -1309,7 +1304,7 @@ class Device:
13091304 if options is None:
13101305 raise NotImplementedError("WIP: https://github.com/NVIDIA/cuda-python/issues/189")
13111306
1312- assert_type( options , ContextOptions )
1307+ options = check_or_create_options(ContextOptions, options, " Context options " )
13131308 if options.resources is None:
13141309 raise NotImplementedError("WIP: https://github.com/NVIDIA/cuda-python/issues/189")
13151310
Original file line number Diff line number Diff line change @@ -8,14 +8,18 @@ from cuda.bindings cimport cydriver
88cdef class SMResource:
99 cdef:
1010 cydriver.CUdevResource _resource
11+ unsigned int _sm_count
12+ unsigned int _min_partition_size
13+ unsigned int _coscheduled_alignment
14+ unsigned int _flags
1115 bint _is_usable
1216 object __weakref__
1317
1418 @staticmethod
15- cdef SMResource _from_dev_resource(cydriver.CUdevResource res)
19+ cdef SMResource _from_dev_resource(cydriver.CUdevResource res, int device_id )
1620
1721 @staticmethod
18- cdef SMResource _from_dry_run_resource (cydriver.CUdevResource res)
22+ cdef SMResource _from_split_resource (cydriver.CUdevResource res, SMResource parent, bint is_usable )
1923
2024
2125cdef class WorkqueueResource:
You can’t perform that action at this time.
0 commit comments