Esempio n. 1
0
    def opt_rules(self, **kwargs):
        # Sequence that works for datalog
        # TODO: replace with below
        # datalog_rules = [
        # rules.CrossProduct2Join(),
        # rules.SimpleGroupBy(),
        # rules.OneToOne(algebra.Select, CSelect),
        # MemoryScanOfFileScan(),
        # rules.OneToOne(algebra.Apply, CApply),
        # rules.OneToOne(algebra.Join, CHashJoin),
        # rules.OneToOne(algebra.GroupBy, CGroupBy),
        # rules.OneToOne(algebra.Project, CProject),
        # TODO: obviously breaks semantics
        # rules.OneToOne(algebra.Union, CUnionAll),
        # rules.FreeMemory()
        # ]

        # sequence that works for myrial
        rule_grps_sequence = [
            rules.remove_trivial_sequences,
            rules.simple_group_by,
            cppcommon.clang_push_select,
            [rules.ProjectToDistinctColumnSelect(),
             rules.JoinToProjectingJoin()],
            rules.push_apply,
            [rules.DeDupBroadcastInputs()],
            clangify(self.emit_print)
        ]

        if kwargs.get('SwapJoinSides'):
            rule_grps_sequence.insert(0, [rules.SwapJoinSides()])

        # set external indexing on (replacing strings with ints)
        if kwargs.get('external_indexing'):
            CBaseLanguage.set_external_indexing(True)

        # flatten the rules lists
        rule_list = list(itertools.chain(*rule_grps_sequence))

        # disable specified rules
        rules.Rule.apply_disable_flags(rule_list, *kwargs.keys())

        return rule_list
Esempio n. 2
0
    def opt_rules(self, **kwargs):
        # Sequence that works for datalog
        # TODO: replace with below
        # datalog_rules = [
        # rules.CrossProduct2Join(),
        # rules.SimpleGroupBy(),
        # rules.OneToOne(algebra.Select, CSelect),
        # MemoryScanOfFileScan(),
        # rules.OneToOne(algebra.Apply, CApply),
        # rules.OneToOne(algebra.Join, CHashJoin),
        # rules.OneToOne(algebra.GroupBy, CGroupBy),
        # rules.OneToOne(algebra.Project, CProject),
        # TODO: obviously breaks semantics
        # rules.OneToOne(algebra.Union, CUnionAll),
        # rules.FreeMemory()
        # ]

        # sequence that works for myrial
        rule_grps_sequence = [
            rules.remove_trivial_sequences, rules.simple_group_by,
            cppcommon.clang_push_select,
            [
                rules.ProjectToDistinctColumnSelect(),
                rules.JoinToProjectingJoin()
            ], rules.push_apply, [rules.DeDupBroadcastInputs()],
            clangify(self.emit_print)
        ]

        if kwargs.get('SwapJoinSides'):
            rule_grps_sequence.insert(0, [rules.SwapJoinSides()])

        # set external indexing on (replacing strings with ints)
        if kwargs.get('external_indexing'):
            CBaseLanguage.set_external_indexing(True)

        # flatten the rules lists
        rule_list = list(itertools.chain(*rule_grps_sequence))

        # disable specified rules
        rules.Rule.apply_disable_flags(rule_list, *kwargs.keys())

        return rule_list
Esempio n. 3
0
class CC(CBaseLanguage):
    _template_path = 'cpp/c_templates'
    _cgenv = CBaseLanguage.__get_env_for_template_libraries__(_template_path)

    @classmethod
    def cgenv(cls):
        return cls._cgenv

    @classmethod
    def base_template(cls):
        return cls.cgenv().get_template('base_query.cpp')

    @staticmethod
    def pipeline_wrap(ident, code, attrs):

        # timing code
        if True:
            inner_code = code
            timing_template = \
                CC._cgenv.get_template('clang_pipeline_timing.cpp')

            code = timing_template.render(locals())

        return code

    @staticmethod
    def group_wrap(ident, grpcode, attrs):
        timing_template = CC._cgenv.get_template('clang_group_timing.cpp')
        inner_code = grpcode

        code = timing_template.render(locals())
        return code

    @staticmethod
    def log(txt):
        return """std::cout << "%s" << std::endl;
        """ % txt

    @staticmethod
    def log_unquoted(code, level=0):
        return """std::cout << %s << std::endl;
      """ % code

    @staticmethod
    def log_file(code, level=0):
        return """logfile << "%s" << "\\n";\n """ % code

    @staticmethod
    def log_file_unquoted(code, level=0):
        return """logfile << %s << " ";\n """ % code