三重山括弧による起動
>>でカーネルを呼び出します。
「三重山括弧による起動」はCoddyKit上の無料CUDA Academyレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはCUDA Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 CUDA Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Launching Is Different
You do not call a kernel like a normal function. You launch it, telling the GPU how many threads to spin up at the same time. 🚀
The <<< >>> Syntax
The launch uses CUDA's special triple angle brackets. Inside them you give a launch configuration before the normal argument list.
myKernel<<<blocks, threads>>>(args);First Number: Blocks
The first value sets how many blocks launch. A block is a group of threads that run together and share fast on-chip memory.
myKernel<<<4, threads>>>(args); // 4 blocksSecond Number: Threads per Block
The second value sets threads per block. Total threads launched equals blocks times threads per block.
myKernel<<<4, 256>>>(args); // 1024 threadsArguments Come After
After the brackets, you pass the kernel's normal arguments in parentheses, just like any C++ call.
doubleIt<<<1, 256>>>(devicePtr);Launches Are Asynchronous
A launch is asynchronous: the CPU queues the work and keeps going immediately. The GPU runs the kernel in the background.
Configs Can Be Variables
The launch numbers do not have to be literals. You often compute the block count from your data size at runtime.
int blocks = (n + 255) / 256;
add<<<blocks, 256>>>(c, a, b, n);Using dim3 for 2D
For grids and blocks in 2D or 3D, you use a dim3 value. It bundles x, y, and z sizes into the launch.
dim3 threads(16, 16);
blur<<<grid, threads>>>(img);Picking Threads per Block
A safe default for threads per block is 128 or 256. Values must be multiples of 32 and stay at or below 1024.
kernel<<<blocks, 128>>>(data);A Bad Config Fails
If you ask for too many threads per block, the launch fails silently. You must check for errors right after launching.
kernel<<<1, 2048>>>(p); // too big, failsRead It Left to Right
Read a launch as: run this kernel across this many blocks of this many threads, with these arguments. Simple once it clicks.
vectorAdd<<<grid, block>>>(c, a, b, n);Quick Check
Time to check the launch configuration.
Recap: The Launch
You launch with kernel<<
よくある質問
「三重山括弧による起動」レッスンは無料ですか?
はい。「三重山括弧による起動」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、CUDA Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 CUDA Academyコースには全4レッスンが含まれています。
「三重山括弧による起動」で何を学びますか?
>>でカーネルを呼び出します。 ブラウザで直接実行するハンズオンコードでCUDA Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
CUDA Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのCUDA Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。
「三重山括弧による起動」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このCUDA Academyレッスンでコードを書いて実行できますか?
はい。すべてのCUDA Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。