Contents

class

SushiBLAS::Engine

Owns one task graph with its scratch pool, recorder, tensor factory and random stream, and runs the graph.

Declared in
include/SushiBLAS/engine.hpp

See also

include/SushiBLAS/README.md

Public member functions

explicit Engine(SushiRuntime::Execution::RuntimeContext &context, Core::Layout layout=Core::Layout::ROW_MAJOR)

Builds an engine on a runtime context.

Parameters

context

Must outlive the engine and every tensor it creates.

layout

The memory layout of tensors this engine creates.

Engine(const Engine &)=delete
Engine & operator=(const Engine &)=delete
Engine(Engine &&)=delete
Engine & operator=(Engine &&)=delete
~Engine()=default
TaskRecorder & get_recorder() noexcept

Returns the recorder every operation view of this engine records through.

TensorFactory & get_tensor_factory() noexcept

Returns the factory create_tensor forwards to.

RngStream & get_rng() noexcept

Returns the random stream every RandomOps view of this engine draws from.

See also

include/SushiBLAS/engine/README.md

ScratchPool & get_scratch_pool() noexcept

Returns the pool tasks recorded through this engine lease device scratch from.

See also

include/SushiBLAS/engine/README.md

SushiRuntime::Execution::RuntimeContext & get_context() noexcept

Returns the runtime context the engine was built on.

void set_mode(ExecutionMode mode) noexcept

Sets the execution mode of every operation recorded from now on.

ExecutionMode get_mode() const noexcept

Returns the execution mode operations are recorded under.

Core::Layout get_layout() const noexcept

Returns the memory layout of tensors this engine creates.

void execute()

Compiles the graph recorded through get_recorder(), runs it and returns when every task has finished.

Precondition

No thread is recording on this engine.

Tensor create_tensor(std::initializer_list< int64_t > dims, Core::DataType dtype=Core::DataType::FLOAT32, SushiRuntime::API::Residency residency=SushiRuntime::API::Residency::Shared, std::size_t device_index=0)

Creates a tensor from a brace list of dimensions.

Parameters

device_index

Device queue that owns the allocation.

Returns

A tensor without storage when a dimension is 0.

Exceptions

std::runtime_error

as TensorFactory::create states.

Tensor create_tensor(SushiRuntime::span< const int64_t > dims, Core::DataType dtype=Core::DataType::FLOAT32, SushiRuntime::API::Residency residency=SushiRuntime::API::Residency::Shared, std::size_t device_index=0)

Creates a tensor whose dimensions are known only at run time.

Parameters

device_index

Device queue that owns the allocation.

Returns

A tensor without storage when a dimension is 0.

Exceptions

std::runtime_error

as TensorFactory::create states.