是否可以知道哪些 SciPy / NumPy 函数在多个内核上运行?
我试图明确找出 SciPy/NumPy 中的哪些函数在多个处理器上运行。例如,我可以在 SciPy 参考手册中读到 SciPy 使用此功能,但我更感兴趣的是到底哪些函数确实运行并行计算,因为并非所有函数都运行并行计算。理想的情况当然是当您键入 help(SciPy.foo) 时包含它,但情况似乎并非如此。
任何帮助将不胜感激。
最好的,
马蒂亚斯
I am trying to figure out explicitly which of the functions in SciPy/NumPy run on multiple processors. I can e.g. read in the SciPy reference manual that SciPy uses this, but I am more interested in exactly which functions do run parallel computations, because not all of them do. The dream scenario would of course be if it is included when you type help(SciPy.foo), but this does not seem to be the case.
Any help will be much appreciated.
Best,
Matias
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这个问题最好解决您使用的 BLAS/LAPACK 库,而不是 SciPy/NumPy。
某些 BLAS/LAPACK 库(例如 MKL)本身使用多个内核其他实现可能不会。
以 scipy.linalg.solve 为例,这是它的源代码(为了清楚起见,省略了一些错误处理代码):
如您所见,它只是两个 LAPACK 函数系列的薄包装(例如
DPOSV
和DGESV
)。SciPy 级别不存在并行性,但您可以在系统上使用多个内核来观察该函数。唯一可能的解释是您的 LAPACK 库能够使用多个内核,无需 NumPy/SciPy 执行任何操作来实现这一点。
I think the question is better addressed to the BLAS/LAPACK libraries you use rather than to SciPy/NumPy.
Some BLAS/LAPACK libraries, such as MKL, use multiple cores natively where other implementations might not.
To take
scipy.linalg.solve
as an example, here's its source code (with some error handling code omitted for clarity):As you can see, it's just a thin wrapper around two families of LAPACK functions (exemplified by
DPOSV
andDGESV
).There is no parallelism going on at the SciPy level, yet you observe the function using multiple cores on your system. The only possible explanation is that your LAPACK library is capable of using multiple cores, without NumPy/SciPy doing anything to make this happen.