示例#1
0
    def _arg_names_and_decls(self, codegen_state):
        implemented_data_info = codegen_state.implemented_data_info
        arg_names = [iai.name for iai in implemented_data_info]

        arg_decls = [
            self.idi_to_cgen_declarator(codegen_state.kernel, idi)
            for idi in implemented_data_info
        ]

        # {{{ occa compatibility hackery

        from cgen import Value
        if self.target.occa_mode:
            from cgen import ArrayOf, Const
            from cgen.ispc import ISPCUniform

            arg_decls = [
                Const(ISPCUniform(ArrayOf(Value("int", "loopy_dims")))),
                Const(ISPCUniform(Value("int", "o1"))),
                Const(ISPCUniform(Value("int", "o2"))),
                Const(ISPCUniform(Value("int", "o3"))),
            ] + arg_decls
            arg_names = ["loopy_dims", "o1", "o2", "o3"] + arg_names

        # }}}

        return arg_names, arg_decls
示例#2
0
    def get_global_arg_decl(self, name, shape, dtype, is_written):
        from loopy.target.c import POD  # uses the correct complex type
        from cgen import Const
        from cgen.ispc import ISPCUniformPointer, ISPCUniform

        arg_decl = ISPCUniformPointer(POD(self, dtype, name))

        if not is_written:
            arg_decl = Const(arg_decl)

        arg_decl = ISPCUniform(arg_decl)

        return arg_decl
示例#3
0
    def emit_sequential_loop(self, codegen_state, iname, iname_dtype, lbound,
                             ubound, inner):
        ecm = codegen_state.expression_to_code_mapper

        from loopy.target.c import POD

        from pymbolic.mapper.stringifier import PREC_NONE
        from cgen import For, InlineInitializer

        from cgen.ispc import ISPCUniform

        return For(
            InlineInitializer(ISPCUniform(POD(self, iname_dtype, iname)),
                              ecm(lbound, PREC_NONE, "i")),
            ecm(p.Comparison(var(iname), "<=", ubound), PREC_NONE, "i"),
            "++%s" % iname, inner)
示例#4
0
    def get_value_arg_decl(self, name, shape, dtype, is_written):
        result = super().get_value_arg_decl(name, shape, dtype, is_written)

        from cgen import Reference, Const
        was_const = isinstance(result, Const)

        if was_const:
            result = result.subdecl

        if self.target.occa_mode:
            result = Reference(result)

        if was_const:
            result = Const(result)

        from cgen.ispc import ISPCUniform
        return ISPCUniform(result)
示例#5
0
 def wrap_temporary_decl(self, decl, scope):
     from cgen.ispc import ISPCUniform
     return ISPCUniform(decl)