Skip to Content
AIシステム性能エンジニアリング (Japanese Edition)
book

AIシステム性能エンジニアリング (Japanese Edition)

by Chris Fregly
November 2025
Intermediate to advanced
1060 pages
18h 47m
Japanese
O'Reilly Media, Inc.
Content preview from AIシステム性能エンジニアリング (Japanese Edition)

第11章 インターカーネル ・パイプライニング、同期、およびCUDAストリーム順序メモリ割り当て

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

これまで、単一カーネルでSMを稼働させるため、カーネル内部のツール(cuda::pipeline 、ダブルバッファリング、ワープ特殊化(ローダー/演算/ストアーワープ)、永続カーネル、DSMEM/TMAを用いたスレッドブロッククラスタ)に焦点を当ててきた。本章ではそれらのカーネルを維持しつつ、CUDAストリーム、イベント、ストリーム順序メモリ割り当て器を用いて、カーネル間およびバッチ間でパイプライン化する手法を示す。要するに、第10章ではカーネル内部の遅延を隠蔽することに焦点を当てた。本章では、カーネル間およびGPUとホスト間の遅延を隠蔽する方法を示す。

この種のカーネル間並行処理は、実世界のワークロードにおいてGPUの全エンジンを稼働状態に保つために不可欠である。現代のGPUでピーク利用率を達成するには、GPUの演算エンジンとダイレクトメモリアクセス(DMA)エンジンを並列に稼働させ続ける必要がある。

CUDA ストリームはこのカーネル間並行処理の基盤を提供する。非同期メモリ操作、細粒度の同期、CUDA グラフ(本章で簡単に紹介し、次章で詳しく扱う)を組み合わせることで、ホスト側のストールを回避する高効率なパイプラインを構築できる。

CUDAストリームによるカーネル実行のオーバーラッピング

CUDAストリームとは、 操作(カーネル起動、メモリコピー、メモリ割り当て)のシーケンスであり、発行された順序で実行される。図11-1に示すように、CPUからGPUへ2つのストリームを使用して5つのカーネルを起動すると考える。

Diagram showing the sequence of five kernels launched from the CPU to two GPU streams, illustrating the concurrent execution of operations in CUDA streams.
図11-1. CPUからGPU上で動作する2つのストリームへ5つのカーネルを起動する

ここでは、ker_Aker_B がストリーム2で実行され、ker_1ker_2ker_3 がストリーム1で実行されている。ハードウェアリソースが許容する限り、全てのカーネルは互いに、またCUDAストリーム間で重なり合うことができる。

CPUは、ストリームが非同期にカーネル操作を実行している間も、作業(cpu_code_1cpu_code_2) )を継続できる。これら5つのカーネルを2つのCUDAストリーム上で起動するコードは次の通りだ:

#include <cstdio>
#include <cuda_runtime.h>

__global__ void ker_A()  { /* ... do some work ... */ }
__global__ void ker_B()  { /* ... do some work ... */ }

__global__ void ker_1()  { /* ... do some work ... */ }
__global__ void ker_2()  { /* ... do some work ... */ }
__global__ void ker_3()  { /* ... do some work ... */ }

int main() {
    // 1) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

注目すべきレーダーのトレンド2026年1月 (Japanese Edition)

注目すべきレーダーのトレンド2026年1月 (Japanese Edition)

Mike Loukides

Publisher Resources

ISBN: 0642572281526