ublas与矩阵模板库(MTL4) [英] ublas vs. matrix template library (MTL4)

查看:266
本文介绍了ublas与矩阵模板库(MTL4)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在c ++中编写了一个用于双曲线偏微分方程的软件。几乎所有的符号都是向量和矩阵。除此之外,我需要线性代数求解器。是的,矢量和矩阵的大小可以相当大地变化(从例如1000到只能通过分布式存储器计算(例如,集群或类似的架构)解决的大小)。如果我住在乌托邦,我有一个线性解算器,它可以扩展到群集,GPU和多核。



当考虑应该代表变量的数据结构,我来accros的boost.ublas和MTL4。
这两个库都是blas级别3兼容的,MTL4实现稀疏求解器,比ublas快得多。它们都没有实现对多核处理器的支持,更不用说针对分布式内存计算的并行化。另一方面,MTL4的开发取决于2个开发人员的唯一努力(至少我理解),我敢肯定有一个原因,ublas是在boost库。此外,intel的mkl库包括将其结构与ublas绑定的示例。
我想将我的数据和软件绑定到数据结构,这将是坚实的,开发和维护很长一段时间。



最后,问题。你使用ublas和/或mtl4的经验是什么,你会推荐什么?



thanx,
mightydodol

解决方案

,我可能会去 BOOST :: uBLAS 。实际上,uBLAS的良好部署应该与MTL4的速度大致相同。



原因是存在 ATLAS (因此可以有效地实现共享内存并行化)的.de / software / boost-bindings>绑定针对您的计算机进行优化),以及供应商调整的实施,例如 Intel Math Kernel Library HP MLIB



通过这些绑定,uBLAS具有良好的ATLAS / BLAS库做数学应该足够快。如果你链接到给定的BLAS / ATLAS,你应该大致与使用编译器标志 -DMTL_HAS_BLAS ,并且很可能比根据他们自己的观看(示例参见此处,其中 GotoBLAS a>胜过MTL4)。



总而言之,只要你愿意使用一些BLAS库,速度不应该是你的决定性因素。可用性和支持更重要。你必须决定,MTL还是uBLAS更适合你。我倾向于uBLAS,因为它是BOOST的一部分,而MTL4目前只支持BLAS 选择性地。您还可能发现这个略微过时的科学C ++包的比较很有趣。一个大的BUT:对于你的要求(非常大的矩阵),我可能会跳过语法糖uBLAS或MTL,并称为BLAS的金属C接口/ LAPACK直接。但这只是我...另一个优点是,它应该更容易切换到 ScaLAPACK (分布式内存LAPACK,从来没有使用它)更大的问题。只是为了清楚:对于家庭问题,我不建议直接调用BLAS库。


I'm writing a software for hyperbolic partial differential equations in c++. Almost all notations are vector and matrix ones. On top of that, I need the linear algebra solver. And yes, the vector's and matrix's sizes can vary considerably (from say 1000 to sizes that can be solved only by distributed memory computing, eg. clusters or similar architecture). If I had lived in utopia, I'd had had linear solver which scales great for clusters, GPUs and multicores.

When thinking about the data structure that should represent the variables, I came accros the boost.ublas and MTL4. Both libraries are blas level 3 compatible, MTL4 implements sparse solver and is much faster than ublas. They both don't have implemented support for multicore processors, not to mention parallelization for distributed memory computations. On the other hand, the development of MTL4 depends on sole effort of 2 developers (at least as I understood), and I'm sure there is a reason that the ublas is in the boost library. Furthermore, intel's mkl library includes the example for binding their structure with ublas. I'd like to bind my data and software to the data structure that will be rock solid, developed and maintained for long period of time.

Finally, the question. What is your experience with the use of ublas and/or mtl4, and what would you recommend?

thanx, mightydodol

解决方案

With your requirements, I would probably go for BOOST::uBLAS. Indeed, a good deployment of uBLAS should be roughly on par with MTL4 regarding speed.

The reason is that there exist bindings for ATLAS (hence shared-memory parallelization that you can efficiently optimize for your computer), and also vendor-tuned implementations like the Intel Math Kernel Library or HP MLIB.

With these bindings, uBLAS with a well-tuned ATLAS / BLAS library doing the math should be fast enough. If you link against a given BLAS / ATLAS, you should be roughly on par with MTL4 linked against the same BLAS / ATLAS using the compiler flag -DMTL_HAS_BLAS, and most likely faster than the MTL4 without BLAS according to their own observation (example see here, where GotoBLAS outperforms MTL4).

To sum up, speed should not be your decisive factor as long as you are willing to use some BLAS library. Usability and support is more important. You have to decide, whether MTL or uBLAS is better suited for you. I tend towards uBLAS given that it is part of BOOST, and MTL4 currently only supports BLAS selectively. You might also find this slightly dated comparison of scientific C++ packages interesting.

One big BUT: for your requirements (extremely big matrices), I would probably skip the "syntactic sugar" uBLAS or MTL, and call the "metal" C interface of BLAS / LAPACK directly. But that's just me... Another advantage is that it should be easier than to switch to ScaLAPACK (distributed memory LAPACK, have never used it) for bigger problems. Just to be clear: for house-hold problems, I would not suggest calling a BLAS library directly.

这篇关于ublas与矩阵模板库(MTL4)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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