Example #1
0
    def dump_sym_operator(name, sym_operator):
        if "dump_sym_operator_stages" in debug_flags:
            from pytools.debug import open_unique_debug_file
            outf, name = open_unique_debug_file("%02d-%s" % (stage[0], name), ".txt")
            with outf:
                outf.write(sym.pretty(sym_operator))

            stage[0] += 1
Example #2
0
def bind(discr,
         sym_operator,
         *,
         post_bind_mapper=lambda x: x,
         function_registry=base_function_registry,
         exec_mapper_factory=ExecutionMapper,
         debug_flags=frozenset(),
         local_only=None):
    """
    :param local_only: If *True*, *sym_operator* should oly be evaluated on the
        local part of the mesh. No inter-rank communication will take place.
        (However rank boundaries, tagged :class:`~meshmode.mesh.BTAG_PARTITION`,
        will not automatically be considered part of the domain boundary.)
    """
    # from grudge.symbolic.mappers import QuadratureUpsamplerRemover
    # sym_operator = QuadratureUpsamplerRemover(self.quad_min_degrees)(
    #         sym_operator)

    stage = [0]

    def dump_sym_operator(name, sym_operator):
        if "dump_sym_operator_stages" in debug_flags:
            from pytools.debug import open_unique_debug_file
            outf, name = open_unique_debug_file("%02d-%s" % (stage[0], name),
                                                ".txt")
            with outf:
                outf.write(sym.pretty(sym_operator))

            stage[0] += 1

    sym_operator = process_sym_operator(discr,
                                        sym_operator,
                                        post_bind_mapper=post_bind_mapper,
                                        dumper=dump_sym_operator,
                                        local_only=local_only)

    from grudge.symbolic.compiler import OperatorCompiler
    discr_code, eval_code = OperatorCompiler(discr,
                                             function_registry)(sym_operator)

    bound_op = BoundOperator(discr,
                             discr_code,
                             eval_code,
                             function_registry=function_registry,
                             exec_mapper_factory=exec_mapper_factory,
                             debug_flags=debug_flags)

    if "dump_op_code" in debug_flags:
        from pytools.debug import open_unique_debug_file
        outf, _ = open_unique_debug_file("op-code", ".txt")
        with outf:
            outf.write(str(bound_op))

    if "dump_dataflow_graph" in debug_flags:
        discr_code.dump_dataflow_graph("discr")
        eval_code.dump_dataflow_graph("eval")

    return bound_op
Example #3
0
    def dump_dataflow_graph(self, name=None):
        from pytools.debug import open_unique_debug_file

        if name is None:
            stem = "dataflow"
        else:
            stem = "dataflow-%s" % name

        outf, _ = open_unique_debug_file(stem, ".dot")
        with outf:
            outf.write(dot_dataflow_graph(self, max_node_label_length=None))
Example #4
0
def bind(discr, sym_operator, post_bind_mapper=lambda x: x,
        function_registry=base_function_registry,
        exec_mapper_factory=ExecutionMapper,
        debug_flags=frozenset(), allocator=None):
    # from grudge.symbolic.mappers import QuadratureUpsamplerRemover
    # sym_operator = QuadratureUpsamplerRemover(self.quad_min_degrees)(
    #         sym_operator)

    stage = [0]

    def dump_sym_operator(name, sym_operator):
        if "dump_sym_operator_stages" in debug_flags:
            from pytools.debug import open_unique_debug_file
            outf, name = open_unique_debug_file("%02d-%s" % (stage[0], name), ".txt")
            with outf:
                outf.write(sym.pretty(sym_operator))

            stage[0] += 1

    sym_operator = process_sym_operator(
            discr,
            sym_operator,
            post_bind_mapper=post_bind_mapper,
            dumper=dump_sym_operator)

    from grudge.symbolic.compiler import OperatorCompiler
    discr_code, eval_code = OperatorCompiler(discr, function_registry)(sym_operator)

    bound_op = BoundOperator(discr, discr_code, eval_code,
            function_registry=function_registry,
            exec_mapper_factory=exec_mapper_factory,
            debug_flags=debug_flags,
            allocator=allocator)

    if "dump_op_code" in debug_flags:
        from pytools.debug import open_unique_debug_file
        outf, _ = open_unique_debug_file("op-code", ".txt")
        with outf:
            outf.write(str(bound_op))

    if "dump_dataflow_graph" in debug_flags:
        discr_code.dump_dataflow_graph("discr")
        eval_code.dump_dataflow_graph("eval")

    return bound_op
Example #5
0
    def dump_dataflow_graph(self):
        from pytools.debug import open_unique_debug_file

        open_unique_debug_file("dataflow", ".dot")[0]\
                .write(dot_dataflow_graph(self, max_node_label_length=None))
Example #6
0
    def dump_dataflow_graph(self):
        from pytools.debug import open_unique_debug_file

        open_unique_debug_file("dataflow", ".dot")\
                .write(dot_dataflow_graph(self, max_node_label_length=None))