找回密码
 注册
Simdroid-非首页
查看: 266|回复: 6

[2. C/C++/C#] C++的速度有多快

[复制链接]
发表于 2005-3-23 18:27:34 | 显示全部楼层 |阅读模式 来自 日本
如果你认为FORTRAN的速度比C++快,请看看这里的检测数据。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
发表于 2005-3-24 08:10:41 | 显示全部楼层 来自 天津

Re:C++的速度有多快

Simdroid开发平台
这个东西我看过,C++借助新编写的类和模板确实比以前快了。但是有没有与Fortran做对比的例子呢?再者有多少搞数值计算的人知道这个东西呢?又有多少人再用呢?你周围有多少人在用呢?不是追求一个理论上的速度,而是看它在实际中所发挥的作用。
 楼主| 发表于 2005-3-24 09:43:14 | 显示全部楼层 来自 日本

Re:C++的速度有多快

但是有没有与Fortran做对比的例子呢  => All benchmark test in this article is compared with Fortran.

再者有多少搞数值计算的人知道这个东西呢? => I cannot say anything if you have no idea trying to understand it.

不是追求一个理论上的速度,而是看它在实际中所发挥的作用 => Blitz (http://www.oonumerics.org/blitz/) , e.g, adopted in this article, which is the flatform for scientific computing, is in real application now. You can find numbers of them, such as POOMA, ISIS, MTL, CPPLAPACK, all freeware, specified for scientific computing and in application also. Most are developed in America and Europe under the support with their government. If you keep trying to catch up with the current trend of scientific computing, yu wouldn't have such question.
发表于 2005-3-25 03:53:19 | 显示全部楼层 来自 美国

Re:C++的速度有多快

This is an article in 1997! It compares Blitz++ with Fortran77 not Fortran90! Come on! You can not compare a new thing with an old thing!
 楼主| 发表于 2005-3-25 10:18:59 | 显示全部楼层 来自 日本

To: freepu

You can not compare a new thing with an old thing!  => I think you doesnot mean C++ is older than Fortran 90, or the comparation between a new C++ and old Fortran is meaningless.

Fortran90与fortran77相比并没有什么根本的变化。90的有些机能加快了计算速度,如矩阵相乘,矢量点积函数的导入使这样的计算得以在低层次上实现;而如a(=0的表达式使编译器能充份利用现代计算机内存管理机能。另一些功能,如动态数组,自定义结构(TYPE,相当与C的struct,或C++的class)则理论上会降低计算速度。指针的导入则更可能给一知半解的用户带来不可测后果。另外90还试图给并行计算功能留下余地, 如FORALL。如果说新程序比旧的快,更多的是基于编译器的发展,使编译出的程序更快。

大概谁也不敢说那个Fortran程序库最快,但无疑BLAS是最快的程序库之一,下面的图比较了MTL(The matrix template library: http://www.osl.iu.edu/research/mtl/) 与BLAS的速度,可以参考。

当然用一两个比较就敢说C++比Fortran快过于狂妄。但可以说Fortran一定比C++的时代已经过去了。而且它们间的差距还会加大,理由很简单: 因为对Fortran编译器的开发以日渐停滞,而C++的则还在积极进行。

最后补充一句,本人并不认为C++是一个令人满意的语言,虽然其强大的功能令人难以放弃。因为对非专家而言,它太难把握,出错是极平常的事。也许采用Java, Python, Tcl/tk等来调用高完成度C++库是一个选择。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
发表于 2005-3-26 06:12:44 | 显示全部楼层 来自 美国

Re:C++的速度有多快

As you said, the most important part is compiler. It is hardly possible to compare two compilers aiming at two different languages. I admit that C++ has many many new features. I am using C++ for my daily work. But as to numerical calculation, I think there is almost no need to use these new fancy features. Personally, I still think Fortran is an elegant language to use in numerical calculation area.

If the work on Fortran compiler is stagnant and on C++ is moving forward rapidly, definitely the speed of C++ will exceed of Fortran. From this fact, you can tell Fortran is still very strong even there are less efforts put on the compiler. Think about it, C++ is trying to exceed Fortran!
 楼主| 发表于 2005-3-26 10:20:48 | 显示全部楼层 来自 日本

Re:C++的速度有多快

But as to numerical calculation, I think there is almost no need to use these new fancy features. Personally, I still think Fortran is an elegant language to use in numerical calculation area.  
——〉 Of course, you can decide which one is best to your work. But I cannot agree with you that there is no need to use the new object-oriented
philosophy. Even you don't consider something like "software crisis" here, don't you have no idea to program like that:

   matrix a, b,c;
   a= b+c
   a= b*c

  Tensor a,b,c
  a= b:c                 //tensor contraction
  a=b*c                 //inner product
  a=b.inverse()        //inversion of b
  double d=a.det()  //determination of a

  And in finite element software programmed by myself.
  element a;
  vector b=a.GetshapeFunction()
  matrix d=a.GetStiffMatrix(ELASTOPLASTICITY)
  
  Such style make a researcher of numerical analysis could focus on what they should focus but programming details. Doesn't that looks convinient?!

C++ is trying to exceed Fortran ——〉No, the philosophy of these two is completely different. They are completely different thine and the founder of C++ had no idea to just "exceed Fortran".
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Simapps系列直播

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-11-1 23:35 , Processed in 0.031364 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表