Skip to content

Commit d0e6bf5

Browse files
Added SyclPlatform.default_context property
1 parent 0bb4f4b commit d0e6bf5

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

dpctl/_sycl_platform.pyx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ from ._backend cimport ( # noqa: E211
3030
DPCTLPlatform_CreateFromSelector,
3131
DPCTLPlatform_Delete,
3232
DPCTLPlatform_GetBackend,
33+
DPCTLPlatform_GetDefaultContext,
3334
DPCTLPlatform_GetName,
3435
DPCTLPlatform_GetPlatforms,
3536
DPCTLPlatform_GetVendor,
@@ -40,15 +41,19 @@ from ._backend cimport ( # noqa: E211
4041
DPCTLPlatformVector_GetAt,
4142
DPCTLPlatformVector_Size,
4243
DPCTLPlatformVectorRef,
44+
DPCTLSyclContextRef,
4345
DPCTLSyclDeviceSelectorRef,
4446
DPCTLSyclPlatformRef,
4547
_backend_type,
4648
)
4749

4850
import warnings
4951

52+
from ._sycl_context import SyclContextCreationError
5053
from .enum_types import backend_type
5154

55+
from ._sycl_context cimport SyclContext
56+
5257
__all__ = [
5358
"get_platforms",
5459
"lsplatform",
@@ -236,10 +241,10 @@ cdef class SyclPlatform(_SyclPlatform):
236241

237242
@property
238243
def backend(self):
239-
"""Returns the backend_type enum value for this device
244+
"""Returns the backend_type enum value for this platform
240245
241246
Returns:
242-
backend_type: The backend for the device.
247+
backend_type: The backend for the platform.
243248
"""
244249
cdef _backend_type BTy = (
245250
DPCTLPlatform_GetBackend(self._platform_ref)
@@ -255,6 +260,22 @@ cdef class SyclPlatform(_SyclPlatform):
255260
else:
256261
raise ValueError("Unknown backend type.")
257262

263+
@property
264+
def default_context(self):
265+
"""Returns the default platform context for this platform
266+
267+
Returns:
268+
SyclContext: The default context for the platform.
269+
"""
270+
cdef DPCTLSyclContextRef CRef = (
271+
DPCTLPlatform_GetDefaultContext(self._platform_ref)
272+
)
273+
274+
if (CRef == NULL):
275+
raise
276+
else:
277+
return SyclContext._create(CRef)
278+
258279

259280
def lsplatform(verbosity=0):
260281
"""

0 commit comments

Comments
 (0)