USM Interface

Overview

// global functions

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_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
    );

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

Detailed Documentation

Global Functions

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.

Parameters:

MRef

USM pointer to free

CRef

Sycl context reference to use.

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_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.

DPCTL_API DPCTLSyclUSMType
DPCTLUSM_GetPointerType(
    __dpctl_keep const DPCTLSyclUSMRef MRef,
    __dpctl_keep const DPCTLSyclContextRef CRef
    )

Returns the USM allocator type for a pointer.

Parameters:

MRef

USM allocated pointer

CRef

Sycl context reference associated with the pointer

Returns:

DPCTLSyclUSMType enum value indicating if the pointer is of USM type “shared”, “host”, or “device”.