cpu VS gpu

1,110 阅读1分钟

image.png

www.omnisci.com/technical-g…

这篇文章最经典的是下面提供的一个 youtube 的视频,兼职是非常完美的阐述了 cpu 和 gpu 的区别。

youtu.be/-P28LKWTzrI

你可以理解为 cpu 是一个全能型选手,能干很多事情,也就是说它的指令集很多。但是 gpu 是一个职业性选手,他的指令集非常少,所以非常擅长和适合做专业的事情,是数学计算和重复计算方面的专家。

www.boston.co.uk/info/nvidia…

并且 gpu 的核数非常多,所以可以并行做大量的重复计算。

image.png

在很多文章中,对 cpu 的描述都用了同样一个词汇:versatile,去 marriam webster 上查这个单词,给出的第一个解释就是:able to do many different things。

具体来讲,引用文章中的一段话

CPUs, to be sure, remain essential. Fast and versatile, CPUs race through a series of tasks requiring lots of interactivity. Calling up information from a hard drive in response to user’s keystrokes, for example.

By contrast, GPUs break complex problems into thousands or millions of separate tasks and work them out at once.

gpu 是把一个任务拆分成可以并行进行的多个小任务,然后快速的计算出结果。但是 cpu 的任务通常都是串行的。

Architecturally, the CPU is composed of just a few cores with lots of cache memory that can handle a few software threads at a time. In contrast, a GPU is composed of hundreds of cores that can handle thousands of threads simultaneously.

这里也顺便说下 thread 和 process 的区别,上面的引用内容里提到了 thread,可见 thread 是 cpu 运行的最小单元,就是计算的单元。而 process 是一个资源共享的单元。