Concurrency In Python 简明教程

System and Memory Architecture

在设计程序或并发系统时,需要考虑不同的系统和内存架构样式。这非常必要,因为一种系统和内存样式可能适用于一个任务,但可能对其他任务产生错误。

There are different system and memory architecture styles that need to be considered while designing the program or concurrent system. It is very necessary because one system & memory style may be suitable for one task but may be error prone to other task.

Computer system architectures supporting concurrency

迈克尔·弗林于 1972 年给出了对不同样式的计算机系统架构进行分类的法规。该分类定义了以下四种不同的样式 −

Michael Flynn in 1972 gave taxonomy for categorizing different styles of computer system architecture. This taxonomy defines four different styles as follows −

  1. Single instruction stream, single data stream (SISD)

  2. Single instruction stream, multiple data stream (SIMD)

  3. Multiple instruction stream, single data stream (MISD)

  4. Multiple instruction stream, multiple data stream (MIMD).

Single instruction stream, single data stream (SISD)

顾名思义,此类系统将具有一个序列输入数据流和一个执行数据流的单个处理单元。它们就像具有并行计算架构的单处理器系统。以下是 SISD 的架构 −

As the name suggests, such kind of systems would have one sequential incoming data stream and one single processing unit to execute the data stream. They are just like uniprocessor systems having parallel computing architecture. Following is the architecture of SISD −

ssid

Advantages of SISD

SISD 架构的优点如下 −

The advantages of SISD architecture are as follows −

  1. It requires less power.

  2. There is no issue of complex communication protocol between multiple cores.

Disadvantages of SISD

SISD 架构的缺点如下 −

The disadvantages of SISD architecture are as follows −

  1. The speed of SISD architecture is limited just like single-core processors.

  2. It is not suitable for larger applications.

Single instruction stream, multiple data stream (SIMD)

顾名思义,此类系统将具有多个输入数据流和数量的处理单元,这些处理单元可以在任何给定时间作用于单个指令。它们就像具有并行计算架构的多处理器系统。以下是 SIMD 的架构 −

As the name suggests, such kind of systems would have multiple incoming data streams and number of processing units that can act on a single instruction at any given time. They are just like multiprocessor systems having parallel computing architecture. Following is the architecture of SIMD −

simd

SIMD 的最佳示例是显卡。这些卡具有数百个单独的处理单元。如果我们讨论 SISD 和 SIMD 之间的计算差异,那么对于添加数组 [5, 15, 20][15, 25, 10], SISD 架构必须执行三个不同的添加运算。另一方面,使用 SIMD 架构,我们可以在单个添加运算中添加它们。

The best example for SIMD is the graphics cards. These cards have hundreds of individual processing units. If we talk about computational difference between SISD and SIMD then for the adding arrays [5, 15, 20] and [15, 25, 10], SISD architecture would have to perform three different add operations. On the other hand, with the SIMD architecture, we can add then in a single add operation.

Advantages of SIMD

SIMD 架构的优点如下 −

The advantages of SIMD architecture are as follows −

  1. Same operation on multiple elements can be performed using one instruction only.

  2. Throughput of the system can be increased by increasing the number of cores of the processor.

  3. Processing speed is higher than SISD architecture.

Disadvantages of SIMD

单指令多数据流架构的缺点如下 −

The disadvantages of SIMD architecture are as follows −

  1. There is complex communication between numbers of cores of processor.

  2. The cost is higher than SISD architecture.

Multiple Instruction Single Data (MISD) stream

具有多指令单数据流的数据流的系统具有多个处理器单元,这些处理器单元通过对同一数据集执行不同的指令来执行不同的操作。以下是多指令单数据流的架构 −

Systems with MISD stream have number of processing units performing different operations by executing different instructions on the same data set. Following is the architecture of MISD −

misd

多指令单数据流架构的代表者目前还不存在于商业领域。

The representatives of MISD architecture do not yet exist commercially.

Multiple Instruction Multiple Data (MIMD) stream

在使用多指令多数据流架构的系统中,多处理器系统中的每个处理器可以同时独立地针对不同的数据集执行不同的指令集。这与单指令多数据流架构相反,单指令多数据流架构对多个数据集执行单一操作。以下是多指令多数据流的架构 −

In the system using MIMD architecture, each processor in a multiprocessor system can execute different sets of instructions independently on the different set of data set in parallel. It is opposite to SIMD architecture in which single operation is executed on multiple data sets. Following is the architecture of MIMD −

mimd

常规的多处理器使用多指令多数据流架构。这些架构基本用于多个应用领域,如计算机辅助设计/计算机辅助制造、仿真、建模、通信交换机等。

A normal multiprocessor uses the MIMD architecture. These architectures are basically used in a number of application areas such as computer-aided design/computer-aided manufacturing, simulation, modeling, communication switches, etc.

Memory architectures supporting concurrency

在使用并发性和并行性等概念时,始终需要加快程序速度。计算机设计师找到的一种解决方案是创建共享内存多计算机,即具有单个物理地址空间的计算机,该地址空间由处理器具有的所有内核访问。在此情况下,可能有多种不同风格的体系结构,但以下三种是重要的体系结构样式 −

While working with the concepts like concurrency and parallelism, there is always a need to speed up the programs. One solution found by computer designers is to create shared-memory multi-computers, i.e., computers having single physical address space, which is accessed by all the cores that a processor is having. In this scenario, there can be a number of different styles of architecture but following are the three important architecture styles −

UMA (Uniform Memory Access)

在此模型中,所有处理器一致地共享物理内存。所有处理器对所有内存词都具有相等访问时间。每个处理器可能具有私有高速缓存。外围设备遵循一组规则。

In this model, all the processors share the physical memory uniformly. All the processors have equal access time to all the memory words. Each processor may have a private cache memory. The peripheral devices follow a set of rules.

当所有处理器对所有外围设备具有相等访问权限时,该系统称为 symmetric multiprocessor 。当只有一个或几个处理器可以访问外围设备时,该系统称为 asymmetric multiprocessor

When all the processors have equal access to all the peripheral devices, the system is called a symmetric multiprocessor. When only one or a few processors can access the peripheral devices, the system is called an asymmetric multiprocessor.

uma

Non-uniform Memory Access (NUMA)

在非一致存储器访问多处理器模型中,访问时间随内存词的位置而异。在此,共享内存物理上分布在所有处理器之间,称为局部内存。所有局部内存的集合形成所有处理器都可以访问的全局地址空间。

In the NUMA multiprocessor model, the access time varies with the location of the memory word. Here, the shared memory is physically distributed among all the processors, called local memories. The collection of all local memories forms a global address space which can be accessed by all the processors.

numa

Cache Only Memory Architecture (COMA)

一致存储器访问模型是非一致存储器访问模型的一个特殊版本。在此,所有分布式的主内存都转换为高速缓存。

The COMA model is a specialized version of the NUMA model. Here, all the distributed main memories are converted to cache memories.

coma