Fortran和C ++,Fortran在数值分析中还有什么优势吗? [英] Fortran vs C++, does Fortran still hold any advantage in numerical analysis these days?

查看:272
本文介绍了Fortran和C ++,Fortran在数值分析中还有什么优势吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着C ++编译器,尤其是英特尔编译器的快速发展,以及在C / C ++代码中直接应用SIMD函数的能力,Fortran是否仍然在数值计算世界中拥有任何真正的优势?



我来自应用数学背景,我的工作涉及大量的数值分析,计算,优化等,严格定义性能要求。



我几乎不知道任何关于Fortran,我有一些经验在C / CUDA / matlab(如果你认为后者作为一种计算机语言开始),我的日常任务涉及分析非常大的数据10GB大矩阵),似乎该程序至少花费2/3的时间在内存访问(这就是为什么我把一些工作给GPU),你们人们认为它可能值得我的效果为我尝试至少在我的代码的一些性能关键部分的fortran例程以提高我的程序的性能?



因为复杂性和事情需要完成涉及,

解决方案

Fortran具有严格的别名语义,相比之下, C ++,并已积极调整数值性能数十年。使用CPU处理数据数组的算法通常有可能从Fortran实现中受益。



编程语言的注释不应该被认为太重要,在15个基准测试中,Fortran在其中四个的速度上排名第一(对于英特尔Q6600单核),超过任何其他单一语言。你可以看到Fortran发出的基准是大量的数字:





反例:




  • k-核苷酸慢500%(这个基准主要集中在更复杂的数据结构和字符串处理,这不是Fortran的力量)



您还可以查看摘要页面多少次慢表明,在所有实现中,Fortran代码平均最接近每个基准的最快实现 - 尽管分位数条大于C ++,表示Fortran不适合C ++擅长的一些任务,但你应该知道。



所以,你需要问自己的问题:


  1. 这个功能的速度是如此重要,以便在Fortran中重新实现它是值得的吗?


  2. 是否可以使用


回答这些问题需要详细了解您的代码库和业务模型,所以我不能回答这些。但是,是的,Fortran的实现通常比C ++的实现更快。



你的决定的另一个因素是示例代码的数量和可用的参考实现的数量。 Fortran的强大历史意味着有丰富的数字代码可供下载,甚至与图书馆的旅行。和往常一样,你需要通过它来筛选好的东西。


With the rapid development of C++ compilers,especially the intel ones, and the abilities of directly applying SIMD functions in your C/C++ codes, does Fortran still hold any real advantage in the world of numerical computations?

I am from an applied maths background, my job involves a lot of numerical analysis, computations, optimisations and such, with a strictly defined performance-requirement.

I hardly know anything about Fortran, I have some experience in C/CUDA/matlab(if you consider the latter as a computer language to begin with), and my daily task involves analysis of very large data (e.g. 10GB-large matrix), and it seems the program at least spend 2/3 of its time on memory-accessing (thats why I send some of its job to GPU), do you people think it may worth the effects for me to trying the fortran routine on at least some performance-critical part of my codes to improve the performance of my program?

Because the complexity and things need to be done involved there, I will only go that routine if only there is significant performance benefit there, thanks in advance.

解决方案

Fortran has strict aliasing semantics compared to C++ and has been aggressively tuned for numerical performance for decades. Algorithms that uses the CPU to work with arrays of data often have the potential to benefit from a Fortran implementation.

The programming languages shootout should not be taken too seriously, but of the 15 benchmarks, Fortran ranks #1 for speed on four of them (for Intel Q6600 one core), more than any other single language. You can see that the benchmarks where Fortran shines are the heavily numerical ones:

Counterexample:

  • k-nucleotide 500% slower (this benchmark focuses heavily on more sophisticated data structures and string processing, which is not Fortran's strength)

You can also see a summary page "how many times slower" that shows that out of all implementations, the Fortran code is on average closest to the fastest implementation for each benchmark -- although the quantile bars are much larger than for C++, indicating Fortran is unsuited for some tasks that C++ is good at, but you should know that already.

So the questions you will need to ask yourself are:

  1. Is the speed of this function so critical that reimplementing it in Fortran is worth my time?

  2. Is performance so important that my investment in learning Fortran will pay off?

  3. Is it possible to use a library like ATLAS instead of writing the code myself?

Answering these questions would require detailed knowledge of your code base and business model, so I can't answer those. But yes, Fortran implementations are often faster than C++ implementations.

Another factor in your decision is the amount of sample code and the quantity of reference implementations available. Fortran's strong history means that there is a wealth of numerical code available for download and even with a trip to the library. As always you will need to sift through it to find the good stuff.

这篇关于Fortran和C ++,Fortran在数值分析中还有什么优势吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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