第4章アルゴリズムの言語による実現:低水準プログラミング言語
THINK IT THROUGH考えてみよう
GPU ApplicationsGPUの応用
GPUs are high-performance parallel processors. Some major applications of GPUs include cryptocurrency mining, video games, and the dashboard computers embedded in automobiles. In 2021, there was a shortage of GPUs due to a “perfect storm” of world events. The COVID-19 pandemic complicated manufacturing, limiting the rate at which GPUs could be built. In response to the pandemic, demand for computers increased, as many workers were forced to work from home. Demand for video games also increased as people sought indoor entertainment. At the same time, cryptocurrency prices went up, which stimulated interest in mining cryptocurrency, so even more people tried to buy GPUs at the same time. All these events caused a severe shortage. Customers encountered long waiting lists for GPUs, or found that they were unavailable entirely. Scalpers sold GPUs at a substantial upcharge. Some people were unable to buy video games, or computers they needed to complete work. The shortages affected heavy industry; automobile manufacturers had to idle their factories, which impacted the factory workers’ livelihoods, and triggered a shortage in automobiles.
英語のヒント
GPUは、高性能な並列プロセッサーである。主な用途には、暗号資産のマイニング、ビデオゲーム、自動車のダッシュボードに組み込まれたコンピューターがある。2021年には、世界的な出来事が重なる「パーフェクト・ストーム」によって、GPU不足が起こった。新型コロナウイルスのパンデミックは製造を難しくし、GPUの生産速度を制限した。多くの労働者が在宅勤務を余儀なくされたため、パンデミックを受けてコンピューターの需要が増えた。人々が屋内の娯楽を求めたことで、ビデオゲームの需要も増えた。同時に暗号資産の価格が上がり、マイニングへの関心が刺激されたため、さらに多くの人が同時にGPUを買おうとした。これらの出来事すべてが、深刻な不足を引き起こした。購入者はGPUを長く予約待ちするか、まったく入手できないと知ることになった。転売業者は、価格を大幅に上乗せしてGPUを売った。ビデオゲームや、仕事を終えるために必要なコンピューターを買えない人もいた。不足は重工業にも影響し、自動車メーカーは工場を休止しなければならなかった。これにより、工場労働者の生計が影響を受け、自動車不足も引き起こされた。
This situation pitted knowledge workers, gamers, market speculators, and manufacturers against each other in a struggle for scarce resources.
英語のヒント
この状況は、知識労働者、ゲーマー、市場の投機家、メーカーを、乏しい資源の奪い合いで互いに対立させた。
To what degree is this a problem? Do computing professionals have a responsibility to offer a technical solution, such as a technological alternative to GPUs? Do they have a responsibility to anticipate these kinds of unintended consequences? How should policy makers handle a shortage for a critical resource?
英語のヒント
これはどの程度の問題だろうか。計算技術の専門家には、GPUに代わる技術など、技術的な解決策を提示する責任があるだろうか。この種の意図しない結果を予測する責任があるだろうか。政策立案者は、重要な資源の不足にどう対応すべきだろうか。
Parallel Programming並列プログラミング
Parallel programming involves writing code that divides a program’s task into parts, works in parallel on different processors, has the processors report back when they are done, and stops in an orderly fashion. C was not designed with parallel programming in mind, so we need to use third-party libraries for parallel programming in C. Some newer languages were designed with parallel programming facilities from the start.
英語のヒント
並列プログラミングでは、プログラムの仕事を複数の部分に分け、異なるプロセッサー上で並列に作業し、終わったらプロセッサーに報告させ、整然と終了するコードを書く。Cは並列プログラミングを念頭に設計されなかったため、Cで並列プログラミングを行うには、サードパーティーのライブラリーを使う必要がある。より新しい言語の中には、最初から並列プログラミングの機能を備えるよう設計されたものもある。
Parallel Programming Models and Languages並列プログラミングのモデルと言語
A parallel programming model is a high-level conception of how the programmer can control processors and the data that moves between them.
英語のヒント
並列プログラミングモデルは、プログラマーがプロセッサーと、その間を移動するデータをどのように制御するかという、大まかな構想である。
• Shared Memory: In the shared memory programming model, processes/tasks share a common address space, which they read and write to asynchronously. Various mechanisms such as locks/semaphores are used to control access to the shared memory, resolve contentions and to prevent race conditions and deadlocks. One example is SHMEM.
英語のヒント
• 共有メモリ:共有メモリのプログラミングモデルでは、プロセスやタスクが共通のアドレス空間を共有し、非同期に読書きを行う。ロックやセマフォなどの各種の仕組みを使って、共有メモリへのアクセスを制御し、競合を解消して、競合状態やデッドロックを防ぐ。例としてSHMEMがある。
• Threads: This programming model is a type of shared memory programming. A thread is a single “heavyweight” process can have multiple "lightweight", concurrent execution paths. A simple example of a thread includes a chat feature, video, or audio in an application like Microsoft Teams. Examples include Pthreads, OpenMP, Microsoft Threads, Java and Python threads, and CUDA threads for GPUs.
英語のヒント
• スレッド:このプログラミングモデルは、共有メモリプログラミングの一種である。スレッドでは、1つの「重い」プロセスが、複数の「軽い」並行実行経路を持てる。スレッドの単純な例として、Microsoft Teamsのようなアプリケーションのチャット機能、映像、音声がある。実装の例には、Pthreads、OpenMP、Microsoft Threads、JavaとPythonのスレッド、GPU用のCUDAスレッドがある。
• Message Passing: A parallel programming approach where separate processes communicate only by sending messages, not sharing memory. Each set of tasks use their own local memory during computation. Multiple tasks can reside on the same physical machine and/or across an arbitrary number of machines. One example is the Message Passing Interface (MPI) that was first developed in the 1990s.
英語のヒント
• メッセージパッシング:別々のプロセスがメモリを共有せず、メッセージの送信だけで通信する、並列プログラミングの手法。タスクの各集合は、計算中、それぞれのローカルメモリを使う。複数のタスクは、同じ物理マシン内にも、任意の台数のマシンにまたがっても、その両方にも置ける。例として、1990年代に初めて開発されたMessage Passing Interface(MPI)がある。
• Hybrid Model: A hybrid model combines more than one of the previously described programming models; currently, a common example of a hybrid model is the combination of the MPI with the threads model. Other examples of hybrid models include MPI with CPU-GPU using CUDA, MPI with Pthreads, and MPI with non-GPU.
英語のヒント
• ハイブリッドモデル:前述のプログラミングモデルを複数組み合わせたもの。現在の一般的な例は、MPIとスレッドモデルの組合せである。ほかには、MPIとCUDAを使うCPU–GPU、MPIとPthreads、MPIと非GPUの組合せがある。
To program in parallel, you can extend compilers (i.e., translate sequential programs into parallel programs), extend languages (i.e., add parallel operations on top of sequential language), add a parallel language layer on top of sequential language, and define a totally new parallel language and compiler system. The extend language strategy (2) is the most popular, and MPI/OpenMP are examples.
英語のヒント
並列プログラミングのためには、コンパイラーを拡張する(逐次プログラムを並列プログラムに変換する)、言語を拡張する(逐次言語の上に並列操作を加える)、逐次言語の上に並列言語の層を加える、完全に新しい並列言語とコンパイラーシステムを定義する、という方法がある。最もよく使われるのは、2番目の言語を拡張する方法であり、MPIやOpenMPがその例である。
THINK IT THROUGH考えてみよう
Multi-Threading Parallel Programmingマルチスレッドの並列プログラミング
Why is it important at this time for application developers to turn to the multi-threading parallel programming paradigm and new emerging computing technologies for their application needs?
英語のヒント
アプリケーションの開発者が、そのアプリケーションの必要を満たすために、マルチスレッドの並列プログラミングのパラダイムや、新しく登場している計算技術へ目を向けることは、なぜ今、重要なのだろうか。