0

我必须在某些算法中利用 PpenMP,为此我需要一些数学函数,例如MATLAB 中可用的eig或者svd它在 MATLAB 中非常快。我已经使用 OpenMP 尝试了以下库

  1. GSL - GNU 科学图书馆

  2. Eigen C++ 模板库

但我不知道为什么我的 OpenMP 并行代码比串行代码慢得多,可能是库中有问题,或者函数randomeig或者svd阻塞?我不知道如何弄清楚,有人可以建议我哪个与 OpenMP 最兼容的数学库。

4

3 回答 3

2

I can recommend Intel's MKL; note that it costs money which may affect your decision. I neither know nor care what language(s) it is written in, just so long as it provides APIs callable from my chosen language. Mine is Fortran, but it has bindings for C too

If you look around SO you'll find many questions from people whose first (or second or third) OpenMP programs were actually slower than their serial versions. Look at some of the answers. Don't conclude that there is a magic bullet, in the shape of a library, to make your code faster. Instead, realise that it is most likely that you've written a poorly-parallelised program and fix that.

Finally, if you have an installation of Matlab, don't expect to be able to write your own routines to outperform Matlab's. I won't say it can't be done, but I think you'll find it very difficult.

于 2012-07-12T10:05:10.380 回答
1

我认为您只想找到已经线程化的 lapack (或相关例程)的快速实现,但是从您的问题中很难分辨。High Performance Mark 建议使用 MKL,这是一个很好的例子;其他包括ATLASFLAME,它们是开源的,但需要做一些工作才能构建。

于 2012-07-12T14:30:12.127 回答
1

GSL 与 OpenMP 兼容。您可以试用免费试用版的英特尔数学内核库。如果加速不是那么快,那么代码可能无法并行化。您可能希望在英特尔线程检查器中调试并查看正在运行的线程的详细信息,这可能有助于了解瓶颈所在。

于 2012-07-12T10:07:59.843 回答