dace.codegen.instrumentation package¶
Submodules¶
dace.codegen.instrumentation.gpu_events module¶
-
class
dace.codegen.instrumentation.gpu_events.
GPUEventProvider
¶ Bases:
dace.codegen.instrumentation.provider.InstrumentationProvider
Timing instrumentation that reports GPU/copy time using CUDA/HIP events.
-
on_node_begin
(sdfg, state, node, outer_stream, inner_stream, global_stream)¶ Event called at the beginning of generating a node. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param node: The generated node. :param outer_stream: Code generator for the internal code before
the scope is opened.Parameters: - inner_stream – Code generator for the internal code within the scope (at the beginning).
- global_stream – Code generator for global (external) code.
-
on_node_end
(sdfg, state, node, outer_stream, inner_stream, global_stream)¶ Event called at the end of generating a node. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param node: The generated node. :param outer_stream: Code generator for the internal code after
the scope is closed.Parameters: - inner_stream – Code generator for the internal code within the scope (at the end).
- global_stream – Code generator for global (external) code.
-
on_scope_entry
(sdfg, state, node, outer_stream, inner_stream, global_stream)¶ Event called at the beginning of a scope (on generating an EntryNode). :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param node: The EntryNode object from which code is generated. :param outer_stream: Code generator for the internal code before
the scope is opened.Parameters: - inner_stream – Code generator for the internal code within the scope (at the beginning).
- global_stream – Code generator for global (external) code.
-
on_scope_exit
(sdfg, state, node, outer_stream, inner_stream, global_stream)¶ Event called at the end of a scope (on generating an ExitNode). :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param node: The ExitNode object from which code is generated. :param outer_stream: Code generator for the internal code after
the scope is closed.Parameters: - inner_stream – Code generator for the internal code within the scope (at the end).
- global_stream – Code generator for global (external) code.
-
on_sdfg_begin
(sdfg, local_stream, global_stream)¶ Event called at the beginning of SDFG code generation. :param sdfg: The generated SDFG object. :param local_stream: Code generator for the in-function code. :param global_stream: Code generator for global (external) code.
-
on_state_begin
(sdfg, state, local_stream, global_stream)¶ Event called at the beginning of SDFG state code generation. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param local_stream: Code generator for the in-function code. :param global_stream: Code generator for global (external) code.
-
on_state_end
(sdfg, state, local_stream, global_stream)¶ Event called at the end of SDFG state code generation. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param local_stream: Code generator for the in-function code. :param global_stream: Code generator for global (external) code.
-
dace.codegen.instrumentation.papi module¶
Implements the PAPI counter performance instrumentation provider. Used for collecting CPU performance counters.
-
class
dace.codegen.instrumentation.papi.
PAPIInstrumentation
¶ Bases:
dace.codegen.instrumentation.provider.InstrumentationProvider
Instrumentation provider that reports CPU performance counters using the PAPI library.
-
configure_papi
()¶
-
get_unique_number
()¶
-
static
has_surrounding_perfcounters
(node, dfg: dace.sdfg.state.StateGraphView)¶ Returns true if there is a possibility that this node is part of a section that is profiled.
-
on_consume_entry
(sdfg, state, node, outer_stream, inner_stream)¶
-
on_copy_begin
(sdfg, state, src_node, dst_node, edge, local_stream, global_stream, copy_shape, src_strides, dst_strides)¶ Event called at the beginning of generating a copy operation. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param src_node: The source node of the copy. :param dst_node: The destination node of the copy. :param edge: An edge in the memlet path of the copy. :param local_stream: Code generator for the internal code. :param global_stream: Code generator for global (external) code. :param copy_shape: Tuple representing the shape of the copy. :param src_strides: Element-skipping strides for each dimension of the copied source. :param dst_strides: Element-skipping strides for each dimension of the copied destination.
-
on_copy_end
(sdfg, state, src_node, dst_node, edge, local_stream, global_stream)¶ Event called at the end of generating a copy operation. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param src_node: The source node of the copy. :param dst_node: The destination node of the copy. :param edge: An edge in the memlet path of the copy. :param local_stream: Code generator for the internal code. :param global_stream: Code generator for global (external) code.
-
on_map_entry
(sdfg, state, node, outer_stream, inner_stream)¶
-
on_node_begin
(sdfg, state, node, outer_stream, inner_stream, global_stream)¶ Event called at the beginning of generating a node. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param node: The generated node. :param outer_stream: Code generator for the internal code before
the scope is opened.Parameters: - inner_stream – Code generator for the internal code within the scope (at the beginning).
- global_stream – Code generator for global (external) code.
-
on_node_end
(sdfg, state, node, outer_stream, inner_stream, global_stream)¶ Event called at the end of generating a node. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param node: The generated node. :param outer_stream: Code generator for the internal code after
the scope is closed.Parameters: - inner_stream – Code generator for the internal code within the scope (at the end).
- global_stream – Code generator for global (external) code.
-
on_scope_entry
(sdfg, state, node, outer_stream, inner_stream, global_stream)¶ Event called at the beginning of a scope (on generating an EntryNode). :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param node: The EntryNode object from which code is generated. :param outer_stream: Code generator for the internal code before
the scope is opened.Parameters: - inner_stream – Code generator for the internal code within the scope (at the beginning).
- global_stream – Code generator for global (external) code.
-
on_scope_exit
(sdfg, state, node, outer_stream, inner_stream, global_stream)¶ Event called at the end of a scope (on generating an ExitNode). :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param node: The ExitNode object from which code is generated. :param outer_stream: Code generator for the internal code after
the scope is closed.Parameters: - inner_stream – Code generator for the internal code within the scope (at the end).
- global_stream – Code generator for global (external) code.
-
on_sdfg_begin
(sdfg, local_stream, global_stream)¶ Event called at the beginning of SDFG code generation. :param sdfg: The generated SDFG object. :param local_stream: Code generator for the in-function code. :param global_stream: Code generator for global (external) code.
-
on_sdfg_end
(sdfg, local_stream, global_stream)¶ Event called at the end of SDFG code generation. :param sdfg: The generated SDFG object. :param local_stream: Code generator for the in-function code. :param global_stream: Code generator for global (external) code.
-
on_state_begin
(sdfg, state, local_stream, global_stream)¶ Event called at the beginning of SDFG state code generation. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param local_stream: Code generator for the in-function code. :param global_stream: Code generator for global (external) code.
-
static
perf_counter_end_measurement_string
(unified_id)¶
-
perf_counter_start_measurement_string
(unified_id: int, iteration: str, core_str: str = 'PAPI_thread_id()')¶
-
perf_counter_string
()¶ Creates a performance counter template string.
-
static
perf_counter_string_from_string_list
(counterlist: [<class 'str'>])¶ Creates a performance counter typename string.
-
static
perf_get_supersection_start_string
(node, dfg, unified_id)¶
-
static
perf_section_start_string
(unified_id: int, size: str, in_size: str, core_str: str = 'PAPI_thread_id()')¶
-
static
perf_supersection_start_string
(unified_id)¶
-
perf_whitelist_schedules
= [<ScheduleType.CPU_Multicore: 4>, <ScheduleType.Sequential: 2>]¶
-
static
should_instrument_entry
(map_entry: dace.sdfg.nodes.EntryNode) → bool¶ Returns True if this entry node should be instrumented.
-
-
class
dace.codegen.instrumentation.papi.
PAPIUtils
¶ Bases:
object
General-purpose utilities for working with PAPI.
-
static
accumulate_byte_movement
(outermost_node, node, dfg: dace.sdfg.state.StateGraphView, sdfg, state_id)¶
-
static
all_maps
(map_entry: dace.sdfg.nodes.EntryNode, dfg: dace.sdfg.graph.SubgraphView) → List[dace.sdfg.nodes.EntryNode]¶ Returns all scope entry nodes within a scope entry.
-
static
available_counters
() → Dict[str, int]¶ Returns the available PAPI counters on this machine. Only works on *nix based systems with
grep
andpapi-tools
installed. :return: A set of available PAPI counters in the form of a dictionarymapping from counter name to the number of native hardware events.
-
static
get_iteration_count
(map_entry: dace.sdfg.nodes.MapEntry, mapvars: dict)¶ Get the number of iterations for this map, allowing other variables as bounds.
-
static
get_memlet_byte_size
(sdfg: dace.sdfg.sdfg.SDFG, memlet: dace.memlet.Memlet)¶ Returns the memlet size in bytes, depending on its data type. :param sdfg: The SDFG in which the memlet resides. :param memlet: Memlet to return size in bytes. :return: The size as a symbolic expression.
-
static
get_memory_input_size
(node, sdfg, state_id) → str¶
-
static
get_out_memlet_costs
(sdfg: dace.sdfg.sdfg.SDFG, state_id: int, node: dace.sdfg.nodes.Node, dfg: dace.sdfg.state.StateGraphView)¶
-
static
get_parents
(outermost_node: dace.sdfg.nodes.Node, node: dace.sdfg.nodes.Node, sdfg: dace.sdfg.sdfg.SDFG, state_id: int) → List[dace.sdfg.nodes.Node]¶
-
static
get_tasklet_byte_accesses
(tasklet: dace.sdfg.nodes.CodeNode, dfg: dace.sdfg.state.StateGraphView, sdfg: dace.sdfg.sdfg.SDFG, state_id: int) → str¶ Get the amount of bytes processed by tasklet. The formula is sum(inedges * size) + sum(outedges * size)
-
static
is_papi_used
(sdfg: dace.sdfg.sdfg.SDFG) → bool¶ Returns True if any of the SDFG elements includes PAPI counter instrumentation.
-
static
reduce_iteration_count
(begin, end, step, rparams: dict)¶
-
static
dace.codegen.instrumentation.perfdb module¶
dace.codegen.instrumentation.provider module¶
-
class
dace.codegen.instrumentation.provider.
InstrumentationProvider
¶ Bases:
object
Instrumentation provider for SDFGs, states, scopes, and memlets. Emits code on event.
-
extensions
()¶
-
static
get_provider_mapping
() → Dict[dace.dtypes.InstrumentationType, Type[dace.codegen.instrumentation.provider.InstrumentationProvider]]¶ Returns a dictionary that maps instrumentation types to provider class types, given the currently-registered extensions of this class.
-
on_copy_begin
(sdfg, state, src_node, dst_node, edge, local_stream, global_stream, copy_shape, src_strides, dst_strides)¶ Event called at the beginning of generating a copy operation. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param src_node: The source node of the copy. :param dst_node: The destination node of the copy. :param edge: An edge in the memlet path of the copy. :param local_stream: Code generator for the internal code. :param global_stream: Code generator for global (external) code. :param copy_shape: Tuple representing the shape of the copy. :param src_strides: Element-skipping strides for each dimension of the copied source. :param dst_strides: Element-skipping strides for each dimension of the copied destination.
-
on_copy_end
(sdfg, state, src_node, dst_node, edge, local_stream, global_stream)¶ Event called at the end of generating a copy operation. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param src_node: The source node of the copy. :param dst_node: The destination node of the copy. :param edge: An edge in the memlet path of the copy. :param local_stream: Code generator for the internal code. :param global_stream: Code generator for global (external) code.
-
on_node_begin
(sdfg, state, node, outer_stream, inner_stream, global_stream)¶ Event called at the beginning of generating a node. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param node: The generated node. :param outer_stream: Code generator for the internal code before
the scope is opened.Parameters: - inner_stream – Code generator for the internal code within the scope (at the beginning).
- global_stream – Code generator for global (external) code.
-
on_node_end
(sdfg, state, node, outer_stream, inner_stream, global_stream)¶ Event called at the end of generating a node. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param node: The generated node. :param outer_stream: Code generator for the internal code after
the scope is closed.Parameters: - inner_stream – Code generator for the internal code within the scope (at the end).
- global_stream – Code generator for global (external) code.
-
on_scope_entry
(sdfg, state, node, outer_stream, inner_stream, global_stream)¶ Event called at the beginning of a scope (on generating an EntryNode). :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param node: The EntryNode object from which code is generated. :param outer_stream: Code generator for the internal code before
the scope is opened.Parameters: - inner_stream – Code generator for the internal code within the scope (at the beginning).
- global_stream – Code generator for global (external) code.
-
on_scope_exit
(sdfg, state, node, outer_stream, inner_stream, global_stream)¶ Event called at the end of a scope (on generating an ExitNode). :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param node: The ExitNode object from which code is generated. :param outer_stream: Code generator for the internal code after
the scope is closed.Parameters: - inner_stream – Code generator for the internal code within the scope (at the end).
- global_stream – Code generator for global (external) code.
-
on_sdfg_begin
(sdfg, local_stream, global_stream)¶ Event called at the beginning of SDFG code generation. :param sdfg: The generated SDFG object. :param local_stream: Code generator for the in-function code. :param global_stream: Code generator for global (external) code.
-
on_sdfg_end
(sdfg, local_stream, global_stream)¶ Event called at the end of SDFG code generation. :param sdfg: The generated SDFG object. :param local_stream: Code generator for the in-function code. :param global_stream: Code generator for global (external) code.
-
on_state_begin
(sdfg, state, local_stream, global_stream)¶ Event called at the beginning of SDFG state code generation. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param local_stream: Code generator for the in-function code. :param global_stream: Code generator for global (external) code.
-
on_state_end
(sdfg, state, local_stream, global_stream)¶ Event called at the end of SDFG state code generation. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param local_stream: Code generator for the in-function code. :param global_stream: Code generator for global (external) code.
-
register
(**kwargs)¶
-
unregister
()¶
-
dace.codegen.instrumentation.timer module¶
-
class
dace.codegen.instrumentation.timer.
TimerProvider
¶ Bases:
dace.codegen.instrumentation.provider.InstrumentationProvider
Timing instrumentation that reports wall-clock time directly after timed execution is complete.
-
on_node_begin
(sdfg, state, node, outer_stream, inner_stream, global_stream)¶ Event called at the beginning of generating a node. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param node: The generated node. :param outer_stream: Code generator for the internal code before
the scope is opened.Parameters: - inner_stream – Code generator for the internal code within the scope (at the beginning).
- global_stream – Code generator for global (external) code.
-
on_node_end
(sdfg, state, node, outer_stream, inner_stream, global_stream)¶ Event called at the end of generating a node. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param node: The generated node. :param outer_stream: Code generator for the internal code after
the scope is closed.Parameters: - inner_stream – Code generator for the internal code within the scope (at the end).
- global_stream – Code generator for global (external) code.
-
on_scope_entry
(sdfg, state, node, outer_stream, inner_stream, global_stream)¶ Event called at the beginning of a scope (on generating an EntryNode). :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param node: The EntryNode object from which code is generated. :param outer_stream: Code generator for the internal code before
the scope is opened.Parameters: - inner_stream – Code generator for the internal code within the scope (at the beginning).
- global_stream – Code generator for global (external) code.
-
on_scope_exit
(sdfg, state, node, outer_stream, inner_stream, global_stream)¶ Event called at the end of a scope (on generating an ExitNode). :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param node: The ExitNode object from which code is generated. :param outer_stream: Code generator for the internal code after
the scope is closed.Parameters: - inner_stream – Code generator for the internal code within the scope (at the end).
- global_stream – Code generator for global (external) code.
-
on_sdfg_begin
(sdfg, local_stream, global_stream)¶ Event called at the beginning of SDFG code generation. :param sdfg: The generated SDFG object. :param local_stream: Code generator for the in-function code. :param global_stream: Code generator for global (external) code.
-
on_sdfg_end
(sdfg, local_stream, global_stream)¶ Event called at the end of SDFG code generation. :param sdfg: The generated SDFG object. :param local_stream: Code generator for the in-function code. :param global_stream: Code generator for global (external) code.
-
on_state_begin
(sdfg, state, local_stream, global_stream)¶ Event called at the beginning of SDFG state code generation. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param local_stream: Code generator for the in-function code. :param global_stream: Code generator for global (external) code.
-
on_state_end
(sdfg, state, local_stream, global_stream)¶ Event called at the end of SDFG state code generation. :param sdfg: The generated SDFG object. :param state: The generated SDFGState object. :param local_stream: Code generator for the in-function code. :param global_stream: Code generator for global (external) code.
-
on_tbegin
(stream: dace.codegen.prettycode.CodeIOStream, sdfg=None, state=None, node=None)¶
-
on_tend
(timer_name: str, stream: dace.codegen.prettycode.CodeIOStream, sdfg=None, state=None, node=None)¶
-