我的站点

一个系统软件工程师的随手涂鸦

Date: 一月 5, 2016

CPU,GPU和GPGPU的区别

下面摘自Why are we still using CPUs instead of GPUs?

GPUs have far more processor cores than CPUs, but because each GPU core runs significantly slower than a CPU core and do not have the features needed for modern operating systems, they are not appropriate for performing most of the processing in everyday computing. They are most suited to compute-intensive operations such as video processing and physics simulations.

GPU(Graphics Processing Unit)core数量比CPU的多,它是显卡(video card)的CPU。由于它的指令集不如CPU强大,但是core数量多,所以适合做一些相对简单的,计算密集性的运算:比如图像处理等等。GPGPU(General Purpose Graphics Processing Unit)则不仅仅只做图像处理的相关运算,也会做一些一般性的运算。

更新:计算机屏幕上的图像是如何显示出来的?这个帖子给了很好的解释:

The GPU has a series of registers that the BIOS maps. These permit the CPU to access the GPU’s memory and instruct the GPU to perform operations. The CPU plugs values into those registers to map some of the GPU’s memory so that the CPU can access it. Then it loads instructions into that memory. It then writes a value to a register that tells the GPU to execute the instructions the CPU loaded into its memory.

The information consists of the software that the GPU needs to run. This software is bundled with the driver and then the driver handles the responsibility split between the CPU and GPU (by running portions of its code on both devices).

The driver then manages a series of “windows” into GPU memory that the CPU can read from and write to. Generally, the access pattern involves the CPU writing instructions or information into mapped GPU memory and then instructing the GPU, through a register, to execute those instruction or process that information. The information includes shader logic, textures, and so on.

简单地讲,CPU会把要显示的图像和指令存到显卡(video card)的register中,然后通知GPU(显卡上的CPU)去执行画图命令。 此外,wiki百科上的这张图形象地描述了整个过程:

CUDA_processing_flow_(En)

参考资料:

 

C++要点笔记(20)——内联方法(inline method)

下文摘自C++ Primer Plus

123

C++要点笔记(19)——内联函数(inline function)

下文摘自C++ Primer Plus

Capture

C++要点笔记(18)——类(class)包含哪些部分

下文摘自C++ Primer Plus

Capture

Haskell笔记 (8)—— 类型变量(type variables)

参看下面程序:

> :t head
head :: [a] -> a

这里的a不是typeHaskell中的类型以大写字母开头),而是type variale,可以代表任一类型,有点类似于其它编程语言的generics。含有type variable的函数称之为polymorphic functions

现在可以知道为什么type名字必须以大写字母开头,这是为了与type variable名字区分开。type variable必须以小写字母开头。 

此外:

You can always tell a type variable from a normal variable by context, because the languages of types and functions are separate: type variables live in type signatures, and regular variables live in normal expressions.

type variable存在于type signature中,而regular variable则存在于正常的表达式中。

 

Powered by WordPress & Theme by Anders Norén