Class GraphExecutable

Inheritance Relationships

Derived Type

Class Documentation

class mgb::cg::GraphExecutable

executable used internally for cg

Subclassed by mgb::cg::OperatorNodeBase

Public Types

using ExecDependencyArray = std::vector<std::unique_ptr<ExecDependency>>

Public Functions

void execute(ExecEnv &env) = 0
void record_execute_deps(ExecDependencyArray &record)

append the dependencies into record

Some deps might be moved; the original operator should not be used again.

The default implementation does nothing

Protected Functions

~GraphExecutable() = default
class ExecDependency

dependency for execute()

This is used when comp_node_seq_recorder_level is 2: the objects needed by kernels in execute() should be moved to this object and the parent operator class would later be destructed.

Public Functions

~ExecDependency() = default
bool has_runtime_check() const

if this returns true, do_runtime_check() would be called before each run

void do_runtime_check()
class ExecEnv

operator execution environment

When GraphExecutable::execute() is called, it should add tasks into the ExecEnv. The tasks added to ExecEnv would be invoked by a scheduler to perform actual computing.

Operator code usually only calls dispatch_on_comp_node()

Note: The ExecEnv class exists as an abstraction layer for controlling asynchronous kernel dispatching behavior. CUDA has a limited task queue so we have to use a dedicated CPU thread for each CUDA stream (it can be treated as a blocking queue). But for CPU we have our own unlimited dispatch queue so the ExecEnv can be synchonous.

Public Types

using Task = thin_function<void()>

Public Functions

void dispatch_on_comp_node(CompNode cn, Task &&task) = 0

add a task to the queue corresponding to given comp node

void dispatch_on_comp_node_with_mask(CompNode cn, Task &&task, ExecutionMask *mask) = 0

like dispatch_on_comp_node, but with specific mask other than current opr mask

void pause_exec() = 0

pause execution on all threads if there are async dispatch threads

This is currently only used by memory defragmenter.

void resume_exec() = 0

resume execution (cancel previous pause_exec())

Protected Functions

~ExecEnv() noexcept = default