Esempio n. 1
0
    def __init__(self,
                 sdfg: SDFG,
                 dfg,
                 map,
                 cpu_codegen,
                 tree: ast.AST,
                 file: IO[str],
                 code,
                 memlets,
                 pred_name,
                 counter_type,
                 defined_symbols=None,
                 stream_associations=None,
                 wcr_associations=None):

        self.sdfg = sdfg
        self.dfg = dfg
        self.map = map

        self.cpu_codegen = cpu_codegen

        self.dtypes = {k: v[3] for k, v in memlets.items() if k is not None}
        for k, v in sdfg.constants.items():
            if k is not None:
                self.dtypes[k] = v.dtype

        # This defines the type of the loop param and is used whenever we work on predicates to find out the bit size
        self.counter_type = counter_type
        self.pred_bits = counter_type.bytes * 8

        # Keeps track of the currently used predicate
        # This can change during the unparsing (e.g. in an If block)
        self.pred_name = pred_name

        self.code = code

        # This value is used to determine whether we are in an If block, and how deep we are (to name the predicates)
        self.if_depth = 0

        # Stream associations keep track between the local stream variable name <-> underlying stream
        self.stream_associations = stream_associations or {}
        self.wcr_associations = wcr_associations or {}

        # Detect fused operations first (are converted into internal calls)
        preprocessed = preprocess.SVEBinOpFuser(defined_symbols).visit(tree)

        # Make sure all internal calls are defined for the inference
        defined_symbols.update(util.get_internal_symbols())

        super().__init__(preprocessed,
                         0,
                         cppunparse.CPPLocals(),
                         file,
                         expr_semicolon=True,
                         type_inference=True,
                         defined_symbols=defined_symbols)
Esempio n. 2
0
 def __init__(self,
              sdfg: SDFG,
              tree: ast.AST,
              file: IO[str],
              defined_symbols=None):
     self.sdfg = sdfg
     super().__init__(tree,
                      0,
                      cppunparse.CPPLocals(),
                      file,
                      expr_semicolon=False,
                      defined_symbols=defined_symbols)