是否有任何简单的方法可以显式地使已经线程化的应用程序利用多核环境? (如果可用)。
第一个问题是如何确定我的运行时环境是否支持多核应用程序?
如果我确定可以使用多核功能,我可以显式分配线程在不同的核心上运行吗? 如果是这样,线程通信是由操作系统/硬件处理还是我必须亲自动手?
Is there any easy way to explicitly make an already threaded application utilise a multicore environment? (if avaliable).
The first problem would be how do I determine if my runtime environment supports multi-core applications?
If I then determine that I can use multi core functionality, can I explicitly assign threads to run on different cores? If so Is the thread communication handled by the OS/Hardware or do I have to get my hands dirty?
发布评论
评论(5)
如果您的应用程序已经正确线程化,则无需执行任何操作。 线程上下文执行和处理已为您完成。
现在说到线程,您的应用程序是否以利用内核的方式进行线程化? 您是否有将处理器密集型任务分成单独的线程。 如果没有,那么您将需要进行更改以将处理任务拆分为更多线程。 您可以使用Environment.ProcessorCount 获取核心计数,并在运行时为您的任务创建尽可能多的线程。
到目前为止,还没有任何方法可以将不正确的线程应用程序(单线程)变成利用所有处理器/核心的线程应用程序,除非您寻求未来的技术,例如 plinq 和 并行FX
If your application is already threaded properly, you dont have to do anything. Thread context execution and handling is done for you.
Now when it comes to threading, is your app threaded in a way to utilize the cores? do you have processor intensive tasks split into seperate threads. If not, then you will need to make changes to split up your processing tasks into more threads. You can use Environment.ProcessorCount to get the core count and make as many threads as appropriate at runtime for your tasks.
As of now, there is not really any way to make an improperly threaded app(single thread) into a threaded app taking advantage of all the processors/cores, unless you look to future technologies, such as plinq and Parallel FX
您好,我知道有 2 个关于
并行 C# 主页
查看有关 MS June CTP 的 Somasegars MSDN 博客用于并行 3.5 扩展
MSDN
该库由以下组件组成:
Hi there are 2 extentions that I know about
Parallel C# Homepage
Check out Somasegars MSDN blog on MS June CTP for parallel 3.5 extenstions
MSDN
The library is made up of the following components:
目前,您可以使用 Process.ProcessorAffinity,但将特定线程分配给特定处理器是在幕后隐式处理的。 在大多数情况下,这实际上是一件好事,因为使用实时性能和负载平衡信息的智能运行时通常可以比静态方式做得更好,至少对于主流多核运行的少核环境而言。
Currently, you can set the available processors for a given process using Process.ProcessorAffinity, but assigning specific threads to specific processors is handled under the hood implicitly. This is actually a good thing most of the time, as an intelligent runtime using real-time performance and load balance information can usually do a better job than you can statically, at least for the few-core context mainstream multicore operates in.
那就是问题所在。 如何制作线程应用程序,如何转换现有代码。 我想在 C# 中利用多核。 然而,ParallelFX 仍处于测试阶段。 我不会使用测试版进行开发。
而且,我不想再次更改所有代码(我从 VB 6 翻译了我的应用程序)。
今天,我收到 Packt Publishing 的时事通讯,宣布出版一本关于 C# 并行编程的新书。 C# 2008 和 2005 线程编程。 我认为它关注的是我们在各地博客上谈论的事情。 如何在不等待新的奇迹语言的情况下思考和开发线程应用程序。 看到完全致力于该主题的书籍很酷,因为我们有很多关于该主题的博客。 链接是 http:// /www.packtpub.com/beginners-guide-for-C-sharp-2008-and-2005-threaded-programming/book
我认为它应该得到一个机会。 当我购买时,我会让你知道我的反馈。
That's the problem. How to make a threaded application, how to convert your existing code. I want to exploit multi-core in C#. However, ParallelFX is still beta. I won't develop using a beta.
And, I don't want to change all the code again (I translated my apps from VB 6).
Today, I received a newsletter from Packt Publishing announcing a new book about parallel programming with C#. C# 2008 and 2005 Threaded Programming. I think it focuses in the things we are blogging about everywhere. How to think and develop a threaded application without waiting for a new miracle language. It's cool to see books entirely dedicated about the topic, because we have full of blogs about that. The link is http://www.packtpub.com/beginners-guide-for-C-sharp-2008-and-2005-threaded-programming/book
I think it deserves an apportunity. I'll let you know my feedback when I buy it.
在不讨论具体细节的情况下(我不确定有多少信息是公开的),.NET 框架的下一版本将更有助于做到这一点。 您可能不想或不需要考虑手动管理线程。 我确信在 PDC(10 月底)之后将会公开更多相关信息。
Without getting into specifics (I'm not sure how much information is public yet), the next version of the .NET framework will be more helpful with doing this. You will likely not want or need to be thinking about managing threads by hand. I'm sure more information will be public about this after PDC (end of October).