GPU 間のワーク分割
領域分割の戦略
「GPU 間のワーク分割」はCoddyKit上の無料CUDA Academyレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはCUDA Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 CUDA Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Many GPUs, One Job
Two GPUs can finish a job in roughly half the time, but only if you split the work. The art is partitioning: deciding which GPU handles which part.
Domain Decomposition
The classic strategy is to cut the data, not the code. With domain decomposition each GPU gets its own slice of the array or grid to process.
Slicing an Array
For a 1D array, just divide its length. Give the first chunk of elements to GPU 0 and the next chunk to GPU 1, and so on.
int chunk = n / count;Computing Each Offset
Every GPU needs the start of its slice. The offset for device d is simply d times the chunk size, marking where its data begins.
int offset = d * chunk;Allocate Per Device
Each GPU needs its own buffer. Set the device, then cudaMalloc space just for that card's slice instead of the whole array.
cudaSetDevice(d);
cudaMalloc(&dptr[d], chunk * sizeof(float));Copy Only the Slice
Upload to each GPU only the portion it owns. Copy from host[offset] into that device's buffer so no card holds data it will not touch.
Launch on Every Device
Loop over the GPUs, set each current, and launch the kernel on its slice. The launches are asynchronous, so all cards start working in parallel.
Gather the Results Back
When kernels finish, copy each device's output back into the right spot of the host array using its offset. The pieces reassemble into one result.
Mind the Leftover
If n does not divide evenly, the last GPU must handle the remainder. Give it the extra elements so nothing in the array is skipped.
int last = n - offset;Watch the Boundaries
Stencil and neighbor operations read across slice edges. Those halo regions must be shared between GPUs, or results at the borders go wrong.
Balance the Load
If one GPU is faster, an even split wastes it. Good load balancing gives the stronger card a bigger slice so both finish at the same time.
Quick Check
Recall the standard way to spread one large dataset across several GPUs.
Recap
You split data into slices, allocate and copy per device, launch on each, then gather results. Mind the remainder and halos. Next: copying directly GPU to GPU. ✨
よくある質問
「GPU 間のワーク分割」レッスンは無料ですか?
はい。「GPU 間のワーク分割」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、CUDA Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 CUDA Academyコースには全4レッスンが含まれています。
「GPU 間のワーク分割」で何を学びますか?
領域分割の戦略 ブラウザで直接実行するハンズオンコードでCUDA Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
CUDA Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのCUDA Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。
「GPU 間のワーク分割」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このCUDA Academyレッスンでコードを書いて実行できますか?
はい。すべてのCUDA Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- デバイスの列挙と選択
- GPU 間のワーク分割
- ピアツーピアメモリアクセス
- NCCL によるマルチ GPU