FORTRAN VS C ++,Fortran语言是否仍然持有任何优势,在数值分析的这些日子? [英] Fortran vs C++, does Fortran still hold any advantage in numerical analysis these days?

查看:192
本文介绍了FORTRAN VS C ++,Fortran语言是否仍然持有任何优势,在数值分析的这些日子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用C ++编译器,尤其是英特尔的人,并直接运用SIMD功能在你的C /能力的迅速发展C ++ codeS,并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.

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

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语言相比具有C ++严格别名语义,并已积极调整了几十年的数值表现。使用CPU使用的数据阵列往往有潜在的合作算法从Fortran实施中受益。

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.

编程语言点球不应该太认真对待,但15基准,Fortran语言位居第一速度上的的他们(英特尔Q6600一个核心),比任何其他单语言。你可以看到,那里的Fortran眼前一亮的基准是重数控的:

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:

  • spectral norm 27% faster
  • fasta 67% faster
  • mandelbrot 56% faster
  • pidigits 18% faster

反例:


  • K-核苷酸较慢的500%(这个基准测试的重点重上更复杂的数据结构和字符串处理,这是不的Fortran的强度)

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

您还可以看到一个摘要页面多少倍慢,其中显示了所有实现的Fortran语言code是平均最接近最快的实现为每个基准 - 尽管位数条比对C大得多++,Fortran语言表明不适合执行某些任务C ++是擅长的,但是你应该已经知道了。

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. 这是函数的速度非常关键,在Fortran语言重新实现它值得我的时间?

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

时的性能非常重要,因此我在学习Fortran的投资回报?

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

是否有可能使用像ATLAS一个库,而不是写code喽?

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

回答这些问题,需要您的code群和业务模式的详细知识,所以我不能回答这些。但是,是的,Fortran的实现往往比C ++实现更快。

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.

在你的决定的另一个因素是样品code的数量和可用的参考实现的数量。 Fortran语言的浓厚的历史意味着有丰富的可供下载,甚至有去图书馆数值code的。与往常一样,你需要通过它进行筛选,找到好东西。

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 VS C ++,Fortran语言是否仍然持有任何优势,在数值分析的这些日子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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