矩阵库哪里有速度? [英] Matrix library where's the speed ?

查看:102
本文介绍了矩阵库哪里有速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




最近我被委以翻译的任务。从Matlab到C ++的一些复杂的b $ b统计算法。我的目标是以matlab(最新版本)的速度快三倍。


我使用了各种技术(循环展开,循环干扰。 ..)和

尝试了一些矩阵库:newmat(对于大矩阵来说很慢),STL

(快速但不是很有用),手动编码(大脑消耗...... 。),和

最近Meschach ...

我很伤心和不高兴,写一个快速的程序是不明显的

可以击败matlab,即使是一个简单的向量或矩阵添加,...谁... b $ b告诉我matlab很慢......!

尽管我付出了很大的努力,matlab却很快特别是当

矩阵的大小增加时...


我的问题是:

什么样的提示,策略,编译器,现实世界professionnal

用于编写非常快的c ++代码?


Ps:我在XP上使用Dev-cpp / GCC。

Hi ,

Recently I have been commited to the task of "translating" some complex
statistical algorithms from Matlab to C++. The goal is to be three
times as fast as matlab ( the latest) .

I''ve used various techniques ( loop unrolling, loop jamming...) and
tried some matrix libraries : newmat (slow for large matrix) , STL
(fast but ..not usefull) , hand coding (brain consuming...), and
recently Meschach...
I am sad and upset that it is not obvious to write a fast program that
can beat matlab, even for a simple vector or matrix addition, ... Who
told me that matlab is slow...!
Despite my great effort, matlab is fast especially when the size of the
matrix increases...

My question is :
What kind of tips, strategy, compiler, the real world "professionnal"
use to write very fast c++ code ?

Ps : I am using Dev-cpp /GCC on XP.

推荐答案

Frank-O写道:
Frank-O wrote:

尽管我付出了很大的努力,但是matlab很快,特别是当

矩阵的大小增加时......


我的问题是:

什么样的提示,策略,编译器,现实世界expertnal

用于编写非常快的c ++代码?
Despite my great effort, matlab is fast especially when the size of the
matrix increases...

My question is :
What kind of tips, strategy, compiler, the real world "professionnal"
use to write very fast c++ code ?



你怎么知道事情很慢?你的单元测试是什么样的?


你有资料吗?我必须要问一个显而易见的事情:您是否编译了调试信息

关闭,并且优化已开启?


如果所有这些都失败了,您的下一步应该是是Blitz ++或类似的

Expression Metatemplates库。因此提升。


-

Phlip
http://www.greencheese.us/ZeekLand < - 不是博客!!!

How you know things are slow? What do your unit tests look like?

Did you profile? And I must ask the obvious: Did you compile with debug info
turned off, and optimizations turned on?

If all those fail, your next effort should be Blitz++ or a similar
Expression Metatemplates library. Thence Boost.

--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!


Frank- O写道:
Frank-O wrote:

最近我被委以翻译的任务。一些从bb到C ++的复杂统计算法。 [...剪辑...]


我的问题是:

什么样的提示,策略,编译器,真实世界" professionnal"

用来写非常快的c ++代码?
Recently I have been commited to the task of "translating" some
complex statistical algorithms from Matlab to C++. [...snip...]

My question is :
What kind of tips, strategy, compiler, the real world "professionnal"
use to write very fast c++ code ?



提示:使用快速算法,仅在测量后进行优化,这样你才能知道要优化的内容。战略?选择牺牲什么。它b / b
通常是性能价格的便携性。编译器?

英特尔C / C ++编译器很好。微软也不错。比如

和其他任何东西一样,你可以得到你付出的代价。投资工具

将帮助您识别性能瓶颈,然后工作

改善您的计划。


现在,所有这一切与C ++没什么关系。几乎每一种体面的语言都与b $ b相关。所以,下次你想问这个模糊的话题,试试''comp.software-eng''。


V

-

请在通过电子邮件回复时删除资金''A'

我没有回复最热门的回复,请不要''请问

Tips: use fast algorithms, optimize only after measuring so you
know what to optimize. Strategy? Choose what to sacrifice. It
is often portability for the price of performance. Compiler?
Intel C/C++ compiler is good. Microsoft isn''t bad either. Like
with anything else, you get what you pay for. Invest in tools
that will help you identify performance bottlenecks, then work
on improving your program.

Now, all this doesn''t really have much to do with C++. It is
relevant for pretty much every decent language. So, next time
you want to ask about such nebulous topic, try ''comp.software-eng''.

V
--
Please remove capital ''A''s when replying by e-mail
I do not respond to top-posted replies, please don''t ask


Frank-O写道:
Frank-O wrote:


Hi ,



[snip]

[snip]


>

我的问题是:

什么样的提示,策略,编译器,现实世界expertnal

用于编写非常快的c ++代码?


Ps:我正在使用Dev-cpp / GCC on XP。
>
My question is :
What kind of tips, strategy, compiler, the real world "professionnal"
use to write very fast c++ code ?

Ps : I am using Dev-cpp /GCC on XP.



在代码运行正确且正确后,请尝试:

1.编写代码以优化您的风格平台。

例如,ARM处理器可以有条件地执行

指令。替换如果布尔表达式的语句

可以帮助编译器利用这个功能。


2.删除分支。

大多数现代处理器喜欢预先获取大量指令。

然而,分支往往会使生活变得复杂并迫使许多人清除预取的指令并重新加载。
< br $>
-

Thomas Matthews


C ++新闻组欢迎辞:
http://www.slack.net/~shiva/welcome.txt

C ++常见问题: http://www.parashift.com/c++-faq- lite

C常见问题: http://www.eskimo.com/~scs/c-faq/top.html

alt.comp.lang.learn.c-c ++ faq:
http:// www.comeaucomputing.com/learn/faq/

其他网站:
http://www.josuttis.com - C ++ STL图书馆书籍
http://www.sgi.com/tech/stl - 标准模板库

After the code works robustly and correctly, try:
1. Writing code in a style that will optimize for your platform.
For example, the ARM processor can conditionally execute
instructions. Replacing "if" statements by boolean expressions
may help the compiler take advantage of this feature.

2. Remove branches.
Most modern processors love to pre-fetch a lot of instructions.
However, branches tend to complicate life and force many to
clear out the prefetched instructions and reload.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library


这篇关于矩阵库哪里有速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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