dpctl C API¶
dpctl core classes are implemented in Cython. C declarations for Python objects
corresponding to these classes, as well as their Python types are generated by Cython.
Exported typedefs¶
-
struct PySyclDeviceObject¶
-
struct PySyclDeviceType¶
-
struct PySyclContextObject¶
-
struct PySyclContextType¶
-
struct PySyclQueueObject¶
-
struct PySyclQueueType¶
-
struct PySyclEventObject¶
-
struct PySyclEventType¶
-
struct Py_MemoryObject¶
-
struct Py_MemoryType¶
-
struct PySyclKernelObject¶
-
struct PySyclKernelType¶
-
struct PySyclProgramObject¶
-
struct PySyclProgramType¶
To check whether a particular Python object is an instance of dpctl.SyclQueue:
PySyclQueueType¶#include "Python.h"
#include "dpctl_capi.h"
int PySyclQueue_Check(PyObject *o) {
return PyObject_TypeCheck(o, &PySyclQueueType);
}
API for PySyclDeviceObject¶
-
DPCTLSyclDeviceRef SyclDevice_GetDeviceRef(struct PySyclDeviceObject *o)¶
- Parameters:
o – Input object
- Returns:
borrowed instance of
DPCTLSyclDeviceRef
-
struct PySyclDeviceObject *SyclDevice_Make(DPCTLSyclDeviceRef DRef)¶
- Parameters:
DRef – instance of
DPCTLSyclDeviceRef
- Returns:
new Python object of type
PySyclDeviceType
Note that function does not change the ownership of the
DRefinstance and the caller remains responsible for freeingDRefas appropriate.
API for PySyclContextObject¶
-
DPCTLSyclContextRef SyclContext_GetContextRef(struct PySyclContextObject *o)¶
- Parameters:
o – Input object
- Returns:
borrowed instance of
DPCTLSyclContextRef
-
struct PySyclContextObject *SyclContext_Make(DPCTLSyclContextRef CRef)¶
- Parameters:
CRef – instance of
DPCTLSyclContextRef
- Returns:
new Python object of type
PySyclContextType
Note that function does not change the ownership of the
CRefinstance and the caller remains responsible for freeingCRefas appropriate.
API for PySyclQueueObject¶
-
DPCTLSyclQueueRef SyclQueue_GetQueueRef(struct PySyclQueueObject *o)¶
- Parameters:
o – Input object
- Returns:
borrowed instance of
DPCTLSyclQueueRef
-
struct PySyclQueueObject *SyclQueue_Make(DPCTLSyclQueueRef QRef)¶
- Parameters:
QRef – instance of
DPCTLSyclQueueRef
- Returns:
new Python object of type
PySyclQueueType
Note that function does not change the ownership of the
QRefinstance and the caller remains responsible for freeingQRefas appropriate.
API for PySyclEventObject¶
-
DPCTLSyclEventRef SyclEvent_GetEventRef(struct PySyclEventObject *o)¶
- Parameters:
o – Input object
- Returns:
borrowed instance of
DPCTLSyclEventRef
-
struct PySyclEventObject *SyclEvent_Make(DPCTLSyclEventRef ERef)¶
- Parameters:
ERef – instance of
DPCTLSyclEventRef
- Returns:
new Python object of type
PySyclEventType
Note that function does not change the ownership of the
ERefinstance and the caller remains responsible for freeingERefas appropriate.
API for Py_MemoryObject¶
-
DPCTLSyclUSMRef Memory_GetUsmPointer(struct Py_MemoryObject *o)¶
- Parameters:
o – Input object
- Returns:
Opaque pointer to USM allocation represented by Python object.
-
DPCTLSyclContextRef Memory_GetSyclContext(struct Py_MemoryObject *o)¶
- Parameters:
o – Input object
- Returns:
Returns borrowed instance of
PySyclContextRefcorresponding tosycl::contextto which USM allocation represented by input Python object is bound.
-
DPCTLSyclQueueRef Memory_GetSyclQueue(struct Py_MemoryObject *o)¶
- Parameters:
o – Input object
- Returns:
Returns borrowed instance of
PySyclQueueRefcorresponding tosycl::queueassociated with input Python object.
The
sycl::queueuses the samesycl::contextto which the USM allocation represented by input Python object is bound.
-
size_t Memory_GetNumBytes(struct Py_MemoryObject *o)¶
- Parameters:
o – Input object
- Returns:
Size of USM allocation in bytes.
-
struct Py_MemoryObject *Memory_Make(DPCTLSyclUSMRef ptr, size_t nbytes, DPCTLSyclQueueRef QRef, PyObject *owner)¶
- Parameters:
ptr – Opaque pointer in unified address space
nbytes – The size of allocation in bytes
QRef – instance of
PySyclQueueRefcorresponding tosycl::queueto be associated with this allocationowner – Python object instance whose deleter triggers freeing of this USM allocation. Specify owner=None to pass ownership to created Python memory object, which will use
sycl::free(ptr, sycl_queue)for deallocation.
-
void *Memory_GetOpaquePointer(struct Py_MemoryObject *o)¶
- Parameters:
o – Input object
- Returns:
Returns opaque pointer to std::shared_ptr<void> which manages the USM allocation, or a nullptr if the USM allocation represented by o is not managed by the smart pointer.
API for PySyclKernelObject¶
-
DPCTLSyclKernelRef SyclKernel_GetKernelRef(struct PySyclKernelObject *krn)¶
- Parameters:
krn – Input object
- Returns:
borrowed instance of
DPCTLSyclKernelRefcorresponding tosycl::kernel
-
struct PySyclKernelObject *SyclKernel_Make(DPCTLSyclKernelRef KRef)¶
- Parameters:
KRef – instance of
DPCTLSyclKernelRef
- Returns:
new Python object of type
PySyclKernelType
Note that function does not change the ownership of the
KRefinstance and the caller remains responsible for freeingKRefas appropriate.
API for PySyclProgramObject¶
-
DPCTLSyclKernelBundleRef SyclProgram_GetKernelBundleRef(struct PySyclProgramObject *prog)¶
- Parameters:
prog – Input object
- Returns:
borrowed instance of
DPCTLSyclKernelBundleRefcorresponding tosycl::kernel_bundle<sycl::bundle_state::executable>
-
struct PySyclProgramObject *SyclProgram_Make(DPCTLSyclKernelBundleRef KBRef)¶
- Parameters:
KBRef – instance of
DPCTLSyclKernelBundleRef
- Returns:
new Python object of type
PySyclProgramType
Note that function does not change the ownership of the
KBRefinstance and the caller remains responsible for freeingKBRefas appropriate.