Device class helper functions

Overview

Helper functions for sycl::device objects that do not directly map to any sycl::device member function. More…

// typedefs

typedef struct DPCTLDeviceVector* DPCTLDeviceVectorRef;

// global functions

DPCTL_API DPCTLSyclContextRef
DPCTLDeviceMgr_GetCachedContext(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API __dpctl_give DPCTLDeviceVectorRef
DPCTLDeviceMgr_GetDevices(int device_identifier);

DPCTL_API size_t
DPCTLDeviceMgr_GetNumDevices(int device_identifier);

DPCTL_API int64_t
DPCTLDeviceMgr_GetRelativeId(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API void
DPCTLDeviceMgr_PrintDeviceInfo(__dpctl_keep const DPCTLSyclDeviceRef DRef);

DPCTL_API void
DPCTLDeviceVector_Clear(__dpctl_keep DPCTLDeviceVectorRef VRef);

__dpctl_give DPCTLDeviceVectorRef
DPCTLDeviceVector_Create();

DPCTL_API __dpctl_give DPCTLDeviceVectorRef
DPCTLDeviceVector_CreateFromArray(
    size_t len,
    __dpctl_keep DPCTLSyclDeviceRef* elems
    );

DPCTL_API void
DPCTLDeviceVector_Delete(__dpctl_take DPCTLDeviceVectorRef VRef);

DPCTL_API __dpctl_give DPCTLSyclDeviceRef
DPCTLDeviceVector_GetAt(
    __dpctl_keep DPCTLDeviceVectorRef VRef,
    size_t index
    );

DPCTL_API size_t
DPCTLDeviceVector_Size(__dpctl_keep DPCTLDeviceVectorRef VRef);

Detailed Documentation

Helper functions for sycl::device objects that do not directly map to any sycl::device member function.

Global Functions

DPCTL_API DPCTLSyclContextRef
DPCTLDeviceMgr_GetCachedContext(__dpctl_keep const DPCTLSyclDeviceRef DRef)

If the DPCTLSyclDeviceRef argument is a root device, then this function returns a cached default SYCL context for that device.

Parameters:

DRef

A pointer to a sycl::device that will be used to search an internal map containing a cached “default” sycl::context for the device.

Returns:

A DPCTLSyclContextRef associated with the DPCTLSyclDeviceRef argument passed to the function. If the DPCTLSyclDeviceRef is not found in the cache, then returns a nullptr.

DPCTL_API __dpctl_give DPCTLDeviceVectorRef
DPCTLDeviceMgr_GetDevices(int device_identifier)

Returns a pointer to a std::vector<sycl::DPCTLSyclDeviceRef> containing the set of DPCTLSyclDeviceRef pointers matching the passed in device_identifier bit flag.

The device_identifier can be a combination of DPCTLSyclBackendType and DPCTLSyclDeviceType bit flags. The function returns all devices that match the specified bit flags. For example,

// Returns all opencl devices
DPCTLDeviceMgr_GetDevices(DPCTLSyclBackendType::DPCTL_OPENCL);

// Returns all opencl gpu devices
DPCTLDeviceMgr_GetDevices(
    DPCTLSyclBackendType::DPCTL_OPENCL|DPCTLSyclDeviceType::DPCTL_GPU);

// Returns all gpu devices
DPCTLDeviceMgr_GetDevices(DPCTLSyclDeviceType::DPCTL_GPU);

Parameters:

device_identifier

A bitflag that can be any combination of DPCTLSyclBackendType and DPCTLSyclDeviceType enum values.

Returns:

A DPCTLDeviceVectorRef containing DPCTLSyclDeviceRef objects that match the device identifier bit flags.

DPCTL_API size_t
DPCTLDeviceMgr_GetNumDevices(int device_identifier)

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

Parameters:

device_identifier

Identifies a device using a combination of DPCTLSyclBackendType and DPCTLSyclDeviceType enum values. The argument can be either one of the enum values or a bitwise OR-ed combination.

Returns:

The number of available devices satisfying the condition specified by the device_identifier bit flag.

DPCTL_API int64_t
DPCTLDeviceMgr_GetRelativeId(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Gives the index of the given device in the vector returned get_devices for the platform associated with DRef for the device type of DRef.

Parameters:

DRef

A DPCTLSyclDeviceRef opaque pointer.

DPCTL_API void
DPCTLDeviceMgr_PrintDeviceInfo(__dpctl_keep const DPCTLSyclDeviceRef DRef)

Prints out the info::deivice attributes for the device that are currently supported by dpctl.

Parameters:

DRef

A DPCTLSyclDeviceRef opaque pointer.

DPCTL_API void
DPCTLDeviceVector_Clear(__dpctl_keep DPCTLDeviceVectorRef VRef)

Delete all the elements of the std::vector.

Parameters:

VRef

Opaque pointer to a vector.

__dpctl_give DPCTLDeviceVectorRef
DPCTLDeviceVector_Create()

Create an opaque pointer to a std::vector of opaque pointers wrapping the SYCL data type.

Returns:

Returns a new opaque pointer to a vector.

DPCTL_API __dpctl_give DPCTLDeviceVectorRef
DPCTLDeviceVector_CreateFromArray(
    size_t len,
    __dpctl_keep DPCTLSyclDeviceRef* elems
    )

Create an opaque pointer to a std::vector created from the input raw array. The elements of the input array are deep copied before inserting the copies into the vector.

Parameters:

len

Number of elements in the input array.

elems

A C array whose elements will be copied into the returned vector.

Returns:

Returns a new opaque pointer to a vector.

DPCTL_API void
DPCTLDeviceVector_Delete(__dpctl_take DPCTLDeviceVectorRef VRef)

Delete all elements in the vector and then delete the vector.

Parameters:

VRef

Opaque pointer to a vector to be deleted.

DPCTL_API __dpctl_give DPCTLSyclDeviceRef
DPCTLDeviceVector_GetAt(
    __dpctl_keep DPCTLDeviceVectorRef VRef,
    size_t index
    )

Returns the element at the specified index.

Parameters:

VRef

Opaque pointer to a vector.

index

The index postion of the element to be returned.

Returns:

The element at the specified postion, if the index position is out of bounds then a nullptr is returned.

DPCTL_API size_t
DPCTLDeviceVector_Size(__dpctl_keep DPCTLDeviceVectorRef VRef)

Returns the number of elements in the vector.

Parameters:

VRef

Opaque pointer to a vector.

Returns:

The current size of the vector.