4

My code uses a lot of repetitive and largely algebraic operations that are suitable for MATLAB/FORTRAN style vector operations.

I have been considering making a switch to std::valarray or even Blitz++ to take advantage of this. But before making the switch, how can I profile the degree to which one of the main contributors to the performance gap between C++ and FORTRAN - pointer aliasing - is effecting the performance of my code, short of declaring everything with restrict and testing the difference.

Does Visual Studio 2012 / 2013 provide some way of achieving this? Maybe a different IDE?

4

1 回答 1

0

C/C++ 语言没有经过优化,在数学方面表现不佳。对于这些操作,我只建议尝试更改语言,或者,如果您真的想继续使用 c/c++,请极其谨慎地编写。不同的语言被指定以最好的方式做他们所做的事情,但它几乎从来都不是同一件事。

据我所知,没有办法更好地优化 C/C++ 中大多数已经存在的函数,尤其是非标准包(boost),因为它们应该尽可能简单。调试包也重载了调试功能,因此它们速度较慢,但​​我还看到一些具有安全检查的发布功能,例如“对象是否属于我”或“订阅者超出范围检查”。如果这是关于原子函数,如别名、自动指针、其他指针类型或类似的东西,它们就再好不过了,它们会尽可能地工作。

您也可以尝试告诉编译器您想要更高的压缩级别,如果可能的话,这可能会加快速度,但正如我之前所说,使用专为数学设计的语言来进行数学运算。最终,如果您可以从 fortran 或其他语言制作 asm 对象,您可以将此文件链接到您的 c/c++ 代码。

于 2013-11-06T21:28:10.580 回答