dace.codegen package¶
Submodules¶
dace.codegen.codegen module¶
dace.codegen.codeobject module¶
-
class
dace.codegen.codeobject.
CodeObject
(*args, **kwargs)¶ Bases:
object
-
clean_code
¶
-
code
¶ The code attached to this object
-
environments
¶ Environments required by CMake to build and run this code node.
-
extra_compiler_kwargs
¶ Additional compiler argument variables to add to template
-
language
¶ Language used for this code (same as its file extension)
-
linkable
¶ Should this file participate in overall linkage?
-
name
¶ Filename to use
-
properties
()¶
-
target
¶ Target to use for compilation
-
target_type
¶ Sub-target within target (e.g., host or device code)
-
title
¶ Title of code for GUI
-
dace.codegen.compiler module¶
Handles compilation of code objects. Creates the proper folder structure, compiles each target separately, links all targets to one binary, and returns the corresponding CompiledSDFG object.
-
dace.codegen.compiler.
configure_and_compile
(program_folder, program_name=None, output_stream=None)¶ Configures and compiles a DaCe program in the specified folder into a shared library file.
Parameters: - program_folder – Folder containing all files necessary to build, equivalent to what was passed to generate_program_folder.
- output_stream – Additional output stream to write to (used for other clients such as the vscode extension).
Returns: Path to the compiled shared library file.
-
dace.codegen.compiler.
generate_program_folder
(sdfg, code_objects: List[dace.codegen.codeobject.CodeObject], out_path: str, config=None)¶ Writes all files required to configure and compile the DaCe program into the specified folder.
Parameters: - sdfg – The SDFG to generate the program folder for.
- code_objects – List of generated code objects.
- out_path – The folder in which the build files should be written.
Returns: Path to the program folder.
-
dace.codegen.compiler.
get_binary_name
(object_folder, object_name, lib_extension='so')¶
-
dace.codegen.compiler.
get_environment_flags
(environments) → Tuple[List[str], Set[str]]¶ Returns the CMake environment and linkage flags associated with the given input environments/libraries. :param environments: A list of
@dace.library.environment
-decoratedclasses.Returns: A 2-tuple of (environment CMake flags, linkage CMake flags)
-
dace.codegen.compiler.
get_program_handle
(library_path, sdfg)¶
-
dace.codegen.compiler.
identical_file_exists
(filename: str, file_contents: str)¶
-
dace.codegen.compiler.
load_from_file
(sdfg, binary_filename)¶
-
dace.codegen.compiler.
unique_flags
(flags)¶
dace.codegen.cppunparse module¶
-
class
dace.codegen.cppunparse.
CPPLocals
¶ Bases:
dace.codegen.cppunparse.LocalScheme
-
clear_scope
(from_indentation)¶ Clears all locals defined in indentation ‘from_indentation’ and deeper
-
define
(local_name, lineno, depth, dtype=None)¶
-
get_name_type_associations
()¶
-
is_defined
(local_name, current_depth)¶
-
-
class
dace.codegen.cppunparse.
CPPUnparser
(tree, depth, locals, file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, indent_output=True, expr_semicolon=True, indent_offset=0, type_inference=False, defined_symbols=None, language=<Language.CPP: 2>)¶ Bases:
object
Methods in this class recursively traverse an AST and output C++ source code for the abstract syntax; original formatting is disregarded.
-
binop
= {'Add': '+', 'BitAnd': '&', 'BitOr': '|', 'BitXor': '^', 'Div': '/', 'LShift': '<<', 'Mod': '%', 'Mult': '*', 'RShift': '>>', 'Sub': '-'}¶
-
boolops
= {<class '_ast.And'>: '&&', <class '_ast.Or'>: '||'}¶
-
callbools
= {'And': <class '_ast.And'>, 'Or': <class '_ast.Or'>}¶
-
callcmps
= {'Eq': <class '_ast.Eq'>, 'Ge': <class '_ast.GtE'>, 'Gt': <class '_ast.Gt'>, 'GtE': <class '_ast.GtE'>, 'Le': <class '_ast.LtE'>, 'Lt': <class '_ast.Lt'>, 'LtE': <class '_ast.LtE'>, 'Ne': <class '_ast.NotEq'>, 'NotEq': <class '_ast.NotEq'>}¶
-
cmpops
= {'Eq': '==', 'Gt': '>', 'GtE': '>=', 'Is': '==', 'IsNot': '!=', 'Lt': '<', 'LtE': '<=', 'NotEq': '!='}¶
-
dispatch
(tree)¶ Dispatcher function, dispatching tree type T to method _T.
-
dispatch_lhs_tuple
(targets)¶
-
enter
()¶ Print ‘{’, and increase the indentation.
-
fill
(text='')¶ Indent a piece of text, according to the current indentation level
-
format_conversions
= {97: 'a', 114: 'r', 115: 's'}¶
-
funcops
= {'FloorDiv': (' /', 'dace::math::ifloor'), 'MatMult': (',', 'dace::gemm')}¶
-
leave
()¶ Decrease the indentation and print ‘}’.
-
unop
= {'Invert': '~', 'Not': '!', 'UAdd': '+', 'USub': '-'}¶
-
write
(text)¶ Append a piece of text to the current line
-
-
class
dace.codegen.cppunparse.
LocalScheme
¶ Bases:
object
-
clear_scope
(from_indentation)¶
-
define
(local_name, lineno, depth)¶
-
is_defined
(local_name, current_depth)¶
-
-
dace.codegen.cppunparse.
cppunparse
(node, expr_semicolon=True, locals=None, defined_symbols=None)¶
-
dace.codegen.cppunparse.
interleave
(inter, f, seq, **kwargs)¶ Call f on each item in seq, calling inter() in between. f can accept optional arguments (kwargs)
-
dace.codegen.cppunparse.
py2cpp
(code, expr_semicolon=True, defined_symbols=None)¶
-
dace.codegen.cppunparse.
pyexpr2cpp
¶
dace.codegen.prettycode module¶
Code I/O stream that automates indentation and mapping of code to SDFG nodes.
-
class
dace.codegen.prettycode.
CodeIOStream
(base_indentation=0)¶ Bases:
_io.StringIO
Code I/O stream that automates indentation and mapping of code to SDFG nodes.
-
write
(contents, sdfg=None, state_id=None, node_id=None)¶ Write string to file.
Returns the number of characters written, which is always equal to the length of the string.
-