多核处理器与向量处理器

转自: http://www.vonwei.com/post/2outof52.html


52 Things: Number 2: What is the difference between a multi-core processor and a vector processor?

Posted by David McCann,原文地址http://bristolcrypto.blogspot.com/2014/10/52-things-number-2-what-is-difference.html

 同样先给出英文原文博客,再在后面给出翻译理解和补充。

On the face of it, you may be confused as to what the difference is between these two processors. After all, you may be familiar with words like parallel computing and come across these two different types of processor. So what are the differences between them? This is the question of this week's 52Things Every Cryptography PhD Student should know. But before we get into the nitty gritty of it, why don't we first have a look at the concept these two different processors are part of, namely parallel computing.

        

What is parallel computing?

Before answering this question we first need to consider the conventional “serial” model of processing. Let's do so by imagining some problem we need to solve. The way serial computing solves this problem is by viewing it as a number of steps (instructions) which the processor deals with in sequential order. The processor deals with each of the instructions and then at the end, the answer comes out and the problem is solved. Whilst being a wonderful way of solving the problem it does however imply a bottleneck in the speed of solving it. Namely, the speed of the processor at executing the individual instructions. This is fine if the problem isn’t too large, but what happens when we have to deal with larger problems or want to compute things faster? Is there a way of increasing the speed of computation without the bottleneck of the speed of the processor?

The answer as you might have guessed is yes and it comes in the form of something called parallel computing. What parallel computing does to the problem we are trying to solve is to break it down into smaller problems, each of which can be computed separately at the same time. In this way, the problem is distributed over different processing elements which perform each of these different sub problems simultaneously, providing a potentially significant increase in speed of computation – the amount of speed up depends on the algorithm and can be determined by Amdahl's law [1]. So how does this all work? How can you process things in such a way as this? Well two solutions to the problem are multi-core and vector processors.

        

What is a multi-core processor?

A multi-core processor is a single computing component that carries out parallel computing by using multiple serial processors to do different things at the same time. The sub problems of the bigger problem discussed earlier are each solved by a separate processor allowing programs to be computed in parallel. It's like having multiple people working on a project where each person is given a different task to do, but all are contributing to the same project. This might take some extra organising to do, but the overall speed of getting the project completed is going to be faster.

        

What is a vector processor?

A vector processor is a processor that computes single instructions (as in a serial processor) but carries them out on multiple data sets that are arranged in one dimensional arrays (unlike a standard serial processor which operates on single data sets). The idea here is that if you are doing the same thing many times to different data sets in a program, rather than executing a single instruction for each piece of data why not do the instruction to all the sets of data once? The acronym SIMD (Single Instruction Multiple Data) is often used to denote instructions that work in this way.

        

What is the difference?

So that's the general idea, let's sum up with an example. Let's say we want roll 4 big stones across a road and it takes one minute to do each roll. The serial processor rolls them one by one and so takes four minutes. The multi core processor with two cores has two people to roll stones so each one rolls two stones, it takes two minutes. The vector processor gets a long plank of wood, puts it behind all four stones and pushes them all in one, taking one minute. The multi core processor has multiple workers, the vector processor has a way of doing the same thing to multiple things at the same time.

 

下面是翻译与补充整理:

         首先介绍并行计算,然后再介绍这两种处理器的区别。

         什么是并行计算?先考虑传统的串行处理模式,假设需要解决某个问题,串行计算的方式是将该问题视为若干个步骤(或者指令),处理器使用顺序序列的方式处理这些指令,当所有指令处理完成之后会出现最终的问题结果,从而解决了问题。不过,串行处理方式在速度上存在瓶颈。当问题不是太大时,这种方式可行。但是,当处理大问题或者想要更快的计算更多事情,是否有能克服处理器速度瓶颈并增加计算速度的方法呢?答案就是并行计算。并行计算将要解决的问题分解为很多小问题,每个小问题可以被同时独立的进行计算。通过这种方式,问题分发给不同的处理元素,每个处理元素同步的执行其中一个子问题,会显著的增加计算的速度。速度增加量依赖算法,由阿姆达尔定律[1]确定。所有这一切是如何工作的,如何通过这种方式处理事件呢?两个很好的方案分别是多核处理器,和向量处理器。

         什么是多核处理器?一个多核处理器是一个独立计算组件,通过使用多个串行处理器来执行并行计算,每个串行处理器执行一个不同的计算,这些计算同步进行。也就是说,一个大问题的每个子问题都由一个独立的处理器去计算以达到并行的效果。就像多个人执行一个大项目,每个人处理一个不同的任务,但都同时为同一个项目在作出贡献。这一点可能需要其他的组织来实现,不过项目的整体速度是加快了。

         什么是向量处理器?向量处理器计算指令的方式与串行处理器一致,但是串行处理器只能处理单一数据集,而向量处理器可以直接操作一维数组(向量)指令集。其基本思路是,如果你正在一个程序中反复多次的做同一件事,每次使用不同的数据集,通常思路是对每个数据集执行一个独立的指令,向量处理器是对所有数据集只执行一次指令即可。SIMD(单指令多数据)通常用于表示指令按照这种方式工作。

         相信大家对多核处理器都比较熟悉,对向量处理器陌生一点,下面列出维基百科关于向量处理器的解释[2]:“向量处理器,又称数组处理器,是一种实现了直接操作一维数组(向量)指令集的中央处理器(CPU)。这与一次只能处理一个数据的标量处理器正相反。向量处理器可以在特定工作环境中极大地提升性能,尤其是在数值模拟或者相似领域。向量处理器最早出现于20世纪70年代早期,并在70年代到90年代期间成为超级计算机设计的主导方向,尤其是多个克雷(Cray)平台。由于常规处理器设计性价比的快速下降,基于向量处理器的超级计算机在90年代末逐渐让出了主导地位。现在,绝大多数商业化的CPU实现都能够提供某种形式的向量处理的指令,用来处理多个(向量化的)数据集,也就是所谓的SIMD(单一指令、多重数据)。常见的例子有 VIS, MMX, SSE, AltiVec AVX。向量处理技术也能在游戏主机硬件和图形加速硬件上看到。在2000年,IBM,东芝和索尼合作开发了Cell处理器,集成了一个标量处理器和八个向量处理器,应用在索尼的PlayStation 3游戏机和其他一些产品中。其他CPU设计还可能包括多重指令处理多重(向量化的)数据集的技术——也就是所谓的MIMD(多重指令、多重数据)——并实现了VLIM。此类设计通常用于特定应用场合,而不是面向通用计算机的市场化产品。在富士通的 FR-V VLIW/vector处理器中,组合使用了两种技术。”

         多核处理器和向量处理器有何不同?这里通过一个例子来说明,可以忘记上面描述的一切,记住这个例子即可。假设我们想要将四个大石头滚到马路的另一边,平均滚动每个石头需要花费1分钟。串行处理器会逐一的滚动每个石头,将花费4分钟时间。拥有两个核的多核处理器让两个人去滚石头,即每人滚两个,最终花费2分钟。向量处理器找一根长木板,放到四个大石头后面,推木板即可同时滚动四个石头,最终只需要1分钟。多核处理器相当于拥有多个工人,而向量处理器拥有一种方法,可以同时对多件事进行相同的操作。

 

[1] http://en.wikipedia.org/wiki/Amdahl%27s_law

[2]http://zh.wikipedia.org/wiki/%E5%B9%B6%E8%A1%8C%E5%90%91%E9%87%8F%E5%A4%84%E7%90%86%E6%9C%BA


你可能感兴趣的:(多核处理器与向量处理器)