csharp中的性能,科学模拟 [英] Performance in csharp, scientific simulation

查看:125
本文介绍了csharp中的性能,科学模拟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今年夏天我被要求写一个蒙特卡罗代码来模拟

磁性纳米粒子。对于非物理学家来说,基本上它是一个模拟,其中大部分时间是通过循环遍历500个左右粒子阵列中的每个

对来进行的,以便计算

互动潜力。我在csharp写了到目前为止我写的东西因为我想要学习它,虽然它会给我一些很好的经验。我现在开始明白.net和托管代码一般

远远落后于性能。最终我可能会将
移植到c ++,不受管理,因为模拟代码也需要

才能在linux上运行。

我的问题是:

我现在可以用我的chsarp代码做什么来加速性能。

基本上每秒运行数百次的主要方法涉及计算矢量点积(使用我自己的矢量类)和

指数的
。将方法标记为不安全会加速任何事情>

I was asked this summer to write a monte carlo code to simulation
magnetic nanoparticles. For the nonphysicists, basicly it is a
simulation where most of the time is taken up by looping through each
pair in an array of 500 or so particles, in order to calculate
interaction potential. I wrote what i have so far in csharp because i
wanted to learn it and though it would give me some good experience. I
am now beginning to understand that .net and managed code in general
lags far behind performance wise. Eventually i am probably going to
have to port to c++, unmanaged, because the simulation code will need
to run on linux as well.
My question is this:
What can i do in my chsarp code right now to speed up the performance.
The main method that is run hundreds of times a second basicly involves
calculating a vector dot product (using my own vector class), and an
exponential. Would marking the method unsafe speed anything up>

推荐答案

我相信在得出结论之前,您必须对您的申请进行分析。

除了内存使用,你可以找出大部分时间花在哪些方法

/ calls并检查代码是否在那里是最佳的。


您可能知道,通过

参数获取结果可以获得理想的性能。简单的迭代并不总是最好的方法。这包括

名字:-)

HTH

Alex


" Michael Gorbach <毫克****** @ gmail.com>在消息中写道

news:11 ********************** @ f14g2000cwb.googlegr oups.com ...
I believe before jumping to conclusions you must profile your application.
Aside from memory use you can find out which methods are taking most of time
/ calls and check if code is optimal in there.

As you might know, ideal performance is achieved by fetching result by
argument. Simple iteration is not always the best approach. This includes
names :-)

HTH
Alex

"Michael Gorbach" <mg******@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
今年夏天我被要求写一个monte carlo代码来模拟磁性纳米粒子。对于非物理学家来说,基本上它是一种模拟,其中大部分时间是通过在500个左右的粒子阵列中循环每对
来计算,以便计算相互作用的潜力。我在csharp写了我到目前为止的内容,因为我想学习它,虽然它会给我一些很好的经验。我现在开始明白.net和托管代码一般
远远落后于性能。最终我可能不得不移植到c ++,不受管理,因为模拟代码也需要在linux上运行。
我的问题是:
什么可以我现在用我的chsarp代码来加速性能。
每秒运行数百次的主要方法基本上涉及计算矢量点积(使用我自己的矢量类),以及
指数。将方法标记为不安全会加速任何事情>
I was asked this summer to write a monte carlo code to simulation
magnetic nanoparticles. For the nonphysicists, basicly it is a
simulation where most of the time is taken up by looping through each
pair in an array of 500 or so particles, in order to calculate
interaction potential. I wrote what i have so far in csharp because i
wanted to learn it and though it would give me some good experience. I
am now beginning to understand that .net and managed code in general
lags far behind performance wise. Eventually i am probably going to
have to port to c++, unmanaged, because the simulation code will need
to run on linux as well.
My question is this:
What can i do in my chsarp code right now to speed up the performance.
The main method that is run hundreds of times a second basicly involves
calculating a vector dot product (using my own vector class), and an
exponential. Would marking the method unsafe speed anything up>



我相信在得出结论之前,您必须描述您的申请。

除了内存使用你可以找出哪些方法花费大部分时间

/来电并检查代码是否是最佳的。


你可能知道,理想通过

参数获取结果来实现性能。简单的迭代并不总是最好的方法。这包括

名字:-)

HTH

Alex


" Michael Gorbach <毫克****** @ gmail.com>在消息中写道

news:11 ********************** @ f14g2000cwb.googlegr oups.com ...
I believe before jumping to conclusions you must profile your application.
Aside from memory use you can find out which methods are taking most of time
/ calls and check if code is optimal in there.

As you might know, ideal performance is achieved by fetching result by
argument. Simple iteration is not always the best approach. This includes
names :-)

HTH
Alex

"Michael Gorbach" <mg******@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
今年夏天我被要求写一个monte carlo代码来模拟磁性纳米粒子。对于非物理学家来说,基本上它是一种模拟,其中大部分时间是通过在500个左右的粒子阵列中循环每对
来计算,以便计算相互作用的潜力。我在csharp写了我到目前为止的内容,因为我想学习它,虽然它会给我一些很好的经验。我现在开始明白.net和托管代码一般
远远落后于性能。最终我可能不得不移植到c ++,不受管理,因为模拟代码也需要在linux上运行。
我的问题是:
什么可以我现在用我的chsarp代码来加速性能。
每秒运行数百次的主要方法基本上涉及计算矢量点积(使用我自己的矢量类),以及
指数。将方法标记为不安全会加速任何事情>
I was asked this summer to write a monte carlo code to simulation
magnetic nanoparticles. For the nonphysicists, basicly it is a
simulation where most of the time is taken up by looping through each
pair in an array of 500 or so particles, in order to calculate
interaction potential. I wrote what i have so far in csharp because i
wanted to learn it and though it would give me some good experience. I
am now beginning to understand that .net and managed code in general
lags far behind performance wise. Eventually i am probably going to
have to port to c++, unmanaged, because the simulation code will need
to run on linux as well.
My question is this:
What can i do in my chsarp code right now to speed up the performance.
The main method that is run hundreds of times a second basicly involves
calculating a vector dot product (using my own vector class), and an
exponential. Would marking the method unsafe speed anything up>



如何进行此应用程序分析?我或多或少新的

严肃的编程,所以任何帮助都会被贬低。

另外,你是什么意思通过参数获取结果?


是否有关于你可以建议的表现的参考资料?

how do i go about doing this application profiling? im more or less new
to serious programming so any help would be appreaciated.
Also, what do you mean by "fetching result by argument?"

Are there are references on performance you could suggest?


这篇关于csharp中的性能,科学模拟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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