在两个核心上运行一个线程
当前的架构是否支持在单个系统的多个内核上运行相同的单线程?在这种情况下会涉及到什么样的问题呢?
Do current architectures provide support for running the same single thread on multiple cores of a single system? What kind of issues would be involved in such a situation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您基本上是在问,顺序指令是否会自动并行化?实现并行执行的方法有很多种,根据工作负载的不同,效率水平也不同。这也可能发生在不同的级别,在μarch(与你的问题相关)、ISA、操作系统等......
如果我能正确假设,并尝试回答我相信你的问题。
理论上是可行的,但尚未在商用硬件上实现。因此有许多更高级别的并行化方法。
You're basically asking, are sequential instructions automatically parallelized? There are many ways to implement parallel execution, with different levels of efficiency based on the work load. This can also happen at different levels, at the µarch (related to your question) , the ISA, the OS, and etc...
If I can assume correctly, and attempt to answer what I believe your asking.
It is theoretically possible, but hasn't been implemented on commercially available commodity hardware. Hence the many higher level methods for parallelization.
据我所知没有。
线程可以在不同的核心上停止并重新启动,但线程本身不能并行运行。
如果线程中有可以并行运行的代码,则应该将其分成两个线程。
Not that I know of.
A thread can be stopped an started again on a different core but a thread in and by itself can not run parallel.
If you have code in a thread that could run parallel, you should split it up in two threads.
这实际上会减慢线程的速度。每次线程切换核心时,都需要转移前一个核心的所有状态。理想情况下,线程应保留在一个核心上。
您认为在多核上运行会带来哪些优势?
This would actually slow down the thread. Every time a thread switches cores, all the state of the previous core needs to be transfered. Ideally a thread would stay on one core.
What advantages are you thinking will come from running on multiple cores?
不,我认为不存在这样的事情..
Nope, I don't think there exists such a thing..
它不存在,因为硬件不允许,但这是一个理论上可以通过英特尔的一些独创性消除的瓶颈。
It does not exist because the hardware doesn't permit but this is a bottleneck that could theoretically be eliminated with some ingenuity from Intel.