_jitcode.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:jitcode 作者: neurophysik 项目源码 文件源码
def generate_helpers_C(self, chunk_size=100):
        """
        translates the helpers to C code using SymEngine’s `C-code printer <https://github.com/symengine/symengine/pull/1054>`_.

        Parameters
        ----------
        chunk_size : integer
            If the number of instructions in the final C code exceeds this number, it will be split into chunks of this size. See `large_systems` on why this is useful.

            If there is an obvious grouping of your helpers, the group size suggests itself for `chunk_size`.

            If smaller than 1, no chunking will happen.
        """

        if self.helpers:
            get_helper = symengine.Function("get_general_helper")
            set_helper = symengine.Function("set_general_helper")

            for i,helper in enumerate(self.helpers):
                self.general_subs[helper[0]] = get_helper(i)
            self.render_and_write_code(
                    (set_helper(i, helper[1].subs(self.general_subs)) for i,helper in enumerate(self.helpers)),
                    name = "general_helpers",
                    chunk_size = chunk_size,
                    arguments = self._default_arguments() + [("general_helper","double *__restrict const")],
                    omp = False,
                )

        self._helper_C_source = True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号