Engine is abstraction of a computational device: a CPU, a specific GPU card in the system, etc. Most primitives are created to execute computations on one specific engine. The only exceptions are reorder primitives that transfer data between two different engines.

struct dnnl::engine

An execution engine.

Public Types

enum kind

Kinds of engines.


enumerator any

An unspecified engine.

enumerator cpu

CPU engine.

enumerator gpu

GPU engine.

Public Functions


Constructs an empty engine. An empty engine cannot be used in any operations.

engine(kind kind, size_t index)

Constructs an engine.

  • kind: The kind of engine to construct.

  • index: The index of the engine. Must be less than the value returned by get_count() for this particular kind of engine.

engine(kind kind, const cl::sycl::device &dev, const cl::sycl::context &ctx)

Constructs an engine from SYCL device and context objects.

  • kind: The kind of engine to construct.

  • dev: SYCL device.

  • ctx: SYCL context.

kind get_kind() const

Returns the kind of the engine.


The kind of the engine.

cl::sycl::context get_sycl_context() const

Returns the underlying SYCL context object.

cl::sycl::device get_sycl_device() const

Returns the underlying SYCL device object.

Public Static Functions

size_t get_count(kind kind)

Returns the number of engines of a certain kind.


The number of engines of the specified kind.

  • kind: The kind of engines to count.