コード例 #1
0
    def instrument(self):
        discr = self.discr
        assert discr.instrumented

        from pytools.log import time_and_count_function
        from hedge.tools import time_count_flop

        from hedge.tools import diff_rst_flops, mass_flops

        if discr.quad_min_degrees:
            from warnings import warn
            warn("flop counts for quadrature may be wrong")

        self.diff_rst = \
                time_count_flop(
                        self.diff_rst,
                        discr.diff_timer,
                        discr.diff_counter,
                        discr.diff_flop_counter,
                        diff_rst_flops(discr))

        self.do_elementwise_linear = \
                time_count_flop(
                        self.do_elementwise_linear,
                        discr.el_local_timer,
                        discr.el_local_counter,
                        discr.el_local_flop_counter,
                        mass_flops(discr))

        self.lift_flux = \
                time_and_count_function(
                        self.lift_flux,
                        discr.lift_timer,
                        discr.lift_counter)
コード例 #2
0
ファイル: __init__.py プロジェクト: pombredanne/hedge
    def instrument(self):
        discr = self.discr
        assert discr.instrumented

        from pytools.log import time_and_count_function
        from hedge.tools import time_count_flop

        from hedge.tools import diff_rst_flops, mass_flops

        if discr.quad_min_degrees:
            from warnings import warn
            warn("flop counts for quadrature may be wrong")

        self.diff_rst = \
                time_count_flop(
                        self.diff_rst,
                        discr.diff_timer,
                        discr.diff_counter,
                        discr.diff_flop_counter,
                        diff_rst_flops(discr))

        self.do_elementwise_linear = \
                time_count_flop(
                        self.do_elementwise_linear,
                        discr.el_local_timer,
                        discr.el_local_counter,
                        discr.el_local_flop_counter,
                        mass_flops(discr))

        self.lift_flux = \
                time_and_count_function(
                        self.lift_flux,
                        discr.lift_timer,
                        discr.lift_counter)
コード例 #3
0
ファイル: execute.py プロジェクト: felipeh/hedge
    def __init__(self, discr, optemplate, post_bind_mapper, type_hints={}):
        self.discr = discr
        self.elwise_linear_cache = {}

        from hedge.tools import diff_rst_flops, diff_rescale_one_flops, \
                mass_flops, lift_flops
        self.diff_rst_flops = diff_rst_flops(discr)
        self.diff_rescale_one_flops = diff_rescale_one_flops(discr)
        self.mass_flops = mass_flops(discr)
        self.lift_flops = sum(lift_flops(fg) for fg in discr.face_groups)

        optemplate_stage1 = self.prepare_optemplate_stage1(
                optemplate, post_bind_mapper)

        # build a boundary tag bitmap
        from hedge.optemplate import BoundaryTagCollector
        self.boundary_tag_to_number = {}
        for btag in BoundaryTagCollector()(optemplate_stage1):
            self.boundary_tag_to_number.setdefault(btag,
                    len(self.boundary_tag_to_number))

        e2bb = self.elface_to_bdry_bitmap = {}

        for btag, bdry_number in self.boundary_tag_to_number.iteritems():
            bdry_bit = 1 << bdry_number
            for elface in discr.mesh.tag_to_boundary.get(btag, []):
                e2bb[elface] = (e2bb.get(elface, 0) | bdry_bit)

        # compile the optemplate
        from struct import calcsize
        self.code = OperatorCompiler(
                max_vectors_in_batch_expr=220 // calcsize("P")
                )(
                self.prepare_optemplate_stage2(discr.mesh, optemplate_stage1,
                    discr.debug, type_hints=type_hints),
                type_hints=type_hints)

        # build the local kernels
        self.diff_kernel = self.discr.diff_plan.make_kernel(discr)

        if "dump_op_code" in discr.debug:
            from hedge.tools import open_unique_debug_file
            open_unique_debug_file("op-code", ".txt").write(
                    str(self.code))
コード例 #4
0
ファイル: execute.py プロジェクト: yangzilongdmgy/hedge
    def __init__(self, discr, optemplate, post_bind_mapper, type_hints={}):
        self.discr = discr
        self.elwise_linear_cache = {}

        from hedge.tools import diff_rst_flops, diff_rescale_one_flops, \
                mass_flops, lift_flops
        self.diff_rst_flops = diff_rst_flops(discr)
        self.diff_rescale_one_flops = diff_rescale_one_flops(discr)
        self.mass_flops = mass_flops(discr)
        self.lift_flops = sum(lift_flops(fg) for fg in discr.face_groups)

        optemplate_stage1 = self.prepare_optemplate_stage1(
            optemplate, post_bind_mapper)

        # build a boundary tag bitmap
        from hedge.optemplate import BoundaryTagCollector
        self.boundary_tag_to_number = {}
        for btag in BoundaryTagCollector()(optemplate_stage1):
            self.boundary_tag_to_number.setdefault(
                btag, len(self.boundary_tag_to_number))

        e2bb = self.elface_to_bdry_bitmap = {}

        for btag, bdry_number in self.boundary_tag_to_number.iteritems():
            bdry_bit = 1 << bdry_number
            for elface in discr.mesh.tag_to_boundary.get(btag, []):
                e2bb[elface] = (e2bb.get(elface, 0) | bdry_bit)

        # compile the optemplate
        from struct import calcsize
        self.code = OperatorCompiler(
            max_vectors_in_batch_expr=220 // calcsize("P"))(
                self.prepare_optemplate_stage2(discr.mesh,
                                               optemplate_stage1,
                                               discr.debug,
                                               type_hints=type_hints),
                type_hints=type_hints)

        # build the local kernels
        self.diff_kernel = self.discr.diff_plan.make_kernel(discr)

        if "dump_op_code" in discr.debug:
            from hedge.tools import open_unique_debug_file
            open_unique_debug_file("op-code", ".txt").write(str(self.code))