Skip to main content

class instruction_graph_generator

Declaration

class instruction_graph_generator { /* full declaration omitted */ };

Description

Tracks the node-local state of buffers and host objects, receives commands at node granularity and emits instructions to allocate memory, establish coherence between devices and distribute work among the devices on the local system.

Declared at: include/instruction_graph_generator.h:39

Member Variables

std::unique_ptr< instruction_graph_generator_detail:: generator_impl> m_impl

Member Function Overview

Member Functions

scheduling_hint anticipate(const command& cmd)

Description

Inform the graph generator that a command is to follow in the future, without immediately generating any instructions for it. The scheduler will use this to inject knowledge about future allocation sizes into the graph generator in order to avoid buffer resizes.

Declared at: include/instruction_graph_generator.h:126

Parameters

const command& cmd

void compile(const command& cmd)

Description

Compiles a command-graph node into a set of instructions, which are inserted into the shared instruction graph, and updates tracking structures.

Declared at: include/instruction_graph_generator.h:129

Parameters

const command& cmd

explicit instruction_graph_generator(
    size_t num_nodes,
    node_id local_nid,
    const system_info& system,
    instruction_graph& idag,
    instruction_graph_generator::delegate* dlg =
        nullptr,
    instruction_recorder* recorder = nullptr,
    const policy_set& policy =
        default_policy_set())

Description

Instruction graph generation requires information about the target system. num_nodes and local_nid affect the generation of communication instructions and reductions, and system is used to determine work assignment, memory allocation and data migration between memories. Generated instructions are inserted into (and subsequently owned by) the provided idag, and if dlg is provided, it is notified about any newly created instructions and outbound pilots. If and only if a recorder is present, the generator will collect debug information about each generated instruction and pass it to the recorder. Set this to nullptr in production code in order to avoid a performance penalty. Specify a non-default policy to influence what user-errors are detected at runtime and how they are reported. The default is is to throw exceptions which catch errors early in tests, but users of this class will want to ease these settings. Any policy set to a value other than error_policy::ignore will have a performance penalty.

Declared at: include/instruction_graph_generator.h:95

Parameters

size_t num_nodes
node_id local_nid
const system_info& system
instruction_graph& idag
instruction_graph_generator::delegate* dlg = nullptr
instruction_recorder* recorder = nullptr
const policy_set& policy = default_policy_set()

instruction_graph_generator(
    const instruction_graph_generator&)

Declared at: include/instruction_graph_generator.h:98

Parameters

const instruction_graph_generator&

instruction_graph_generator(
    instruction_graph_generator&&)

Declared at: include/instruction_graph_generator.h:99

Parameters

instruction_graph_generator&&

void notify_buffer_created(
    buffer_id bid,
    const range<3>& range,
    size_t elem_size,
    size_t elem_align,
    allocation_id user_allocation_id)

Description

Begin tracking local data distribution and dependencies on the buffer with id bid. Allocations are made lazily on first access. Passing user_allocation_id != null_allocation_id means that the buffer is considered coherent in user memory and data will be lazily copied from that allocation when read from host tasks or device kernels.

Declared at: include/instruction_graph_generator.h:109

Parameters

buffer_id bid
const range<3>& range
size_t elem_size
size_t elem_align
allocation_id user_allocation_id

void notify_buffer_debug_name_changed(
    buffer_id bid,
    const std::string& name)

Description

Changing an existing buffer's debug name causes all future instructions to refer to that buffer by the new name (if a recorder is present).

Declared at: include/instruction_graph_generator.h:112

Parameters

buffer_id bid
const std::string& name

void notify_buffer_destroyed(buffer_id bid)

Description

End tracking buffer with the id bid. Emits free_instructions for all current allocations of that buffer.

Declared at: include/instruction_graph_generator.h:115

Parameters

buffer_id bid

void notify_host_object_created(
    host_object_id hoid,
    bool owns_instance)

Description

Begin tracking dependencies on the host object with id hoid. If owns_instance is true, a destroy_host_object_instruction will be emitted when destroy_host_object is subsequently called.

Declared at: include/instruction_graph_generator.h:119

Parameters

host_object_id hoid
bool owns_instance

void notify_host_object_destroyed(
    host_object_id hoid)

Description

End tracking the host object with id hoid. Emits destroy_host_object_instruction if create_host_object was called with owns_instance == true.

Declared at: include/instruction_graph_generator.h:122

Parameters

host_object_id hoid

instruction_graph_generator& operator=(
    const instruction_graph_generator&)

Declared at: include/instruction_graph_generator.h:100

Parameters

const instruction_graph_generator&

instruction_graph_generator& operator=(
    instruction_graph_generator&&)

Declared at: include/instruction_graph_generator.h:101

Parameters

instruction_graph_generator&&

~instruction_graph_generator()

Declared at: include/instruction_graph_generator.h:103


static constexpr policy_set default_policy_set()

Description

Default-constructs a policy_set - this must be a function because we can't use the implicit default constructor of policy_set, which has member initializers, within its surrounding class (Clang diagnostic).

Declared at: include/instruction_graph_generator.h:134