プリンキピア

第4章アルゴリズムの言語による実現:低水準プログラミング言語

4.3 Parallel Programming Models4.3 並列プログラミングのモデル

Learning Objectives学習目標
By the end of this section, you will be able to:
この節を終えると、次のことができるようになる。
• Define parallel computing and related terminology
• 並列計算と関連用語を定義する。
• Discuss parallel programming approaches
• 並列プログラミングの手法を論じる。
So far, our programs have run on a single at a time and the assumption is that the underlying machine only supported a single GPU core. A CPU core is a chip consisting of billions of transistors that function according to an instruction or opcode. It is like a single processor. While there is a lot that we can do with these single-core programs, there is also a need for programs to run in parallel, meaning that they execute code on multiple CPUs, cores, or computers at the same time. In parallel programming, bigger tasks are split into smaller ones, and they are processed in parallel, sharing the same memory. Parallel programming is trending toward being increasingly needed and widespread as time goes on. Many computers now come equipped with a graphics processing unit (GPU), which is a massively parallel processor that supplements a CPU. GPUs were originally designed for rendering real-time graphics in video games and are sometimes called “video cards.” A typical GPU has thousands of cores, although each is weaker than a CPU core. Parallel techniques are essential for making use of GPUs.
英語のヒント
これまでのプログラムは、一度に1つで動作し、その基盤となるマシンはGPUコアを1つしか備えないと仮定していた。CPUコアは、命令またはオペコードに従って動作する数十億個のトランジスターからなるチップであり、1つのプロセッサーのようなものである。こうした単一コアのプログラムでも多くのことができるが、プログラムを並列に動かす必要もある。つまり、複数のCPU、コア、コンピューター上で、同時にコードを実行するということである。並列プログラミングでは、大きな仕事を小さな仕事に分割し、同じメモリを共有しながら並列に処理する。時間がたつにつれて、並列プログラミングの必要性と普及は高まっている。現在、多くのコンピューターはグラフィックス処理装置(GPU)を備える。GPUは、CPUを補う超並列プロセッサーである。もともとはビデオゲームのリアルタイム画像を描画するために設計され、「ビデオカード」と呼ばれることもある。一般的なGPUには数千個のコアがあるが、各コアはCPUコアより弱い。GPUを活用するには、並列処理の技術が不可欠である。

Parallel Computing Overview並列計算の概要

In the 20th century, a computer typically had only one processor. Now, a CPU chip typically holds not just one processor, but multiple processors built into a single computer chip. Each individual processor built into a CPU is a core. A multicore processor is a CPU chip that has multiple cores. Multicore CPUs are prevalent; smartphones and budget PCs typically have two to four cores, and high-end PCs have eight or more cores. The trend is for these core counts to increase over time.
英語のヒント
20世紀のコンピューターは、通常、プロセッサーを1つしか持たなかった。現在のCPUチップには、1つだけでなく、複数のプロセッサーが1枚のコンピューターチップ上に組み込まれているのが一般的である。CPU内の個々のプロセッサーを、コアという。マルチコアプロセッサーは、複数のコアを持つCPUチップである。マルチコアCPUは広く普及しており、スマートフォンや低価格PCは通常2〜4コア、高性能PCは8コア以上を備える。これらのコア数は、時とともに増える傾向にある。
By default, a program runs on one core at a time. That means that a four-core computer can run up to four programs at full speed at the same time. That capability is occasionally useful, but more often a user wants a single high-demand program to make full use of their computer. This is the case with productivity software, games, embedded systems, and Web server software. For this to work, the program needs to be coded in a way that explicitly divides work among multiple cores.
英語のヒント
既定では、プログラムは一度に1つのコアで動く。したがって、4コアのコンピューターでは、最大4つのプログラムを同時に全速力で動かせる。この能力が役立つ場合もあるが、多くの場合、ユーザーは負荷の高い1つのプログラムに、コンピューターを十分に活用させたい。業務用ソフトウェア、ゲーム、組込みシステム、Webサーバーソフトウェアがそれに当たる。そのためには、複数コアへ作業を明示的に分担させるよう、プログラムを書く必要がある。
Fundamentally, in order to use multiple cores, a program needs to work in “parallel.” That means that multiple cores are working together at the same time (Figure 4.30). A real-world example of parallel work is a factory assembly line. If an assembly line has twenty workers, then at any given moment twenty people are working in parallel. This concept of parallel work also applies to software. The parallelism concepts discussed here are:
英語のヒント
基本的に、複数のコアを使うには、プログラムを「並列」に動かす必要がある。これは、複数コアが同時に連携して作業するという意味である(図4.30)。現実の並列作業の例が、工場の組立ラインである。組立ラインに20人の作業員がいれば、どの時点でも20人が並列に働いている。この並列作業の概念は、ソフトウェアにも当てはまる。ここで扱う並列性の概念は、次のとおりである。
• parallel computer: a multiple-processor system that supports parallel programming.
• 並列コンピューター:並列プログラミングに対応する、複数プロセッサーのシステム。
• parallel computing: the practice of making productive use of parallel computers.
• 並列計算:並列コンピューターを生産的に利用する実践。
• parallel programming: a computer programming technique that provides for executing code in parallel on multiple processors.
• 並列プログラミング:複数のプロセッサー上でコードを並列に実行するための、コンピュータープログラミング技術。
Figure 4.30

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典

Figure 4.30 This diagram illustrates how multiple computer programs can be executed as tasks on a multi-core machine either in parallel on separate individual cores using parallel computing or in sequence (on a single or on multiple cores) using serial computing. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図4.30 マルチコアマシンで、複数のコンピュータープログラムをタスクとして実行する方法を示す。並列計算では、別々のコアで並列に実行できる。逐次計算では、1つまたは複数のコア上で、順番に実行する。(出典表記:著作権者 Rice University、OpenStax、CC BY 4.0ライセンス)
There are two related but distinct terms that we should define at this point: concurrent programming, which refers to any situation where multiple programs or tasks are running simultaneously, regardless of whether they are using multiple processors or sharing one processor; and distributed computing, which is a more specific form of parallel programming where processors are working together in parallel, but the processors are in multiple connected computers, not a single computer. Concurrent programming is a broader term than parallel programming, while distributed computing usually refers to massively parallel programs that run on hundreds or thousands of servers, usually at large companies such as Amazon, Google, the NSA, and the NIH.
英語のヒント
ここで、関連はあるが異なる2つの用語を定義しておこう。並行プログラミングとは、複数のプロセッサーを使うか、1つのプロセッサーを共有するかを問わず、複数のプログラムやタスクが同時に動いている状況を指す。分散計算は、より限定された並列プログラミングの形で、プロセッサーが並列に連携して働くが、それらは1台のコンピューターではなく、接続された複数のコンピューター内にある。並行プログラミングは、並列プログラミングより広い意味を持つ。分散計算は通常、数百台から数千台のサーバー上で動く超並列プログラムを指し、Amazon、Google、NSA、NIHのような大きな組織で使われることが多い。