SYCL interoperability API

Overview

API extensions to interact with the underlying SYCL run-time. More…

// namespaces

namespace dnnl::graph::sycl_interop;

// typedefs

typedef void* (*dnnl_graph_sycl_allocate_f)(
    size_t size,
    size_t alignment,
    const void *dev,
    const void *context
    );

typedef void (*dnnl_graph_sycl_deallocate_f)(
    void *buf,
    const void *dev,
    const void *context,
    void *event
    );

// global functions

dnnl_status_t DNNL_API dnnl_graph_sycl_interop_allocator_create(
    dnnl_graph_allocator_t* allocator,
    dnnl_graph_sycl_allocate_f sycl_malloc,
    dnnl_graph_sycl_deallocate_f sycl_free
    );

dnnl_status_t DNNL_API dnnl_graph_sycl_interop_make_engine_with_allocator(
    dnnl_engine_t* engine,
    const void* device,
    const void* context,
    const_dnnl_graph_allocator_t alloc
    );

dnnl_status_t DNNL_API dnnl_graph_sycl_interop_compiled_partition_execute(
    const_dnnl_graph_compiled_partition_t compiled_partition,
    dnnl_stream_t stream,
    size_t num_inputs,
    const_dnnl_graph_tensor_t* inputs,
    size_t num_outputs,
    const_dnnl_graph_tensor_t* outputs,
    const void* deps,
    void* sycl_event
    );

Detailed Documentation

API extensions to interact with the underlying SYCL run-time.

Typedefs

typedef void* (*dnnl_graph_sycl_allocate_f)(
    size_t size,
    size_t alignment,
    const void *dev,
    const void *context
    )

Allocation call-back function interface for SYCL.

SYCL allocator should be used for SYCL runtime and host allocator should be used for non-SYCL. The call-back should return a USM device memory pointer.

typedef void (*dnnl_graph_sycl_deallocate_f)(
    void *buf,
    const void *dev,
    const void *context,
    void *event
    )

Deallocation call-back function interface for SYCL.

SYCL allocator should be used for SYCL runtime and host allocator should be used for non-SYCL. The call-back should deallocate a USM device memory returned by dnnl_graph_sycl_allocate_f.

Global Functions

dnnl_status_t DNNL_API dnnl_graph_sycl_interop_allocator_create(
    dnnl_graph_allocator_t* allocator,
    dnnl_graph_sycl_allocate_f sycl_malloc,
    dnnl_graph_sycl_deallocate_f sycl_free
    )

Creates an allocator with the given allocation and deallocation call-back function pointers.

Parameters:

allocator

Output allocator

sycl_malloc

A pointer to SYCL malloc function

sycl_free

A pointer to SYCL free function

Returns:

dnnl_success on success and a status describing the error otherwise.

dnnl_status_t DNNL_API dnnl_graph_sycl_interop_make_engine_with_allocator(
    dnnl_engine_t* engine,
    const void* device,
    const void* context,
    const_dnnl_graph_allocator_t alloc
    )

This API is a supplement for existing onednn engine API.

dnnl_status_t DNNL_API dnnl_graph_sycl_interop_compiled_partition_execute(
    const_dnnl_graph_compiled_partition_t compiled_partition,
    dnnl_stream_t stream,
    size_t num_inputs,
    const_dnnl_graph_tensor_t* inputs,
    size_t num_outputs,
    const_dnnl_graph_tensor_t* outputs,
    const void* deps,
    void* sycl_event
    )

Execute a compiled partition with sycl runtime.

Parameters:

compiled_partition

The handle of target compiled_partition.

stream

The stream used for execution

num_inputs

The number of input tensors

inputs

A list of input tensors

num_outputs

The number of output tensors

outputs

A non-empty list of output tensors

deps

Optional handle of list with sycl::event dependencies.

sycl_event

The handle of sycl event.

Returns:

dnnl_success on success and a status describing the error otherwise.