Global Namespace

Overview

// typedefs

typedef  struct DPCTLOpaqueSyclContext* DPCTLSyclContextRef;
typedef struct DPCTLOpaqueSyclDevice* DPCTLSyclDeviceRef;
typedef struct DPCTLOpaqueSyclDeviceSelector* DPCTLSyclDeviceSelectorRef;
typedef struct DPCTLOpaqueSyclEvent* DPCTLSyclEventRef;
typedef struct DPCTLOpaqueSyclKernel* DPCTLSyclKernelRef;
typedef struct DPCTLOpaqueSyclPlatform* DPCTLSyclPlatformRef;
typedef struct DPCTLOpaqueSyclProgram* DPCTLSyclProgramRef;
typedef struct DPCTLOpaqueSyclQueue* DPCTLSyclQueueRef;
typedef struct DPCTLOpaqueSyclUSM* DPCTLSyclUSMRef;

// enums

enum DPCTLKernelArgType;
enum DPCTLSyclBackendType;
enum DPCTLSyclDeviceType;

// global functions

DPCTL_C_EXTERN_C_BEGIN DPCTL_API bool
DPCTLContext_AreEq(
    __dpctl_keep const DPCTLSyclContextRef CtxRef1,
    __dpctl_keep const DPCTLSyclContextRef CtxRef2
    );

DPCTL_API void
DPCTLContext_Delete(__dpctl_take DPCTLSyclContextRef CtxRef);

DPCTL_API DPCTLSyclBackendType
DPCTLContext_GetBackend(__dpctl_keep const DPCTLSyclContextRef CtxRef);

DPCTL_API bool
DPCTLContext_IsHost(__dpctl_keep const DPCTLSyclContextRef CtxRef);

DPCTL_API bool
DPCTLDevice_AreEq(
    __dpctl_keep const DPCTLSyclDeviceRef DevRef1,
    __dpctl_keep const DPCTLSyclDeviceRef DevRef2
    );

