与专门的供应商库相比,C ++ Eigen库的性能如何? [英] How can the C++ Eigen library perform better than specialized vendor libraries?
问题描述
我正在查看性能基准: http://eigen.tuxfamily.org/ index.php?title = Benchmark
I was looking over the performance benchmarks: http://eigen.tuxfamily.org/index.php?title=Benchmark
我不禁注意到本征似乎始终优于所有专门的供应商库。问题是:怎么可能?有人会假定mkl / goto将使用处理器特定的调整代码,而本征则相当通用。
I could not help but notice that eigen appears to consistently outperform all the specialized vendor libraries. The questions is: how is it possible? One would assume that mkl/goto would use processor specific tuned code, while eigen is rather generic.
请注意 http://download.tuxfamily.org/eigen/btl-results-110323/aat.pdf ,本质上是一个dgemm。对于N = 1000,本征大约为17Gf,而MKL仅12Gf
Notice this http://download.tuxfamily.org/eigen/btl-results-110323/aat.pdf, essentially a dgemm. For N=1000 Eigen gets roughly 17Gf, MKL only 12Gf
推荐答案
本征的评估很懒。来自本征与BLAS / LAPACK的比较如何?:
Eigen has lazy evaluation. From How does Eigen compare to BLAS/LAPACK?:
对于涉及复杂表达式的运算,Eigen本质上比任何BLAS实现都要快
,因为它可以处理和优化
a全球范围内的整个操作-虽然BLAS迫使程序员
将复杂的操作分成与BLAS
固定功能API匹配的小步,由于引入
临时对象而导致效率低下。例如,参见Y = a X + b Y
操作的基准结果,该操作涉及两次调用BLAS level1例程,而Eigen
自动生成一个矢量循环。 p>
For operations involving complex expressions, Eigen is inherently faster than any BLAS implementation because it can handle and optimize a whole operation globally -- while BLAS forces the programmer to split complex operations into small steps that match the BLAS fixed-function API, which incurs inefficiency due to introduction of temporaries. See for instance the benchmark result of a Y = aX + bY operation which involves two calls to BLAS level1 routines while Eigen automatically generates a single vectorized loop.
基准是 Y = a * X + b * Y
,这是Eigen专门设计的。毫无疑问,图书馆在创建基准时胜出。您会注意到,更通用的基准测试(例如矩阵-矩阵乘法)对Eigen没有任何优势。
The second chart in the benchmarks is Y = a*X + b*Y
, which Eigen was specially designed to handle. It should be no wonder that a library wins at a benchmark it was created for. You'll notice that the more generic benchmarks, like matrix-matrix multiplication, don't show any advantage for Eigen.
这篇关于与专门的供应商库相比,C ++ Eigen库的性能如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!