.NET的数值计算的速度 [英] The speed of .NET in numerical computing

查看:177
本文介绍了.NET的数值计算的速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的经验中,.NET比原生code慢了2〜3倍。 (我实现了L-BFGS的多元优化)。

In my experience, .net is 2 to 3 times slower than native code. (I implemented L-BFGS for multivariate optimization).

我已经追踪了广告上的计算器来 http://www.centerspace.net/products/

I have traced the ads on stackoverflow to http://www.centerspace.net/products/

速度更是惊人,速度接近原生code。他们怎么能这样做呢? 他们说:

the speed is really amazing, the speed is close to native code. How can they do that? They said that:

Q值。是NMath纯.NET?

Q. Is NMath "pure" .NET?

一个。答案一定程度上取决于你的纯.NET的定义。 NMath是用C#,再加上一个小的托管C ++层。对于基本线性代数运算的性能更好,但是,NMath并依靠本土英特尔数学核心函数库(包括NMath)上。但也有没有的COM组件,无DLL的 - 只是.NET程序集。此外,所有的内存分配在托管C ++层和使用的原生code从托管堆中分配。

A. The answer depends somewhat on your definition of "pure .NET". NMath is written in C#, plus a small Managed C++ layer. For better performance of basic linear algebra operations, however, NMath does rely on the native Intel Math Kernel Library (included with NMath). But there are no COM components, no DLLs--just .NET assemblies. Also, all memory allocated in the Managed C++ layer and used by native code is allocated from the managed heap.

有人能解释更多的给我吗?

Can someone explain more to me?

谢谢!

推荐答案

关于C ++ / CLI的一点是正确的。要完成图片,只有两个附加的有趣之处:

The point about C++/CLI is correct. To complete the picture, just two additional interesting points:

  • .NET内存管理(垃圾收集器),显然不是这里的问题,因为NMath还是要看它

  • .NET memory management (garbage collector) obviously is not the problem here, as NMath still depends on it

性能优势实际上是由Intel MKL,它提供的实现多个CPU非常优化的提供。从我的角度来看,这是关键的一点。使用直线前进,naiv C / C ++ code不会必然给你性能优于C#/。NET,它有时甚至更糟。然而C ++ / CLI,您可以充分利用所有的脏的优化选项。

The performance advantage is actually provided by Intel MKL, which offers implementations extremely optimized for many CPUs. From my point of view, this is the crucial point. Using straight-forward, naiv C/C++ code wont necessarily give you superior performance over C#/.NET, it's sometimes even worse. However C++/CLI allows you to exploit all the "dirty" optimization options.

这篇关于.NET的数值计算的速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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