DPCTL_C_EXTERN_C_BEGIN DPCTL_API __dpctl_give DPCTLSyclDeviceRef
DPCTLDevice_Copy(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API __dpctl_give DPCTLSyclDeviceRef
DPCTLDevice_Create();

DPCTL_API __dpctl_give DPCTLSyclDeviceRef
DPCTLDevice_CreateFromSelector(__dpctl_keep const DPCTLSyclDeviceSelectorRef DSRef);

DPCTL_API void
DPCTLDevice_Delete(__dpctl_take DPCTLSyclDeviceRef DRef);

DPCTL_API void
DPCTLDevice_DumpInfo(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API const __dpctl_give char*
DPCTLDevice_GetDriverInfo(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API uint32_t
DPCTLDevice_GetMaxComputeUnits(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API uint32_t
DPCTLDevice_GetMaxNumSubGroups(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API size_t
DPCTLDevice_GetMaxWorkGroupSize(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API uint32_t
DPCTLDevice_GetMaxWorkItemDims(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API __dpctl_keep size_t*
DPCTLDevice_GetMaxWorkItemSizes(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API const __dpctl_give char*
DPCTLDevice_GetName(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API const __dpctl_give char*
DPCTLDevice_GetVendorName(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API bool
DPCTLDevice_HasInt64BaseAtomics(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API bool
DPCTLDevice_HasInt64ExtendedAtomics(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API bool
DPCTLDevice_IsAccelerator(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API bool
DPCTLDevice_IsCPU(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API bool
DPCTLDevice_IsGPU(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API bool
DPCTLDevice_IsHost(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API bool
DPCTLDevice_IsHostUnifiedMemory(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_C_EXTERN_C_BEGIN DPCTL_API __dpctl_give DPCTLSyclDeviceSelectorRef
DPCTLAcceleratorSelector_Create();

DPCTL_API __dpctl_give DPCTLSyclDeviceSelectorRef
DPCTLCPUSelector_Create();

DPCTL_API __dpctl_give DPCTLSyclDeviceSelectorRef
DPCTLDefaultSelector_Create();

DPCTL_API void
DPCTLDeviceSelector_Delete(__dpctl_take DPCTLSyclDeviceSelectorRef DSRef);

DPCTL_API __dpctl_give DPCTLSyclDeviceSelectorRef
DPCTLFilterSelector_Create(__dpctl_keep const char* filter_str);

DPCTL_API __dpctl_give DPCTLSyclDeviceSelectorRef
DPCTLGPUSelector_Create();

DPCTL_API __dpctl_give DPCTLSyclDeviceSelectorRef
DPCTLHostSelector_Create();

DPCTL_API void
DPCTLEvent_Delete(__dpctl_take DPCTLSyclEventRef ERef);

DPCTL_C_EXTERN_C_BEGIN DPCTL_API void
DPCTLEvent_Wait(__dpctl_keep DPCTLSyclEventRef ERef);

DPCTL_API void
DPCTLKernel_Delete(__dpctl_take DPCTLSyclKernelRef KRef);

DPCTL_C_EXTERN_C_BEGIN DPCTL_API const __dpctl_give char*
DPCTLKernel_GetFunctionName(__dpctl_keep const DPCTLSyclKernelRef KRef);

DPCTL_API size_t
DPCTLKernel_GetNumArgs(__dpctl_keep const DPCTLSyclKernelRef KRef);

DPCTL_API void
DPCTLPlatform_DeleteListOfBackends(__dpctl_take DPCTLSyclBackendType* BEArr);

DPCTL_API void
DPCTLPlatform_DumpInfo();

DPCTL_API __dpctl_give DPCTLSyclBackendType*
DPCTLPlatform_GetListOfNonHostBackends();

DPCTL_API size_t
DPCTLPlatform_GetNumNonHostBackends();

DPCTL_C_EXTERN_C_BEGIN DPCTL_API size_t
DPCTLPlatform_GetNumNonHostPlatforms();

DPCTL_API __dpctl_give DPCTLSyclProgramRef
DPCTLProgram_CreateFromOCLSource(
    __dpctl_keep const DPCTLSyclContextRef Ctx,
    __dpctl_keep const char* Source,
    __dpctl_keep const char* CompileOpts
    );

DPCTL_C_EXTERN_C_BEGIN DPCTL_API __dpctl_give DPCTLSyclProgramRef
DPCTLProgram_CreateFromSpirv(
    __dpctl_keep const DPCTLSyclContextRef Ctx,
    __dpctl_keep const void* IL,
    size_t Length,
    const char* CompileOpts
    );

DPCTL_API void
DPCTLProgram_Delete(__dpctl_take DPCTLSyclProgramRef PRef);

DPCTL_API __dpctl_give DPCTLSyclKernelRef
DPCTLProgram_GetKernel(
    __dpctl_keep DPCTLSyclProgramRef PRef,
    __dpctl_keep const char* KernelName
    );

DPCTL_API bool
DPCTLProgram_HasKernel(
    __dpctl_keep DPCTLSyclProgramRef PRef,
    __dpctl_keep const char* KernelName
    );

DPCTL_API bool
DPCTLQueue_AreEq(
    __dpctl_keep const DPCTLSyclQueueRef QRef1,
    __dpctl_keep const DPCTLSyclQueueRef QRef2
    );

DPCTL_C_EXTERN_C_BEGIN DPCTL_API void
DPCTLQueue_Delete(__dpctl_take DPCTLSyclQueueRef QRef);

DPCTL_API DPCTLSyclBackendType
DPCTLQueue_GetBackend(__dpctl_keep DPCTLSyclQueueRef QRef);

DPCTL_API __dpctl_give DPCTLSyclContextRef
DPCTLQueue_GetContext(__dpctl_keep const DPCTLSyclQueueRef QRef);

DPCTL_API __dpctl_give DPCTLSyclDeviceRef
DPCTLQueue_GetDevice(__dpctl_keep const DPCTLSyclQueueRef QRef);

DPCTL_API void
DPCTLQueue_MemAdvise(
    __dpctl_keep DPCTLSyclQueueRef QRef,
    const void* Ptr,
    size_t Count,
    int Advice
    );

DPCTL_API void
DPCTLQueue_Memcpy(
    __dpctl_keep const DPCTLSyclQueueRef QRef,
    void* Dest,
    const void* Src,
    size_t Count
    );

DPCTL_API void
DPCTLQueue_Prefetch(
    __dpctl_keep DPCTLSyclQueueRef QRef,
    const void* Ptr,
    size_t Count
    );

DPCTL_API DPCTLSyclEventRef
DPCTLQueue_SubmitNDRange(
    __dpctl_keep const DPCTLSyclKernelRef KRef,
    __dpctl_keep const DPCTLSyclQueueRef QRef,
    __dpctl_keep void** Args,
    __dpctl_keep const DPCTLKernelArgType* ArgTypes,
    size_t NArgs,
    __dpctl_keep const size_t gRange[3],
    __dpctl_keep const size_t lRange[3],
    size_t NDims,
    __dpctl_keep const DPCTLSyclEventRef* DepEvents,
    size_t NDepEvents
    );

DPCTL_API DPCTLSyclEventRef
DPCTLQueue_SubmitRange(
    __dpctl_keep const DPCTLSyclKernelRef KRef,
    __dpctl_keep const DPCTLSyclQueueRef QRef,
    __dpctl_keep void** Args,
    __dpctl_keep const DPCTLKernelArgType* ArgTypes,
    size_t NArgs,
    __dpctl_keep const size_t Range[3],
    size_t NRange,
    __dpctl_keep const DPCTLSyclEventRef* DepEvents,
    size_t NDepEvents
    );

DPCTL_API void
DPCTLQueue_Wait(__dpctl_keep const DPCTLSyclQueueRef QRef);

DPCTL_C_EXTERN_C_BEGIN DPCTL_API __dpctl_give DPCTLSyclQueueRef
DPCTLQueueMgr_GetCurrentQueue();

DPCTL_API size_t
DPCTLQueueMgr_GetNumActivatedQueues();

DPCTL_API size_t
DPCTLQueueMgr_GetNumQueues(
    DPCTLSyclBackendType BETy,
    DPCTLSyclDeviceType DeviceTy
    );

DPCTL_API __dpctl_give DPCTLSyclQueueRef
DPCTLQueueMgr_GetQueue(
    DPCTLSyclBackendType BETy,
    DPCTLSyclDeviceType DeviceTy,
    size_t DNum
    );

DPCTL_API __dpctl_give DPCTLSyclQueueRef
DPCTLQueueMgr_GetQueueFromContextAndDevice(
    __dpctl_keep DPCTLSyclContextRef CRef,
    __dpctl_keep DPCTLSyclDeviceRef DRef
    );

DPCTL_API bool
DPCTLQueueMgr_IsCurrentQueue(__dpctl_keep const DPCTLSyclQueueRef QRef);

DPCTL_API void
DPCTLQueueMgr_PopQueue();

DPCTL_API __dpctl_give DPCTLSyclQueueRef
DPCTLQueueMgr_PushQueue(
    DPCTLSyclBackendType BETy,
    DPCTLSyclDeviceType DeviceTy,
    size_t DNum
    );

DPCTL_API __dpctl_give DPCTLSyclQueueRef
DPCTLQueueMgr_SetAsDefaultQueue(
    DPCTLSyclBackendType BETy,
    DPCTLSyclDeviceType DeviceTy,
    size_t DNum
    );

DPCTL_API __dpctl_give DPCTLSyclUSMRef
DPCTLaligned_alloc_device(
    size_t alignment,
    size_t size,
    __dpctl_keep const DPCTLSyclQueueRef QRef
    );

DPCTL_API __dpctl_give DPCTLSyclUSMRef
DPCTLaligned_alloc_host(
    size_t alignment,
    size_t size,
    __dpctl_keep const DPCTLSyclQueueRef QRef
    );

DPCTL_API __dpctl_give DPCTLSyclUSMRef
DPCTLaligned_alloc_shared(
    size_t alignment,
    size_t size,
    __dpctl_keep const DPCTLSyclQueueRef QRef
    );

DPCTL_API void
DPCTLfree_with_context(
    __dpctl_take DPCTLSyclUSMRef MRef,
    __dpctl_keep const DPCTLSyclContextRef CRef
    );

DPCTL_API void
DPCTLfree_with_queue(
    __dpctl_take DPCTLSyclUSMRef MRef,
    __dpctl_keep const DPCTLSyclQueueRef QRef
    );

DPCTL_API __dpctl_give DPCTLSyclUSMRef
DPCTLmalloc_device(
    size_t size,
    __dpctl_keep const DPCTLSyclQueueRef QRef
    );

DPCTL_API __dpctl_give DPCTLSyclUSMRef
DPCTLmalloc_host(
    size_t size,
    __dpctl_keep const DPCTLSyclQueueRef QRef
    );

DPCTL_C_EXTERN_C_BEGIN DPCTL_API __dpctl_give DPCTLSyclUSMRef
DPCTLmalloc_shared(
    size_t size,
    __dpctl_keep const DPCTLSyclQueueRef QRef
    );

DPCTL_API DPCTLSyclDeviceRef
DPCTLUSM_GetPointerDevice(
    __dpctl_keep const DPCTLSyclUSMRef MRef,
    __dpctl_keep const DPCTLSyclContextRef CRef
    );

const DPCTL_API char*
DPCTLUSM_GetPointerType(
    __dpctl_keep const DPCTLSyclUSMRef MRef,
    __dpctl_keep const DPCTLSyclContextRef CRef
    );

Detailed Documentation

Typedefs

typedef  struct DPCTLOpaqueSyclContext* DPCTLSyclContextRef

Opaque pointer to a sycl::context.

typedef struct DPCTLOpaqueSyclDevice* DPCTLSyclDeviceRef

Opaque pointer to a sycl::device.

typedef struct DPCTLOpaqueSyclDeviceSelector* DPCTLSyclDeviceSelectorRef

Opaque pointer to a sycl::device_selector.

typedef struct DPCTLOpaqueSyclEvent* DPCTLSyclEventRef

Opaque pointer to a sycl::event.

typedef struct DPCTLOpaqueSyclKernel* DPCTLSyclKernelRef

Opaque pointer to a sycl::kernel.

typedef struct DPCTLOpaqueSyclPlatform* DPCTLSyclPlatformRef

Opaque pointer to a sycl::platform.

typedef struct DPCTLOpaqueSyclProgram* DPCTLSyclProgramRef

Opaque pointer to a sycl::program.

typedef struct DPCTLOpaqueSyclQueue* DPCTLSyclQueueRef

Opaque pointer to a sycl::queue.

See also:

sycl::queue

typedef struct DPCTLOpaqueSyclUSM* DPCTLSyclUSMRef

Used to pass a sycl::usm memory opaquely through DPCTL interfaces.

See also:

sycl::usm

Global Functions

DPCTL_C_EXTERN_C_BEGIN DPCTL_API bool
DPCTLContext_AreEq(
    __dpctl_keep const DPCTLSyclContextRef CtxRef1,
    __dpctl_keep const DPCTLSyclContextRef CtxRef2
    )

Checks if two DPCTLSyclContextRef objects point to the same sycl::context.

Parameters:

CtxRef1

First opaque pointer to the sycl context.

CtxRef2

Second opaque pointer to the sycl context.

Returns:

True if the underlying sycl::context are same, false otherwise.

DPCTL_API void
DPCTLContext_Delete(__dpctl_take DPCTLSyclContextRef CtxRef)

Delete the pointer after casting it to sycl::context.

Parameters:

CtxRef

The DPCTLSyclContextRef pointer to be deleted.

DPCTL_API DPCTLSyclBackendType
DPCTLContext_GetBackend(__dpctl_keep const DPCTLSyclContextRef CtxRef)

Returns the sycl backend for the DPCTLSyclContextRef pointer.

Parameters:

CtxRef

An opaque pointer to a sycl::context.

Returns:

The sycl backend for the DPCTLSyclContextRef returned as a DPCTLSyclBackendType enum type.

DPCTL_API bool
DPCTLContext_IsHost(__dpctl_keep const DPCTLSyclContextRef CtxRef)

Returns true if this SYCL context is a host context.

Parameters:

CtxRef

An opaque pointer to a sycl::context.

Returns:

True if the SYCL context is a host context, else False.

DPCTL_API bool
DPCTLDevice_AreEq(
    __dpctl_keep const DPCTLSyclDeviceRef DevRef1,
    __dpctl_keep const DPCTLSyclDeviceRef DevRef2
    )

Checks if two DPCTLSyclDeviceRef objects point to the same sycl::device.

Parameters:

DevRef1

First opaque pointer to the sycl device.

DevRef2

Second opaque pointer to the sycl device.

Returns:

True if the underlying sycl::device are same, false otherwise.

DPCTL_C_EXTERN_C_BEGIN DPCTL_API __dpctl_give DPCTLSyclDeviceRef
DPCTLDevice_Copy(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Returns a copy of the DPCTLSyclDeviceRef object.

Parameters:

DRef

DPCTLSyclDeviceRef object to be copied.

Returns:

A new DPCTLSyclDeviceRef created by copying the passed in DPCTLSyclDeviceRef object.

DPCTL_API __dpctl_give DPCTLSyclDeviceRef
DPCTLDevice_Create()

Returns a new DPCTLSyclDeviceRef opaque object wrapping a SYCL device instance as a host device.

Returns:

An opaque pointer to the host SYCL device.

DPCTL_API __dpctl_give DPCTLSyclDeviceRef
DPCTLDevice_CreateFromSelector(__dpctl_keep const DPCTLSyclDeviceSelectorRef DSRef)

Returns a new DPCTLSyclDeviceRef opaque object created using the provided device_selector.

Parameters:

DSRef

An opaque pointer to a SYCL device_selector.

Returns:

Returns an opaque pointer to a SYCL device created using the device_selector, if the requested device could not be created a nullptr is returned.

DPCTL_API void
DPCTLDevice_Delete(__dpctl_take DPCTLSyclDeviceRef DRef)

Deletes a DPCTLSyclDeviceRef pointer after casting to to sycl::device.

Parameters:

DRef

The DPCTLSyclDeviceRef pointer to be freed.

DPCTL_API void
DPCTLDevice_DumpInfo(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Prints out some of the info::deivice attributes for the device.

Parameters:

DRef

A DPCTLSyclDeviceRef pointer.

DPCTL_API const __dpctl_give char*
DPCTLDevice_GetDriverInfo(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Returns the OpenCL software driver version as a C string.

Parameters:

DRef

Opaque pointer to a sycl::device

Returns:

A C string in the form major_number.minor.number that corresponds to the OpenCL driver version if this is a OpenCL device.

DPCTL_API uint32_t
DPCTLDevice_GetMaxComputeUnits(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Wrapper over device.get_info<info::device::max_compute_units>().

Parameters:

DRef

Opaque pointer to a sycl::device

Returns:

Returns the valid result if device exists else returns 0.

DPCTL_API uint32_t
DPCTLDevice_GetMaxNumSubGroups(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Wrapper over device.get_info<info::device::max_num_sub_groups>.

Parameters:

DRef

Opaque pointer to a sycl::device

Returns:

Returns the valid result if device exists else returns 0.

DPCTL_API size_t
DPCTLDevice_GetMaxWorkGroupSize(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Wrapper for get_info<info::device::max_work_group_size>().

Parameters:

DRef

Opaque pointer to a sycl::device

Returns:

Returns the valid result if device exists else returns 0.

DPCTL_API uint32_t
DPCTLDevice_GetMaxWorkItemDims(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Wrapper for get_info<info::device::max_work_item_dimensions>().

Parameters:

DRef

Opaque pointer to a sycl::device

Returns:

Returns the valid result if device exists else returns 0.

DPCTL_API __dpctl_keep size_t*
DPCTLDevice_GetMaxWorkItemSizes(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Wrapper for get_info<info::device::max_work_item_sizes>().

Parameters:

DRef

Opaque pointer to a sycl::device

Returns:

Returns the valid result if device exists else returns NULL.

DPCTL_API const __dpctl_give char*
DPCTLDevice_GetName(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Returns a C string for the device name.

Parameters:

DRef

Opaque pointer to a sycl::device

Returns:

A C string containing the OpenCL device name.

DPCTL_API const __dpctl_give char*
DPCTLDevice_GetVendorName(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Returns a C string corresponding to the vendor name.

Parameters:

DRef

Opaque pointer to a sycl::device

Returns:

A C string containing the OpenCL device vendor name.

DPCTL_API bool
DPCTLDevice_HasInt64BaseAtomics(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Wrapper over device.get_info<info::device::aspect::int64_base_atomics>.

Parameters:

DRef

Opaque pointer to a sycl::device

Returns:

Returns true if device has int64_base_atomics else returns false.

DPCTL_API bool
DPCTLDevice_HasInt64ExtendedAtomics(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Wrapper over device.get_info<info::device::aspect::int64_extended_atomics>.

Parameters:

DRef

Opaque pointer to a sycl::device

Returns:

Returns true if device has int64_extended_atomics else returns false.

DPCTL_API bool
DPCTLDevice_IsAccelerator(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Returns true if this SYCL device is an OpenCL device and the device type is sycl::info::device_type::accelerator.

Parameters:

DRef

Opaque pointer to a sycl::device

Returns:

True if the device type is an accelerator, else False.

DPCTL_API bool
DPCTLDevice_IsCPU(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Returns true if this SYCL device is an OpenCL device and the device type is sycl::info::device_type::cpu.

Parameters:

DRef

Opaque pointer to a sycl::device

Returns:

True if the device type is a cpu, else False.

DPCTL_API bool
DPCTLDevice_IsGPU(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Returns true if this SYCL device is an OpenCL device and the device type is sycl::info::device_type::gpu.

Parameters:

DRef

Opaque pointer to a sycl::device

Returns:

True if the device type is a gpu, else False.

DPCTL_API bool
DPCTLDevice_IsHost(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Returns true if this SYCL device is a host device.

Parameters:

DRef

Opaque pointer to a sycl::device

Returns:

True if the device is a host device, else False.

DPCTL_API bool
DPCTLDevice_IsHostUnifiedMemory(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Returns True if the device and the host share a unified memory subsystem, else returns False.

Parameters:

DRef

Opaque pointer to a sycl::device

Returns:

Boolean indicating if the device shares a unified memory subsystem with the host.

DPCTL_C_EXTERN_C_BEGIN DPCTL_API __dpctl_give DPCTLSyclDeviceSelectorRef
DPCTLAcceleratorSelector_Create()

Returns an opaque wrapper for sycl::accelerator_selector object.

Returns:

An opaque pointer to a sycl::accelerator_selector object.

DPCTL_API __dpctl_give DPCTLSyclDeviceSelectorRef
DPCTLCPUSelector_Create()

Returns an opaque wrapper for sycl::cpu_selector object.

Returns:

An opaque pointer to a sycl::cpu_selector object.

DPCTL_API __dpctl_give DPCTLSyclDeviceSelectorRef
DPCTLDefaultSelector_Create()

Returns an opaque wrapper for sycl::default_selector object.

Returns:

An opaque pointer to a sycl::default_selector object.

DPCTL_API void
DPCTLDeviceSelector_Delete(__dpctl_take DPCTLSyclDeviceSelectorRef DSRef)

Deletes the DPCTLSyclDeviceSelectorRef after casting it to a sycl::device_selector.

Parameters:

DSRef

An opaque DPCTLSyclDeviceSelectorRef pointer that would be freed.

DPCTL_API __dpctl_give DPCTLSyclDeviceSelectorRef
DPCTLFilterSelector_Create(__dpctl_keep const char* filter_str)

Returns an opaque wrapper for sycl::ONEAPI::filter_selector object based on the passed in filter string.

Parameters:

filter_str

A C string providing a filter based on which to create a device_selector.

Returns:

An opaque pointer to a sycl::ONEAPI::filter_selector object.

DPCTL_API __dpctl_give DPCTLSyclDeviceSelectorRef
DPCTLGPUSelector_Create()

Returns an opaque wrapper for sycl::gpu_selector object.

Returns:

An opaque pointer to a sycl::gpu_selector object.

DPCTL_API __dpctl_give DPCTLSyclDeviceSelectorRef
DPCTLHostSelector_Create()

Returns an opaque wrapper for sycl::host_selector object.

Returns:

An opaque pointer to a sycl::host_selector object.

DPCTL_API void
DPCTLEvent_Delete(__dpctl_take DPCTLSyclEventRef ERef)

Deletes the DPCTLSyclEventRef after casting it to a sycl::event.

Parameters:

ERef

An opaque DPCTLSyclEventRef pointer that would be freed.

DPCTL_C_EXTERN_C_BEGIN DPCTL_API void
DPCTLEvent_Wait(__dpctl_keep DPCTLSyclEventRef ERef)

C-API wrapper for sycl::event.wait.

Parameters:

ERef

An opaque DPCTLSyclEventRef pointer on which to wait.

DPCTL_API void
DPCTLKernel_Delete(__dpctl_take DPCTLSyclKernelRef KRef)

Deletes the DPCTLSyclKernelRef after casting it to a sycl::kernel.

Parameters:

KRef

DPCTLSyclKernelRef pointer to an OpenCL interoperability kernel.

DPCTL_C_EXTERN_C_BEGIN DPCTL_API const __dpctl_give char*
DPCTLKernel_GetFunctionName(__dpctl_keep const DPCTLSyclKernelRef KRef)

Returns a C string for the kernel name.

Parameters:

KRef

DPCTLSyclKernelRef pointer to an OpenCL interoperability kernel.

Returns:

If a kernel name exists then returns it as a C string, else returns a nullptr.

DPCTL_API size_t
DPCTLKernel_GetNumArgs(__dpctl_keep const DPCTLSyclKernelRef KRef)

Returns the number of arguments for the OpenCL kernel.

Parameters:

KRef

DPCTLSyclKernelRef pointer to an OpenCL interoperability kernel.

Returns:

Returns the number of arguments for the OpenCL interoperability kernel.

DPCTL_API void
DPCTLPlatform_DeleteListOfBackends(__dpctl_take DPCTLSyclBackendType* BEArr)

Frees an array of DPCTLSyclBackendType enum values.

Parameters:

BEArr

An array of DPCTLSyclBackendType enum values to be freed.

DPCTL_API void
DPCTLPlatform_DumpInfo()

Prints out some selected info about all sycl::platform on the system.

DPCTL_API __dpctl_give DPCTLSyclBackendType*
DPCTLPlatform_GetListOfNonHostBackends()

Returns an array of the unique non-host DPCTLSyclBackendType values on the system.

Returns:

An array of DPCTLSyclBackendType enum values.

DPCTL_API size_t
DPCTLPlatform_GetNumNonHostBackends()

Returns the number of unique non-host sycl backends on the system.

Returns:

The number of unique sycl backends.

DPCTL_C_EXTERN_C_BEGIN DPCTL_API size_t
DPCTLPlatform_GetNumNonHostPlatforms()

Returns the number of non-host type sycl::platform available on the system.

Returns:

The number of available sycl::platforms.

DPCTL_API __dpctl_give DPCTLSyclProgramRef
DPCTLProgram_CreateFromOCLSource(
    __dpctl_keep const DPCTLSyclContextRef Ctx,
    __dpctl_keep const char* Source,
    __dpctl_keep const char* CompileOpts
    )

Create a Sycl program from an OpenCL kernel source string.

Parameters:

Ctx

An opaque pointer to a sycl::context

Source

OpenCL source string

CompileOpts

Extra compiler flags (refer Sycl spec.)

Returns:

A new SyclProgramRef pointer if the program creation succeeded, else returns NULL.

DPCTL_C_EXTERN_C_BEGIN DPCTL_API __dpctl_give DPCTLSyclProgramRef
DPCTLProgram_CreateFromSpirv(
    __dpctl_keep const DPCTLSyclContextRef Ctx,
    __dpctl_keep const void* IL,
    size_t Length,
    const char* CompileOpts
    )

Create a Sycl program from an OpenCL SPIR-V binary file.

Sycl 1.2 does not expose any method to create a sycl::program from a SPIR-V IL file. To get around this limitation, we first creare a SYCL interoperability program and then create a SYCL program from the interoperability program. Currently, interoperability programs can be created for OpenCL and Level-0 backends.

The feature to create a Sycl kernel from a SPIR-V IL binary will be available in Sycl 2.0 at which point this function may become deprecated.

Parameters:

Ctx

An opaque pointer to a sycl::context

IL

SPIR-V binary

Length

The size of the IL binary in bytes.

CompileOpts

Optional compiler flags used when compiling the SPIR-V binary.

Returns:

A new SyclProgramRef pointer if the program creation succeeded, else returns NULL.

DPCTL_API void
DPCTLProgram_Delete(__dpctl_take DPCTLSyclProgramRef PRef)

Frees the DPCTLSyclProgramRef pointer.

Parameters:

PRef

Opaque pointer to a sycl::program

DPCTL_API __dpctl_give DPCTLSyclKernelRef
DPCTLProgram_GetKernel(
    __dpctl_keep DPCTLSyclProgramRef PRef,
    __dpctl_keep const char* KernelName
    )

Returns the SyclKernel with given name from the program, if not found then return NULL.

Parameters:

PRef

Opaque pointer to a sycl::program

KernelName

Name of kernel

Returns:

A SyclKernel reference if the kernel exists, else NULL

DPCTL_API bool
DPCTLProgram_HasKernel(
    __dpctl_keep DPCTLSyclProgramRef PRef,
    __dpctl_keep const char* KernelName
    )

Return True if a SyclKernel with given name exists in the program, if not found then returns False.

Parameters:

PRef

Opaque pointer to a sycl::program

KernelName

Name of kernel

Returns:

True if the kernel exists, else False

DPCTL_API bool
DPCTLQueue_AreEq(
    __dpctl_keep const DPCTLSyclQueueRef QRef1,
    __dpctl_keep const DPCTLSyclQueueRef QRef2
    )

Checks if two DPCTLSyclQueueRef objects point to the same sycl::queue.

Parameters:

QRef1

First opaque pointer to the sycl queue.

QRef2

Second opaque pointer to the sycl queue.

Returns:

True if the underlying sycl::queue are same, false otherwise.

DPCTL_C_EXTERN_C_BEGIN DPCTL_API void
DPCTLQueue_Delete(__dpctl_take DPCTLSyclQueueRef QRef)

Delete the pointer after casting it to sycl::queue.

Parameters:

QRef

A DPCTLSyclQueueRef pointer that gets deleted.

DPCTL_API DPCTLSyclBackendType
DPCTLQueue_GetBackend(__dpctl_keep DPCTLSyclQueueRef QRef)

Returns the Sycl backend for the provided sycl::queue.

Parameters:

QRef

An opaque pointer to the sycl queue.

Returns:

A enum DPCTLSyclBackendType corresponding to the backed for the queue.

DPCTL_API __dpctl_give DPCTLSyclContextRef
DPCTLQueue_GetContext(__dpctl_keep const DPCTLSyclQueueRef QRef)

Returns the Sycl context for the queue.

Parameters:

QRef

An opaque pointer to the sycl queue.

Returns:

A DPCTLSyclContextRef pointer to the sycl context for the queue.

DPCTL_API __dpctl_give DPCTLSyclDeviceRef
DPCTLQueue_GetDevice(__dpctl_keep const DPCTLSyclQueueRef QRef)

returns the Sycl device for the queue.

Parameters:

QRef

An opaque pointer to the sycl queue.

Returns:

A DPCTLSyclDeviceRef pointer to the sycl device for the queue.

DPCTL_API void
DPCTLQueue_MemAdvise(
    __dpctl_keep DPCTLSyclQueueRef QRef,
    const void* Ptr,
    size_t Count,
    int Advice
    )

C-API wrapper for sycl::queue::mem_advise, the function waits on an event till the operation completes.

Parameters:

QRef

An opaque pointer to the sycl queue.

Ptr

An USM pointer to memory.

Count

A number of bytes to prefetch.

Advice

Device-defined advice for the specified allocation. A value of 0 reverts the advice for Ptr to the default behavior.

DPCTL_API void
DPCTLQueue_Memcpy(
    __dpctl_keep const DPCTLSyclQueueRef QRef,
    void* Dest,
    const void* Src,
    size_t Count
    )

C-API wrapper for sycl::queue::memcpy, the function waits on an event till the memcpy operation completes.

Parameters:

QRef

An opaque pointer to the sycl queue.

Dest

An USM pointer to the destination memory.

Src

An USM pointer to the source memory.

Count

A number of bytes to copy.

DPCTL_API void
DPCTLQueue_Prefetch(
    __dpctl_keep DPCTLSyclQueueRef QRef,
    const void* Ptr,
    size_t Count
    )

C-API wrapper for sycl::queue::prefetch, the function waits on an event till the prefetch operation completes.

Parameters:

QRef

An opaque pointer to the sycl queue.

Ptr

An USM pointer to memory.

Count

A number of bytes to prefetch.

DPCTL_API DPCTLSyclEventRef
DPCTLQueue_SubmitNDRange(
    __dpctl_keep const DPCTLSyclKernelRef KRef,
    __dpctl_keep const DPCTLSyclQueueRef QRef,
    __dpctl_keep void** Args,
    __dpctl_keep const DPCTLKernelArgType* ArgTypes,
    size_t NArgs,
    __dpctl_keep const size_t gRange[3],
    __dpctl_keep const size_t lRange[3],
    size_t NDims,
    __dpctl_keep const DPCTLSyclEventRef* DepEvents,
    size_t NDepEvents
    )

Submits the kernel to the specified queue with the provided nd_range argument.

A wrapper over sycl::queue.submit(). The function takes an interoperability kernel, the kernel arguments, and a Sycl queue as input. The kernel is submitted as parallel_for(nd_range<NRange>, *unwrap(KRef)).

Todo sycl::buffer arguments are not supported yet.

Add support for id<Dims> WorkItemOffset

Parameters:

KRef

Opaque pointer to an OpenCL interoperability kernel wrapped inside a sycl::kernel.

QRef

Opaque pointer to the sycl::queue where the kernel will be enqueued.

Args

An array of void* pointers that represent the kernel arguments for the kernel.

ArgTypes

An array of DPCTLKernelArgType enum values that represent the type of each kernel argument.

NArgs

Size of Args.

gRange

Defines the overall dimension of the dispatch for the kernel. The array can have up to three dimensions.

lRange

Defines the iteration domain of a single work-group in a parallel dispatch. The array can have up to three dimensions.

NDims

The number of dimensions for both local and global ranges.

DepEvents

List of dependent DPCTLSyclEventRef objects (events) for the kernel. We call sycl::handler.depends_on for each of the provided events.

NDepEvents

Size of the DepEvents list.

Returns:

An opaque pointer to the sycl::event returned by the sycl::queue.submit() function.

DPCTL_API DPCTLSyclEventRef
DPCTLQueue_SubmitRange(
    __dpctl_keep const DPCTLSyclKernelRef KRef,
    __dpctl_keep const DPCTLSyclQueueRef QRef,
    __dpctl_keep void** Args,
    __dpctl_keep const DPCTLKernelArgType* ArgTypes,
    size_t NArgs,
    __dpctl_keep const size_t Range[3],
    size_t NRange,
    __dpctl_keep const DPCTLSyclEventRef* DepEvents,
    size_t NDepEvents
    )

Submits the kernel to the specified queue with the provided range argument.

A wrapper over sycl::queue.submit(). The function takes an interoperability kernel, the kernel arguments, and a Sycl queue as input. The kernel is submitted as parallel_for(range<NRange>, *unwrap(KRef)).

Todo sycl::buffer arguments are not supported yet.

Add support for id<Dims> WorkItemOffset

Parameters:

KRef

Opaque pointer to an OpenCL interoperability kernel wrapped inside a sycl::kernel.

QRef

Opaque pointer to the sycl::queue where the kernel will be enqueued.

Args

An array of void* pointers that represent the kernel arguments for the kernel.

ArgTypes

An array of DPCTLKernelArgType enum values that represent the type of each kernel argument.

NArgs

Size of Args and ArgTypes.

Range

Defines the overall dimension of the dispatch for the kernel. The array can have up to three dimensions.

NRange

Size of the gRange array.

DepEvents

List of dependent DPCTLSyclEventRef objects (events) for the kernel. We call sycl::handler.depends_on for each of the provided events.

NDepEvents

Size of the DepEvents list.

Returns:

An opaque pointer to the sycl::event returned by the sycl::queue.submit() function.

DPCTL_API void
DPCTLQueue_Wait(__dpctl_keep const DPCTLSyclQueueRef QRef)

Calls the sycl::queue.submit function to do a blocking wait on all enqueued tasks in the queue.

Parameters:

QRef

Opaque pointer to a sycl::queue.

DPCTL_C_EXTERN_C_BEGIN DPCTL_API __dpctl_give DPCTLSyclQueueRef
DPCTLQueueMgr_GetCurrentQueue()

Get the sycl::queue object that is currently activated for this thread.

Returns:

A copy of the current (top of the stack) sycl::queue is returned wrapped inside an opaque DPCTLSyclQueueRef pointer.

DPCTL_API size_t
DPCTLQueueMgr_GetNumActivatedQueues()

Get the number of activated queues not including the global or default queue.

Returns:

The number of activated queues.

DPCTL_API size_t
DPCTLQueueMgr_GetNumQueues(
    DPCTLSyclBackendType BETy,
    DPCTLSyclDeviceType DeviceTy
    )

Get the number of available queues for given backend and device type combination.

Parameters:

BETy

Type of Sycl backend.

DeviceTy

Type of Sycl device.

Returns:

The number of available queues.

DPCTL_API __dpctl_give DPCTLSyclQueueRef
DPCTLQueueMgr_GetQueue(
    DPCTLSyclBackendType BETy,
    DPCTLSyclDeviceType DeviceTy,
    size_t DNum
    )

Get a sycl::queue object of the specified type and device id.

Parameters:

BETy

A valid Sycl backend value.

DeviceTy

The type of Sycl device (sycl_device_type)

DNum

Device id for the device (defaults to 0)

Returns:

A copy of the sycl::queue corresponding to the device is returned wrapped inside a DPCTLSyclDeviceType pointer. A runtime_error exception is raised if no such device exists.

DPCTL_API __dpctl_give DPCTLSyclQueueRef
DPCTLQueueMgr_GetQueueFromContextAndDevice(
    __dpctl_keep DPCTLSyclContextRef CRef,
    __dpctl_keep DPCTLSyclDeviceRef DRef
    )

Creates a new instance of SYCL queue from SYCL context and SYCL device.

The instance is not placed into queue manager. The user assumes ownership of the queue reference and should deallocate it using DPCTLQueue_Delete.

Parameters:

CRef

Sycl context reference

DRef

Sycl device reference

Returns:

A copy of the sycl::queue created from given context and device references.

DPCTL_API bool
DPCTLQueueMgr_IsCurrentQueue(__dpctl_keep const DPCTLSyclQueueRef QRef)

Returns True if the passed in queue and the current queue are the same, else returns False.

Parameters:

QRef

An opaque pointer to a sycl::queue.

Returns:

True or False depending on whether the QRef argument is the same as the currently activated queue.

DPCTL_API void
DPCTLQueueMgr_PopQueue()

Pops the top of stack element from DPCTL’s stack of activated sycl::queue objects.

DPCTLPopSyclQueue only removes the reference from the DPCTL stack of sycl::queue objects. Any instance of the popped queue that were previously acquired by calling DPCTLPushSyclQueue() or DPCTLQueueMgr_GetCurrentQueue() needs to be freed separately. In addition, a runtime_error is thrown when the stack contains only one sycl::queue, i.e., the default queue.

DPCTL_API __dpctl_give DPCTLSyclQueueRef
DPCTLQueueMgr_PushQueue(
    DPCTLSyclBackendType BETy,
    DPCTLSyclDeviceType DeviceTy,
    size_t DNum
    )

Pushes a new sycl::queue object to the top of DPCTL’s thread-local stack of a “activated” queues, and returns a copy of the queue to caller.

The DPCTL queue manager maintains a thread-local stack of sycl::queue objects to facilitate nested parallelism. The sycl::queue at the top of the stack is termed as the currently activated queue, and is always the one returned by DPCTLQueueMgr_GetCurrentQueue(). DPCTLPushSyclQueueToStack creates a new sycl::queue corresponding to the specified device and pushes it to the top of the stack. A copy of the sycl::queue is returned to the caller wrapped inside the opaque DPCTLSyclQueueRef pointer. A runtime_error exception is thrown when a new sycl::queue could not be created for the specified device.

Parameters:

BETy

Type of Sycl backend.

DeviceTy

The type of Sycl device (sycl_device_type)

DNum

Device id for the device (defaults to 0)

Returns:

A copy of the sycl::queue that was pushed to the top of DPCTL’s stack of sycl::queue objects. Nullptr is returned if no such device exists.

DPCTL_API __dpctl_give DPCTLSyclQueueRef
DPCTLQueueMgr_SetAsDefaultQueue(
    DPCTLSyclBackendType BETy,
    DPCTLSyclDeviceType DeviceTy,
    size_t DNum
    )

Set the default DPCTL queue to the sycl::queue for the given backend and device type combination and return a DPCTLSyclQueueRef for that queue. If no queue was created Null is returned to caller.

Parameters:

BETy

Type of Sycl backend.

DeviceTy

The type of Sycl device (sycl_device_type)

DNum

Device id for the device

Returns:

A copy of the sycl::queue that was set as the new default queue. If no queue could be created then returns Null.

DPCTL_API __dpctl_give DPCTLSyclUSMRef
DPCTLaligned_alloc_device(
    size_t alignment,
    size_t size,
    __dpctl_keep const DPCTLSyclQueueRef QRef
    )

Create USM device memory.

Parameters:

alignment

Allocation’s byte alignment

size

Number of bytes to allocate

QRef

Sycl queue reference to use in allocation

Returns:

The pointer to USM device memory with requested alignment. On failure, returns nullptr.

DPCTL_API __dpctl_give DPCTLSyclUSMRef
DPCTLaligned_alloc_host(
    size_t alignment,
    size_t size,
    __dpctl_keep const DPCTLSyclQueueRef QRef
    )

Create USM host memory.

Parameters:

alignment

Allocation’s byte alignment

size

Number of bytes to allocate

QRef

Sycl queue reference to use in allocation

Returns:

The pointer to USM host memory with the requested alignment. On failure, returns nullptr.

DPCTL_API __dpctl_give DPCTLSyclUSMRef
DPCTLaligned_alloc_shared(
    size_t alignment,
    size_t size,
    __dpctl_keep const DPCTLSyclQueueRef QRef
    )

Create USM shared memory.

Parameters:

alignment

Allocation’s byte alignment

size

Number of bytes to allocate

QRef

Sycl queue reference to use in allocation

Returns:

The pointer to USM shared memory with the requested alignment. On failure, returns nullptr.

DPCTL_API void
DPCTLfree_with_context(
    __dpctl_take DPCTLSyclUSMRef MRef,
    __dpctl_keep const DPCTLSyclContextRef CRef
    )

Free USM memory.

DPCTL_API void
DPCTLfree_with_queue(
    __dpctl_take DPCTLSyclUSMRef MRef,
    __dpctl_keep const DPCTLSyclQueueRef QRef
    )

Free USM memory.

USM pointer must have been allocated using the same context as the one used to construct the queue.

Parameters:

MRef

USM pointer to free

QRef

Sycl queue reference to use.

DPCTL_API __dpctl_give DPCTLSyclUSMRef
DPCTLmalloc_device(
    size_t size,
    __dpctl_keep const DPCTLSyclQueueRef QRef
    )

Create USM device memory.

Parameters:

size

Number of bytes to allocate

QRef

Sycl queue reference to use in allocation

Returns:

The pointer to USM device memory. On failure, returns nullptr.

DPCTL_API __dpctl_give DPCTLSyclUSMRef
DPCTLmalloc_host(
    size_t size,
    __dpctl_keep const DPCTLSyclQueueRef QRef
    )

Create USM host memory.

Parameters:

size

Number of bytes to allocate

QRef

Sycl queue reference to use in allocation

Returns:

The pointer to USM host memory. On failure, returns nullptr.

DPCTL_C_EXTERN_C_BEGIN DPCTL_API __dpctl_give DPCTLSyclUSMRef
DPCTLmalloc_shared(
    size_t size,
    __dpctl_keep const DPCTLSyclQueueRef QRef
    )

Create USM shared memory.

Parameters:

size

Number of bytes to allocate

QRef

Sycl queue reference to use in allocation

Returns:

The pointer to USM shared memory. On failure, returns nullptr.

DPCTL_API DPCTLSyclDeviceRef
DPCTLUSM_GetPointerDevice(
    __dpctl_keep const DPCTLSyclUSMRef MRef,
    __dpctl_keep const DPCTLSyclContextRef CRef
    )

Get the device associated with USM pointer.

Parameters:

MRef

USM pointer

CRef

Sycl context reference associated with the pointer

Returns:

A DPCTLSyclDeviceRef pointer to the sycl device.

const DPCTL_API char*
DPCTLUSM_GetPointerType(
    __dpctl_keep const DPCTLSyclUSMRef MRef,
    __dpctl_keep const DPCTLSyclContextRef CRef
    )

Get pointer type.

Parameters:

MRef

USM Memory

CRef

Sycl context reference associated with the pointer

Returns:

“host”, “device”, “shared” or “unknown”