并行编码与多线程(在单个CPU上) [英] Parallel coding Vs Multithreading (on single cpu)

查看:119
本文介绍了并行编码与多线程(在单个CPU上)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以在单个CPU上互换使用并行编码"和多线程编码"吗?

can we use interchangeably "Parallel coding" and "Multithreading coding " on single cpu?

我在这两个方面经验都不多, 但我想将我的编码样式更改为以上任何一种.

i am not much experience in both, but i want to shift my coding style to any one of the above.

正如我现在发现的那样,许多单一的应用程序已经过时了,这对于将来的软件行业来说是一个更好的职业前景吗?

As i found now a days many single thred application are obsolete, which would be better for future software industy as a career prospect?

推荐答案

多线程与并行编码/计算之间肯定存在重叠,但目标处理体系结构之间存在主要差异.

There is definitely overlap between multithreading and parallel coding/computing, with the main differences in the target processing architecture.

多线程已用于在具有共享内存的单个CPU上的单个进程内利用并发的优势.在具有多个CPU的计算机上运行相同的程序可能会显着提高速度,但通常是一个奖励,而不是预期的(直到最近).许多操作系统具有线程模型(例如 pthreads ),该模型可受益于但不需要多个CPU.

Multithreading has been used to exploit the benefits of concurrency within a single process on a single CPU with shared memory. Running the same programs on a machine with multiple CPUs may result in significant speedup, but is often a bonus rather than intended (until recently). Many OSes have threading models (e.g. pthreads), which benefit from but do not require multiple CPUs.

多处理是用于并行编程的标准模型,该编程针对多个CPU,从大型计算机上具有多个CPU的早期SMP机器到多个计算机上的集群,以及现在可以回到单台计算机上的许多CPU/内核. MPI 是可以在许多不同体系结构中使用的标准.

Multiprocessing is the standard model for parallel programming targeting multiple CPUs, from early SMP machines with many CPUs on a big machine, then to cluster computing across many machines, and now back to many CPUs/cores on a single computer. MPI is a standard that can work across many different architectures.

当然,可以使用带有 OpenMP 之类的语言框架的线程对并行设计进行编程.我听说过依赖于理论上可以在任何地方运行的独立处理的多组件GUI/应用程序.实际上,前者要多于后者.

Of course, one can program a parallel design using threads with language frameworks like OpenMP. I've heard of multicomponent GUIs/applications that rely on separate processing that could theoretically run anywhere. Practically, there's more of the former than the latter.

主要区别可能是程序在多台计算机上运行时,使用多线程是不现实的,并且共享内存的现有应用程序将无法正常工作.

Probably the main distinction is when the program runs across multiple machines, where it's not practical to use multithreading, and existing applications that share memory will not work.

这篇关于并行编码与多线程(在单个CPU上)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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