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.
Member Variables
- std::unique_ptr< instruction_graph_generator_detail:: generator_impl> m_impl
Member Function Overview
- compile(const abstract_command & cmd) → void
- instruction_graph_generator(const task_manager & tm, size_t num_nodes, node_id local_nid, const system_info & system, instruction_graph & idag, delegate * dlg = nullptr, instruction_recorder * recorder = nullptr, const policy_set & policy = default_policy_set()) → explicit
- instruction_graph_generator(const instruction_graph_generator &)
- instruction_graph_generator(instruction_graph_generator &&)
- notify_buffer_created(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) → void
- notify_buffer_destroyed(buffer_id bid) → void
- notify_host_object_created(host_object_id hoid, bool owns_instance) → void
- notify_host_object_destroyed(host_object_id hoid) → void
- operator=(const instruction_graph_generator &) → instruction_graph_generator &
- operator=(instruction_graph_generator &&) → instruction_graph_generator &
- ~instruction_graph_generator()
- default_policy_set() → static constexpr policy_set
Member Functions
¶void compile(const abstract_command& cmd)
void compile(const abstract_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.
Parameters
- const abstract_command& cmd
¶explicit instruction_graph_generator(
const task_manager& tm,
size_t num_nodes,
node_id local_nid,
const system_info& system,
instruction_graph& idag,
delegate* dlg = nullptr,
instruction_recorder* recorder = nullptr,
const policy_set& policy =
default_policy_set())
explicit instruction_graph_generator(
const task_manager& tm,
size_t num_nodes,
node_id local_nid,
const system_info& system,
instruction_graph& idag,
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.
Parameters
- const task_manager& tm
- size_t num_nodes
- node_id local_nid
- const system_info& system
- instruction_graph& idag
- delegate* dlg = nullptr
- instruction_recorder* recorder = nullptr
- const policy_set& policy = default_policy_set()
¶instruction_graph_generator(
const instruction_graph_generator&)
instruction_graph_generator(
const instruction_graph_generator&)
Parameters
- const instruction_graph_generator&
¶instruction_graph_generator(
instruction_graph_generator&&)
instruction_graph_generator(
instruction_graph_generator&&)
Parameters
¶void notify_buffer_created(
buffer_id bid,
const range<3>& range,
size_t elem_size,
size_t elem_align,
allocation_id user_allocation_id)
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.
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)
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).
Parameters
- buffer_id bid
- const std::string& name
¶void notify_buffer_destroyed(buffer_id bid)
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.
Parameters
- buffer_id bid
¶void notify_host_object_created(
host_object_id hoid,
bool owns_instance)
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.
Parameters
- host_object_id hoid
- bool owns_instance
¶void notify_host_object_destroyed(
host_object_id hoid)
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
.
Parameters
- host_object_id hoid
¶instruction_graph_generator& operator=(
const instruction_graph_generator&)
instruction_graph_generator& operator=(
const instruction_graph_generator&)
Parameters
- const instruction_graph_generator&
¶instruction_graph_generator& operator=(
instruction_graph_generator&&)
instruction_graph_generator& operator=(
instruction_graph_generator&&)
Parameters
¶~instruction_graph_generator()
~instruction_graph_generator()
¶static constexpr policy_set default_policy_set()
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).