将多线程加大对单处理器的计算速度 [英] Will Multi threading increase the speed of the calculation on Single Processor

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

问题描述

在单处理器,将多线程的可适当增加计算速度。大家都知道,多线程用于增加用户的响应和sepating UI线程和线程计算来实现。但是,让我们来谈谈只有控制台应用程序。将多线程增加计算速度。难道我们得到culculation结果快,当我们通过多线程计算。

On a single processor, Will multi-threading increse the speed of the calculation. As we all know that, multi-threading is used for Increasing the User responsiveness and achieved by sepating UI thread and calculation thread. But lets talk about only console application. Will multi-threading increases the speed of the calculation. Do we get culculation result faster when we calculate through multi-threading.

关于多内核是什么,将多线程的可适当增加速度还是不行。

what about on multi cores, will multi threading increse the speed or not.

请帮助我。如果您有任何材料,详细了解线程。请留言。

Please help me. If you have any material to learn more about threading. please post.

编辑:
我一直在问一个问题,在任何给定的时间,只有一个线程被允许在单一内核上运行。如果是这样,为什么人们在控制台应用程序使用多线程。

I have been asked a question, At any given time, only one thread is allowed to run on a single core. If so, why people use multithreading in a console application.

在此先感谢,
戒日

Thanks in advance, Harsha

推荐答案

在笼统,没有也不会加快东西。

In general terms, no it won't speed up anything.

presumably同样的工作总正在做,但现在有更多的线程和上下文切换的开销。

Presumably the same work overall is being done, but now there is the overhead of additional threads and context switches.

在使用超线程(两个虚拟处理器)的单处理器那么答案就可能。

On a single processor with HyperThreading (two virtual processors) then the answer becomes "maybe".

最后,即使只有一个CPU或许一些线程可以推到GPU或其它硬件?这是有点从单处理器的情况越来越远,但可以在技术上是实现多线程,从单核PC上的速度增长方式。

Finally, even though there is only one CPU perhaps some of the threads can be pushed to the GPU or other hardware? This is kinda getting away from the "single processor" scenario but could technically be way of achieving a speed increase from multithreading on a single core PC.

编辑:现在你的问题提到了多核计算机上的多线程应用程序。
再次,非常笼统,这将提供一个全面的速度提升到你的计算。
然而,增加(或缺乏)将取决于算法如何并行的是,内存和缓存的争用和程序员的技能,当谈到没有锁定或饥饿问题编写并行code

your question now mentions multithreaded apps on a multicore machine. Again, in very general terms, this will provide an overall speed increase to your calculation. However, the increase (or lack thereof) will depend on how parallelizable the algorithm is, the contention for memory and cache, and the skill of the programmer when it comes to writing parallel code without locking or starvation issues.

这篇关于将多线程加大对单处理器的计算速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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