dace.codegen.targets package¶
Submodules¶
dace.codegen.targets.cpu module¶
-
class
dace.codegen.targets.cpu.
CPUCodeGen
(frame_codegen, sdfg)¶ Bases:
dace.codegen.targets.target.TargetCodeGenerator
SDFG CPU code generator.
-
allocate_array
(sdfg, dfg, state_id, node, nodedesc, function_stream, declaration_stream, allocation_stream)¶ Generates code for allocating an array, outputting to the given code streams. :param sdfg: The SDFG to generate code from. :param dfg: The SDFG state to generate code from. :param state_id: The node ID of the state in the given SDFG. :param node: The data node to generate allocation for. :param nodedesc: The data descriptor to allocate. :param global_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: - declaration_stream – A CodeIOStream object that points to the point of array declaration.
- allocation_stream – A CodeIOStream object that points to the call-site of array allocation.
-
allocate_reference
(sdfg: dace.sdfg.sdfg.SDFG, dfg: dace.sdfg.state.SDFGState, state_id: int, node: dace.sdfg.nodes.AccessNode, global_stream: dace.codegen.prettycode.CodeIOStream, declaration_stream: dace.codegen.prettycode.CodeIOStream, allocation_stream: dace.codegen.prettycode.CodeIOStream)¶
-
allocate_view
(sdfg: dace.sdfg.sdfg.SDFG, dfg: dace.sdfg.state.SDFGState, state_id: int, node: dace.sdfg.nodes.AccessNode, global_stream: dace.codegen.prettycode.CodeIOStream, declaration_stream: dace.codegen.prettycode.CodeIOStream, allocation_stream: dace.codegen.prettycode.CodeIOStream)¶ Allocates (creates pointer and refers to original) a view of an existing array, scalar, or view.
-
static
cmake_options
()¶
-
copy_memory
(sdfg, dfg, state_id, src_node, dst_node, edge, function_stream, callsite_stream)¶ Generates code for copying memory, either from a data access node (array/stream) to another, a code node (tasklet/nested SDFG) to another, or a combination of the two. :param sdfg: The SDFG to generate code from. :param dfg: The SDFG state to generate code from. :param state_id: The node ID of the state in the given SDFG. :param src_node: The source node to generate copy code for. :param dst_node: The destination node to generate copy code for. :param edge: The edge representing the copy (in the innermost
scope, adjacent to either the source or destination node).Parameters: - function_stream – A CodeIOStream object that will be generated outside the calling code, for use when generating global functions.
- callsite_stream – A CodeIOStream object that points to the current location (call-site) in the code.
-
deallocate_array
(sdfg, dfg, state_id, node, nodedesc, function_stream, callsite_stream)¶ Generates code for deallocating an array, outputting to the given code streams. :param sdfg: The SDFG to generate code from. :param dfg: The SDFG state to generate code from. :param state_id: The node ID of the state in the given SDFG. :param node: The data node to generate deallocation for. :param nodedesc: The data descriptor to deallocate. :param function_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: callsite_stream – A CodeIOStream object that points to the current location (call-site) in the code.
-
declare_array
(sdfg, dfg, state_id, node, nodedesc, function_stream, declaration_stream)¶ Generates code for declaring an array without allocating it, outputting to the given code streams. :param sdfg: The SDFG to generate code from. :param dfg: The SDFG state to generate code from. :param state_id: The node ID of the state in the given SDFG. :param node: The data node to generate allocation for. :param nodedesc: The data descriptor to allocate. :param global_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: declaration_stream – A CodeIOStream object that points to the point of array declaration.
-
define_out_memlet
(sdfg, state_dfg, state_id, src_node, dst_node, edge, function_stream, callsite_stream)¶
-
generate_node
(sdfg, dfg, state_id, node, function_stream, callsite_stream)¶ Generates code for a single node, outputting it to the given code streams. :param sdfg: The SDFG to generate code from. :param dfg: The SDFG state to generate code from. :param state_id: The node ID of the state in the given SDFG. :param node: The node to generate code from. :param function_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: callsite_stream – A CodeIOStream object that points to the current location (call-site) in the code.
-
generate_nsdfg_arguments
(sdfg, dfg, state, node)¶
-
generate_nsdfg_call
(sdfg, state, node, memlet_references, sdfg_label, state_struct=True)¶
-
generate_nsdfg_header
(sdfg, state, state_id, node, memlet_references, sdfg_label, state_struct=True)¶
-
generate_scope
(sdfg: dace.sdfg.sdfg.SDFG, dfg_scope: dace.sdfg.scope.ScopeSubgraphView, state_id, function_stream, callsite_stream)¶ Generates code for an SDFG state scope (from a scope-entry node to its corresponding scope-exit node), outputting it to the given code streams. :param sdfg: The SDFG to generate code from. :param dfg_scope: The ScopeSubgraphView to generate code from. :param state_id: The node ID of the state in the given SDFG. :param function_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: callsite_stream – A CodeIOStream object that points to the current location (call-site) in the code.
-
generate_scope_postamble
(sdfg, dfg_scope, state_id, function_stream, outer_stream, inner_stream)¶ Generates code for the end of an SDFG scope, outputting it to the given code streams. :param sdfg: The SDFG to generate code from. :param dfg_scope: The ScopeSubgraphView to generate code from. :param state_id: The node ID of the state in the given SDFG. :param function_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: - outer_stream – A CodeIOStream object that points to the code after the scope (e.g., after for-loop closing braces or kernel invocations).
- inner_stream – A CodeIOStream object that points to the end of the inner scope code (e.g., before for-loop closing braces or end of kernel).
-
generate_scope_preamble
(sdfg, dfg_scope, state_id, function_stream, outer_stream, inner_stream)¶ Generates code for the beginning of an SDFG scope, outputting it to the given code streams. :param sdfg: The SDFG to generate code from. :param dfg_scope: The ScopeSubgraphView to generate code from. :param state_id: The node ID of the state in the given SDFG. :param function_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: - outer_stream – A CodeIOStream object that points to the code before the scope generation (e.g., before for-loops or kernel invocations).
- inner_stream – A CodeIOStream object that points to the beginning of the scope code (e.g., inside for-loops or beginning of kernel).
-
generate_tasklet_postamble
(sdfg, dfg_scope, state_id, node, function_stream, before_memlets_stream, after_memlets_stream)¶ Generates code for the end of a tasklet. This method is intended to be overloaded by subclasses. :param sdfg: The SDFG to generate code from. :param dfg_scope: The ScopeSubgraphView to generate code from. :param state_id: The node ID of the state in the given SDFG. :param node: The tasklet node in the state. :param function_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: - before_memlets_stream – A CodeIOStream object that will emit code before output memlets are generated.
- after_memlets_stream – A CodeIOStream object that will emit code after output memlets are generated.
-
generate_tasklet_preamble
(sdfg, dfg_scope, state_id, node, function_stream, before_memlets_stream, after_memlets_stream)¶ Generates code for the beginning of a tasklet. This method is intended to be overloaded by subclasses. :param sdfg: The SDFG to generate code from. :param dfg_scope: The ScopeSubgraphView to generate code from. :param state_id: The node ID of the state in the given SDFG. :param node: The tasklet node in the state. :param function_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: - before_memlets_stream – A CodeIOStream object that will emit code before input memlets are generated.
- after_memlets_stream – A CodeIOStream object that will emit code after input memlets are generated.
-
get_generated_codeobjects
()¶ Returns a list of generated CodeObject classes corresponding to files with generated code. If an empty list is returned (default) then this code generator does not create new files. @see: CodeObject
-
has_finalizer
¶ Returns True if the target generates a __dace_exit_<TARGET> function that should be called on finalization.
-
has_initializer
¶ Returns True if the target generates a __dace_init_<TARGET> function that should be called on initialization.
-
language
= 'cpp'¶
-
make_ptr_assignment
(src_expr, src_dtype, dst_expr, dst_dtype, codegen=None)¶ Write source to destination, where the source is a scalar, and the destination is a pointer. :return: String of C++ performing the write.
-
make_ptr_vector_cast
(*args, **kwargs)¶
-
memlet_ctor
(sdfg, memlet, dtype, is_output)¶
-
memlet_definition
(sdfg: dace.sdfg.sdfg.SDFG, memlet: dace.memlet.Memlet, output: bool, local_name: str, conntype: Union[dace.data.Data, dace.dtypes.typeclass] = None, allow_shadowing=False, codegen=None)¶
-
memlet_stream_ctor
(sdfg, memlet)¶
-
memlet_view_ctor
(sdfg, memlet, dtype, is_output)¶
-
process_out_memlets
(sdfg, state_id, node, dfg, dispatcher, result, locals_defined, function_stream, skip_wcr=False, codegen=None)¶
-
target_name
= 'cpu'¶
-
title
= 'CPU'¶
-
unparse_tasklet
(sdfg, state_id, dfg, node, function_stream, inner_stream, locals, ldepth, toplevel_schedule)¶
-
write_and_resolve_expr
(sdfg, memlet, nc, outname, inname, indices=None, dtype=None)¶ Emits a conflict resolution call from a memlet.
-
dace.codegen.targets.cuda module¶
-
class
dace.codegen.targets.cuda.
CUDACodeGen
(frame_codegen, sdfg: dace.sdfg.sdfg.SDFG)¶ Bases:
dace.codegen.targets.target.TargetCodeGenerator
GPU (CUDA/HIP) code generator.
-
allocate_array
(sdfg, dfg, state_id, node, nodedesc, function_stream, declaration_stream, allocation_stream)¶ Generates code for allocating an array, outputting to the given code streams. :param sdfg: The SDFG to generate code from. :param dfg: The SDFG state to generate code from. :param state_id: The node ID of the state in the given SDFG. :param node: The data node to generate allocation for. :param nodedesc: The data descriptor to allocate. :param global_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: - declaration_stream – A CodeIOStream object that points to the point of array declaration.
- allocation_stream – A CodeIOStream object that points to the call-site of array allocation.
-
allocate_stream
(sdfg, dfg, state_id, node, nodedesc, function_stream, declaration_stream, allocation_stream)¶
-
static
cmake_options
()¶
-
copy_memory
(sdfg, dfg, state_id, src_node, dst_node, memlet, function_stream, callsite_stream)¶ Generates code for copying memory, either from a data access node (array/stream) to another, a code node (tasklet/nested SDFG) to another, or a combination of the two. :param sdfg: The SDFG to generate code from. :param dfg: The SDFG state to generate code from. :param state_id: The node ID of the state in the given SDFG. :param src_node: The source node to generate copy code for. :param dst_node: The destination node to generate copy code for. :param edge: The edge representing the copy (in the innermost
scope, adjacent to either the source or destination node).Parameters: - function_stream – A CodeIOStream object that will be generated outside the calling code, for use when generating global functions.
- callsite_stream – A CodeIOStream object that points to the current location (call-site) in the code.
-
deallocate_array
(sdfg, dfg, state_id, node, nodedesc, function_stream, callsite_stream)¶ Generates code for deallocating an array, outputting to the given code streams. :param sdfg: The SDFG to generate code from. :param dfg: The SDFG state to generate code from. :param state_id: The node ID of the state in the given SDFG. :param node: The data node to generate deallocation for. :param nodedesc: The data descriptor to deallocate. :param function_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: callsite_stream – A CodeIOStream object that points to the current location (call-site) in the code.
-
deallocate_stream
(sdfg, dfg, state_id, node, nodedesc, function_stream, callsite_stream)¶
-
declare_array
(sdfg, dfg, state_id, node, nodedesc, function_stream, declaration_stream)¶ Generates code for declaring an array without allocating it, outputting to the given code streams. :param sdfg: The SDFG to generate code from. :param dfg: The SDFG state to generate code from. :param state_id: The node ID of the state in the given SDFG. :param node: The data node to generate allocation for. :param nodedesc: The data descriptor to allocate. :param global_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: declaration_stream – A CodeIOStream object that points to the point of array declaration.
-
define_out_memlet
(sdfg, state_dfg, state_id, src_node, dst_node, edge, function_stream, callsite_stream)¶
-
generate_devicelevel_scope
(sdfg, dfg_scope, state_id, function_stream, callsite_stream)¶
-
generate_devicelevel_state
(sdfg, state, function_stream, callsite_stream)¶
-
generate_kernel_scope
(sdfg: dace.sdfg.sdfg.SDFG, dfg_scope: dace.sdfg.scope.ScopeSubgraphView, state_id: int, kernel_map: dace.sdfg.nodes.Map, kernel_name: str, grid_dims: list, block_dims: list, has_tbmap: bool, has_dtbmap: bool, kernel_params: list, function_stream: dace.codegen.prettycode.CodeIOStream, kernel_stream: dace.codegen.prettycode.CodeIOStream)¶
-
generate_node
(sdfg, dfg, state_id, node, function_stream, callsite_stream)¶ Generates code for a single node, outputting it to the given code streams. :param sdfg: The SDFG to generate code from. :param dfg: The SDFG state to generate code from. :param state_id: The node ID of the state in the given SDFG. :param node: The node to generate code from. :param function_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: callsite_stream – A CodeIOStream object that points to the current location (call-site) in the code.
-
generate_nsdfg_arguments
(sdfg, dfg, state, node)¶
-
generate_nsdfg_call
(sdfg, state, node, memlet_references, sdfg_label)¶
-
generate_nsdfg_header
(sdfg, state, state_id, node, memlet_references, sdfg_label)¶
-
generate_scope
(sdfg, dfg_scope, state_id, function_stream, callsite_stream)¶ Generates code for an SDFG state scope (from a scope-entry node to its corresponding scope-exit node), outputting it to the given code streams. :param sdfg: The SDFG to generate code from. :param dfg_scope: The ScopeSubgraphView to generate code from. :param state_id: The node ID of the state in the given SDFG. :param function_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: callsite_stream – A CodeIOStream object that points to the current location (call-site) in the code.
-
generate_state
(sdfg, state, function_stream, callsite_stream)¶ Generates code for an SDFG state, outputting it to the given code streams. :param sdfg: The SDFG to generate code from. :param state: The SDFGState to generate code from. :param function_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: callsite_stream – A CodeIOStream object that points to the current location (call-site) in the code.
-
get_generated_codeobjects
()¶ Returns a list of generated CodeObject classes corresponding to files with generated code. If an empty list is returned (default) then this code generator does not create new files. @see: CodeObject
-
get_kernel_dimensions
(dfg_scope)¶ Determines a GPU kernel’s grid/block dimensions from map scopes.
- Ruleset for kernel dimensions:
- If only one map (device-level) exists, of an integer set S, the block size is 32x1x1 and grid size is ceil(|S|/32) in 1st dimension.
- If nested thread-block maps exist (T_1,…,T_n), grid size is |S| and block size is max(|T_1|,…,|T_n|) with block specialization.
- If block size can be overapproximated, it is (for dynamically-sized blocks that are bounded by a predefined size).
- If nested device maps exist, they generate extra grid dimensions (block size 1) as the sum of all their sizes (|T_1| + … + |T_n|)
Note: Kernel dimensions are separate from the map variables, and they should be treated as such. Note: To make use of the grid/block 3D registers, we use multi- dimensional kernels up to 3 dimensions, and flatten the rest into the third dimension.
-
get_next_scope_entries
(dfg, scope_entry)¶
-
get_tb_maps_recursive
(subgraph)¶
-
has_finalizer
¶ Returns True if the target generates a __dace_exit_<TARGET> function that should be called on finalization.
-
has_initializer
¶ Returns True if the target generates a __dace_init_<TARGET> function that should be called on initialization.
-
make_ptr_vector_cast
(*args, **kwargs)¶
-
node_dispatch_predicate
(sdfg, state, node)¶
-
preprocess
(sdfg: dace.sdfg.sdfg.SDFG) → None¶ Called before code generation on any target that will be dispatched. Used for making modifications on the SDFG prior to code generation. :note: Post-conditions assume that the SDFG will NOT be changed after
this point.Parameters: sdfg – The SDFG to modify in-place.
-
process_out_memlets
(*args, **kwargs)¶
-
state_dispatch_predicate
(sdfg, state)¶
-
target_name
= 'cuda'¶
-
title
= 'CUDA'¶
-
-
dace.codegen.targets.cuda.
cpu_to_gpu_cpred
(sdfg, state, src_node, dst_node)¶ Copy predicate from CPU to GPU that determines when a copy is illegal. Returns True if copy is illegal, False otherwise.
-
dace.codegen.targets.cuda.
prod
(iterable)¶
dace.codegen.targets.framecode module¶
-
class
dace.codegen.targets.framecode.
DaCeCodeGenerator
(sdfg: dace.sdfg.sdfg.SDFG)¶ Bases:
object
DaCe code generator class that writes the generated code for SDFG state machines, and uses a dispatcher to generate code for individual states based on the target.
-
allocate_arrays_in_scope
(sdfg: dace.sdfg.sdfg.SDFG, scope: Union[dace.sdfg.nodes.EntryNode, dace.sdfg.state.SDFGState, dace.sdfg.sdfg.SDFG], function_stream: dace.codegen.prettycode.CodeIOStream, callsite_stream: dace.codegen.prettycode.CodeIOStream)¶ Dispatches allocation of all arrays in the given scope.
-
deallocate_arrays_in_scope
(sdfg: dace.sdfg.sdfg.SDFG, scope: Union[dace.sdfg.nodes.EntryNode, dace.sdfg.state.SDFGState, dace.sdfg.sdfg.SDFG], function_stream: dace.codegen.prettycode.CodeIOStream, callsite_stream: dace.codegen.prettycode.CodeIOStream)¶ Dispatches deallocation of all arrays in the given scope.
-
determine_allocation_lifetime
(top_sdfg: dace.sdfg.sdfg.SDFG)¶ Determines where (at which scope/state/SDFG) each data descriptor will be allocated/deallocated. :param top_sdfg: The top-level SDFG to determine for.
-
dispatcher
¶
-
free_symbols
(obj: Any)¶
-
generate_code
(sdfg: dace.sdfg.sdfg.SDFG, schedule: Optional[dace.dtypes.ScheduleType], sdfg_id: str = '') → Tuple[str, str, Set[dace.codegen.targets.target.TargetCodeGenerator], Set[str]]¶ Generate frame code for a given SDFG, calling registered targets’ code generation callbacks for them to generate their own code. :param sdfg: The SDFG to generate code for. :param schedule: The schedule the SDFG is currently located, or
None if the SDFG is top-level.Parameters: sdfg_id – An optional string id given to the SDFG label Returns: A tuple of the generated global frame code, local frame code, and a set of targets that have been used in the generation of this SDFG.
-
generate_constants
(sdfg: dace.sdfg.sdfg.SDFG, callsite_stream: dace.codegen.prettycode.CodeIOStream)¶
-
generate_fileheader
(sdfg: dace.sdfg.sdfg.SDFG, global_stream: dace.codegen.prettycode.CodeIOStream, backend: str = 'frame')¶ Generate a header in every output file that includes custom types and constants. :param sdfg: The input SDFG. :param global_stream: Stream to write to (global). :param backend: Whose backend this header belongs to.
Generate the footer of the frame-code. Code exists in a separate function for overriding purposes. :param sdfg: The input SDFG. :param global_stream: Stream to write to (global). :param callsite_stream: Stream to write to (at call site).
-
generate_header
(sdfg: dace.sdfg.sdfg.SDFG, global_stream: dace.codegen.prettycode.CodeIOStream, callsite_stream: dace.codegen.prettycode.CodeIOStream)¶ Generate the header of the frame-code. Code exists in a separate function for overriding purposes. :param sdfg: The input SDFG. :param global_stream: Stream to write to (global). :param callsite_stream: Stream to write to (at call site).
-
generate_state
(sdfg, state, global_stream, callsite_stream, generate_state_footer=True)¶
-
generate_states
(sdfg, global_stream, callsite_stream)¶
-
preprocess
(sdfg: dace.sdfg.sdfg.SDFG) → None¶ Called before code generation. Used for making modifications on the SDFG prior to code generation. :note: Post-conditions assume that the SDFG will NOT be changed after this point. :param sdfg: The SDFG to modify in-place.
-
symbols_and_constants
(sdfg: dace.sdfg.sdfg.SDFG)¶
-
dace.codegen.targets.mpi module¶
-
class
dace.codegen.targets.mpi.
MPICodeGen
(frame_codegen, sdfg: dace.sdfg.sdfg.SDFG)¶ Bases:
dace.codegen.targets.target.TargetCodeGenerator
An MPI code generator.
-
static
cmake_options
()¶
-
generate_scope
(sdfg, dfg_scope, state_id, function_stream, callsite_stream)¶ Generates code for an SDFG state scope (from a scope-entry node to its corresponding scope-exit node), outputting it to the given code streams. :param sdfg: The SDFG to generate code from. :param dfg_scope: The ScopeSubgraphView to generate code from. :param state_id: The node ID of the state in the given SDFG. :param function_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: callsite_stream – A CodeIOStream object that points to the current location (call-site) in the code.
-
get_generated_codeobjects
()¶ Returns a list of generated CodeObject classes corresponding to files with generated code. If an empty list is returned (default) then this code generator does not create new files. @see: CodeObject
-
has_finalizer
¶ Returns True if the target generates a __dace_exit_<TARGET> function that should be called on finalization.
-
has_initializer
¶ Returns True if the target generates a __dace_init_<TARGET> function that should be called on initialization.
-
language
= 'cpp'¶
-
target_name
= 'mpi'¶
-
title
= 'MPI'¶
-
static
dace.codegen.targets.target module¶
-
class
dace.codegen.targets.target.
IllegalCopy
¶ Bases:
dace.codegen.targets.target.TargetCodeGenerator
A code generator that is triggered when invalid copies are specified by the SDFG. Only raises an exception on failure.
-
copy_memory
(sdfg, dfg, state_id, src_node, dst_node, edge, function_stream, callsite_stream)¶ Generates code for copying memory, either from a data access node (array/stream) to another, a code node (tasklet/nested SDFG) to another, or a combination of the two. :param sdfg: The SDFG to generate code from. :param dfg: The SDFG state to generate code from. :param state_id: The node ID of the state in the given SDFG. :param src_node: The source node to generate copy code for. :param dst_node: The destination node to generate copy code for. :param edge: The edge representing the copy (in the innermost
scope, adjacent to either the source or destination node).Parameters: - function_stream – A CodeIOStream object that will be generated outside the calling code, for use when generating global functions.
- callsite_stream – A CodeIOStream object that points to the current location (call-site) in the code.
-
-
class
dace.codegen.targets.target.
TargetCodeGenerator
¶ Bases:
object
Interface dictating functions that generate code for: * Array allocation/deallocation/initialization/copying * Scope (map, consume) code generation
-
allocate_array
(sdfg: dace.sdfg.sdfg.SDFG, dfg: dace.sdfg.state.SDFGState, state_id: int, node: dace.sdfg.nodes.Node, nodedesc: dace.data.Data, global_stream: dace.codegen.prettycode.CodeIOStream, declaration_stream: dace.codegen.prettycode.CodeIOStream, allocation_stream: dace.codegen.prettycode.CodeIOStream) → None¶ Generates code for allocating an array, outputting to the given code streams. :param sdfg: The SDFG to generate code from. :param dfg: The SDFG state to generate code from. :param state_id: The node ID of the state in the given SDFG. :param node: The data node to generate allocation for. :param nodedesc: The data descriptor to allocate. :param global_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: - declaration_stream – A CodeIOStream object that points to the point of array declaration.
- allocation_stream – A CodeIOStream object that points to the call-site of array allocation.
-
copy_memory
(sdfg: dace.sdfg.sdfg.SDFG, dfg: dace.sdfg.state.SDFGState, state_id: int, src_node: dace.sdfg.nodes.Node, dst_node: dace.sdfg.nodes.Node, edge: dace.sdfg.graph.MultiConnectorEdge[dace.memlet.Memlet][dace.memlet.Memlet], function_stream: dace.codegen.prettycode.CodeIOStream, callsite_stream: dace.codegen.prettycode.CodeIOStream) → None¶ Generates code for copying memory, either from a data access node (array/stream) to another, a code node (tasklet/nested SDFG) to another, or a combination of the two. :param sdfg: The SDFG to generate code from. :param dfg: The SDFG state to generate code from. :param state_id: The node ID of the state in the given SDFG. :param src_node: The source node to generate copy code for. :param dst_node: The destination node to generate copy code for. :param edge: The edge representing the copy (in the innermost
scope, adjacent to either the source or destination node).Parameters: - function_stream – A CodeIOStream object that will be generated outside the calling code, for use when generating global functions.
- callsite_stream – A CodeIOStream object that points to the current location (call-site) in the code.
-
deallocate_array
(sdfg: dace.sdfg.sdfg.SDFG, dfg: dace.sdfg.state.SDFGState, state_id: int, node: dace.sdfg.nodes.Node, nodedesc: dace.data.Data, function_stream: dace.codegen.prettycode.CodeIOStream, callsite_stream: dace.codegen.prettycode.CodeIOStream) → None¶ Generates code for deallocating an array, outputting to the given code streams. :param sdfg: The SDFG to generate code from. :param dfg: The SDFG state to generate code from. :param state_id: The node ID of the state in the given SDFG. :param node: The data node to generate deallocation for. :param nodedesc: The data descriptor to deallocate. :param function_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: callsite_stream – A CodeIOStream object that points to the current location (call-site) in the code.
-
declare_array
(sdfg: dace.sdfg.sdfg.SDFG, dfg: dace.sdfg.state.SDFGState, state_id: int, node: dace.sdfg.nodes.Node, nodedesc: dace.data.Data, global_stream: dace.codegen.prettycode.CodeIOStream, declaration_stream: dace.codegen.prettycode.CodeIOStream) → None¶ Generates code for declaring an array without allocating it, outputting to the given code streams. :param sdfg: The SDFG to generate code from. :param dfg: The SDFG state to generate code from. :param state_id: The node ID of the state in the given SDFG. :param node: The data node to generate allocation for. :param nodedesc: The data descriptor to allocate. :param global_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: declaration_stream – A CodeIOStream object that points to the point of array declaration.
-
extensions
()¶
-
generate_node
(sdfg: dace.sdfg.sdfg.SDFG, dfg: dace.sdfg.state.SDFGState, state_id: int, node: dace.sdfg.nodes.Node, function_stream: dace.codegen.prettycode.CodeIOStream, callsite_stream: dace.codegen.prettycode.CodeIOStream) → None¶ Generates code for a single node, outputting it to the given code streams. :param sdfg: The SDFG to generate code from. :param dfg: The SDFG state to generate code from. :param state_id: The node ID of the state in the given SDFG. :param node: The node to generate code from. :param function_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: callsite_stream – A CodeIOStream object that points to the current location (call-site) in the code.
-
generate_scope
(sdfg: dace.sdfg.sdfg.SDFG, dfg_scope: dace.sdfg.scope.ScopeSubgraphView, state_id: int, function_stream: dace.codegen.prettycode.CodeIOStream, callsite_stream: dace.codegen.prettycode.CodeIOStream) → None¶ Generates code for an SDFG state scope (from a scope-entry node to its corresponding scope-exit node), outputting it to the given code streams. :param sdfg: The SDFG to generate code from. :param dfg_scope: The ScopeSubgraphView to generate code from. :param state_id: The node ID of the state in the given SDFG. :param function_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: callsite_stream – A CodeIOStream object that points to the current location (call-site) in the code.
-
generate_state
(sdfg: dace.sdfg.sdfg.SDFG, state: dace.sdfg.state.SDFGState, function_stream: dace.codegen.prettycode.CodeIOStream, callsite_stream: dace.codegen.prettycode.CodeIOStream) → None¶ Generates code for an SDFG state, outputting it to the given code streams. :param sdfg: The SDFG to generate code from. :param state: The SDFGState to generate code from. :param function_stream: A CodeIOStream object that will be
generated outside the calling code, for use when generating global functions.Parameters: callsite_stream – A CodeIOStream object that points to the current location (call-site) in the code.
-
get_generated_codeobjects
() → List[dace.codegen.codeobject.CodeObject]¶ Returns a list of generated CodeObject classes corresponding to files with generated code. If an empty list is returned (default) then this code generator does not create new files. @see: CodeObject
-
has_finalizer
¶ Returns True if the target generates a __dace_exit_<TARGET> function that should be called on finalization.
-
has_initializer
¶ Returns True if the target generates a __dace_init_<TARGET> function that should be called on initialization.
-
preprocess
(sdfg: dace.sdfg.sdfg.SDFG) → None¶ Called before code generation on any target that will be dispatched. Used for making modifications on the SDFG prior to code generation. :note: Post-conditions assume that the SDFG will NOT be changed after
this point.Parameters: sdfg – The SDFG to modify in-place.
-
register
(**kwargs)¶
-
unregister
()¶
-
-
dace.codegen.targets.target.
make_absolute
(path: str) → str¶ Finds an executable and returns an absolute path out of it. Used when finding compiler executables. :param path: Executable name, relative path, or absolute path. :return: Absolute path pointing to the same file as
path
.
dace.codegen.targets.xilinx module¶
-
class
dace.codegen.targets.xilinx.
XilinxCodeGen
(*args, **kwargs)¶ Bases:
dace.codegen.targets.fpga.FPGACodeGen
Xilinx FPGA code generator.
-
allocate_view
(sdfg: dace.sdfg.sdfg.SDFG, dfg: dace.sdfg.state.SDFGState, state_id: int, node: dace.sdfg.nodes.AccessNode, global_stream: dace.codegen.prettycode.CodeIOStream, declaration_stream: dace.codegen.prettycode.CodeIOStream, allocation_stream: dace.codegen.prettycode.CodeIOStream)¶
-
static
cmake_options
()¶
-
define_local_array
(var_name, desc, array_size, function_stream, kernel_stream, sdfg, state_id, node)¶
-
define_shift_register
(**kwargs)¶
-
define_stream
(dtype, buffer_size, var_name, array_size, function_stream, kernel_stream, sdfg)¶ Defines a stream :return: a tuple containing the type of the created variable, and boolean indicating
whether this is a global variable or not
-
generate_converter
(**kwargs)¶
-
static
generate_flatten_loop_post
(kernel_stream, sdfg, state_id, node)¶
-
static
generate_flatten_loop_pre
(kernel_stream, sdfg, state_id, node)¶
-
generate_host_function_body
(sdfg: dace.sdfg.sdfg.SDFG, state: dace.sdfg.state.SDFGState, kernel_name: str, predecessors: list, parameters: list, rtl_tasklet_names: list, kernel_stream: dace.codegen.prettycode.CodeIOStream, instrumentation_stream: dace.codegen.prettycode.CodeIOStream)¶ Generate the host-specific code for spawning and synchronizing the given kernel. :param sdfg: :param state: :param predecessors: list containing all the name of kernels that must be finished before starting this one :param parameters: list containing the kernel parameters (of all kernels in this state) :param rtl_tasklet_names :param kernel_stream: Device-specific code stream :param instrumentation_stream: Code for profiling kernel execution time.
-
generate_host_header
(sdfg, kernel_function_name, parameters, host_code_stream)¶
-
static
generate_kernel_boilerplate_post
(kernel_stream, sdfg, state_id)¶
-
generate_kernel_boilerplate_pre
(sdfg, state_id, kernel_name, parameters, bank_assignments, module_stream, kernel_stream, external_streams)¶
-
generate_kernel_internal
(sdfg: dace.sdfg.sdfg.SDFG, state: dace.sdfg.state.SDFGState, kernel_name: str, predecessors: list, subgraphs: list, kernel_stream: dace.codegen.prettycode.CodeIOStream, state_host_header_stream: dace.codegen.prettycode.CodeIOStream, state_host_body_stream: dace.codegen.prettycode.CodeIOStream, instrumentation_stream: dace.codegen.prettycode.CodeIOStream, function_stream: dace.codegen.prettycode.CodeIOStream, callsite_stream: dace.codegen.prettycode.CodeIOStream, state_parameters: list)¶ Generates Kernel code, both device and host side. :param sdfg: :param state: :param kernel_name: :param predecessors: list containing all the name of kernels from which this one depends :param subgraphs: :param kernel_stream: Device code stream, contains the kernel code :param state_host_header_stream: Device-specific code stream: contains the host code
for the state global declarations.Parameters: - state_host_body_stream – Device-specific code stream: contains all the code related to this state, for creating transient buffers, spawning kernels, and synchronizing them.
- instrumentation_stream – Code for profiling kernel execution time.
- function_stream – CPU code stream.
- callsite_stream – CPU code stream.
- state_parameters – list of state parameters. The kernel-specific parameters will be appended to it.
-
generate_memlet_definition
(sdfg, dfg, state_id, src_node, dst_node, edge, callsite_stream)¶
-
generate_module
(sdfg, state, kernel_name, name, subgraph, parameters, module_stream, entry_stream, host_stream, instrumentation_stream)¶ Generates a module that will run as a dataflow function in the FPGA kernel.
-
generate_no_dependence_post
(kernel_stream, sdfg: dace.sdfg.sdfg.SDFG, state_id: int, node: dace.sdfg.nodes.Node, var_name: str, accessed_subset: Union[int, dace.subsets.Subset] = None)¶ Adds post loop pragma for ignoring loop carried dependencies on a given variable
-
static
generate_no_dependence_pre
(kernel_stream, sdfg, state_id, node, var_name=None)¶
-
generate_nsdfg_arguments
(sdfg, dfg, state, node)¶
-
generate_nsdfg_header
(sdfg, state, state_id, node, memlet_references, sdfg_label)¶
-
static
generate_pipeline_loop_post
(kernel_stream, sdfg, state_id, node)¶
-
static
generate_pipeline_loop_pre
(kernel_stream, sdfg, state_id, node)¶
-
static
generate_unroll_loop_post
(kernel_stream, factor, sdfg, state_id, node)¶
-
generate_unroll_loop_pre
(kernel_stream, factor, sdfg, state_id, node)¶
-
get_generated_codeobjects
()¶ Returns a list of generated CodeObject classes corresponding to files with generated code. If an empty list is returned (default) then this code generator does not create new files. @see: CodeObject
-
language
= 'hls'¶
-
static
make_kernel_argument
(data: dace.data.Data, var_name: str, subset_info: Union[int, dace.subsets.Subset], sdfg: dace.sdfg.sdfg.SDFG, is_output: bool, with_vectorization: bool, interface_id: Union[int, List[int]] = None, decouple_array_interfaces=False)¶
-
make_ptr_assignment
(src_expr, src_dtype, dst_expr, dst_dtype)¶ Write source to destination, where the source is a scalar, and the destination is a pointer. :return: String of C++ performing the write.
-
static
make_read
(defined_type, dtype, var_name, expr, index, is_pack, packing_factor)¶
-
make_shift_register_write
(defined_type, dtype, var_name, write_expr, index, read_expr, wcr, is_unpack, packing_factor, sdfg)¶
-
static
make_vector_type
(dtype, is_const)¶
-
static
make_write
(defined_type, dtype, var_name, write_expr, index, read_expr, wcr, is_unpack, packing_factor)¶
-
rtl_tasklet_name
(node: dace.sdfg.nodes.RTLTasklet, state, sdfg)¶
-
target_name
= 'xilinx'¶
-
title
= 'Xilinx'¶
-
unparse_tasklet
(*args, **kwargs)¶
-
write_and_resolve_expr
(sdfg, memlet, nc, outname, inname, indices=None, dtype=None)¶ Emits a conflict resolution call from a memlet.
-