如何在Cython中使用诸如openMP之类的东西? [英] How to employ something such as openMP in Cython?

查看:76
本文介绍了如何在Cython中使用诸如openMP之类的东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我遇到了一个非常棘手的问题,我想我已经达到了使用普通python& amp;多重处理,所以我现在正尝试通过Cython并希望将其扩展到更低的水平.

Basically I have a problem that is pretty much embrassing parallel and I think I've hit the limits of how fast I can make it with plain python & multiprocessing so I'm now attempting to take it to a lower level via Cython and hopefully openMP.

因此,简而言之,我想知道如何在Cython中使用openMP,或者是否必须包装一些原始C代码并通过Cython加载/绑定到它?

So in short I am wondering how I can employ openMP with Cython, or if I'll have to wrap some raw C code and load/bind to it via Cython?

还是可以让Cython编译为C代码,然后修改C代码以添加openMP编译指示,然后编译为库并将其加载到Python中?

Or can I have Cython compile down to C code then modify the C code to add in the openMP pragmas in then compile to library and load it into Python?

推荐答案

根据 cython Wiki ,开发人员已经考虑过各种选择,但我认为他们还没有实现任何东西.

According to the cython wiki, the developers have thought about a variety of options, but I don't believe they have implemented anything yet.

如果您的问题令人尴尬地是并行的,并且您已经有一个多处理解决方案,为什么不让每个工作进程调用一些cython代码而不是python代码呢?

If your problem is embarrassingly parallel, and you already have a multi-processing solution, why not just get each worker process to call some cython code instead of python code?

这篇关于如何在Cython中使用诸如openMP之类的东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