0Pricing
CUDA Academy · レッスン

ステンシルとスライディングウィンドウ

ハローセルを含む近傍領域をタイル化します。

「ステンシルとスライディングウィンドウ」はCoddyKit上の無料CUDA Academyレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはCUDA Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 CUDA Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

What a Stencil Is

A stencil computes each output from a fixed neighborhood of inputs, like averaging a pixel with the cells around it.

The Sliding Window

As you move along the array, the input window slides by one. Consecutive outputs share most of their inputs, so reuse is huge.

Perfect for Tiling

Because neighbors overlap, a tile loaded once feeds many outputs. Stencils are a textbook case where tiling shines.

Meet the Halo

To compute the edges of a tile you also need a few elements just outside it. Those extra border cells are called the halo.

Why the Halo Exists

The first thread in a tile needs its left neighbor, which belongs to the previous tile. Without halo cells that read goes wrong.

Sizing the Halo

For a radius-r stencil you load r extra cells on each side. A 3-point blur has radius 1, so one halo cell per side suffices.

A Padded Tile

Declare shared memory as blockDim plus 2 * radius so it holds the interior plus both halos in one tidy buffer.

__shared__ float tile[BLOCK + 2 * RADIUS];

Loading the Interior

Each thread first loads its own element into the tile at an offset of radius, leaving room for the left halo in front.

tile[threadIdx.x + RADIUS] = in[gid];

Loading the Halos

The first few threads do double duty, also fetching the left and right halo cells before the block synchronizes.

Then Sync and Stencil

After __syncthreads, each thread reads its neighbors entirely from the tile, never touching global memory again for that step.

Reuse Multiplier

Every interior value now serves 2r + 1 outputs from one shared-memory load. That is exactly the redundant traffic tiling removes.

Quick Check

Why does a tiled stencil need halo cells?

Recap

Stencils slide overlapping windows, so a halo of r extra cells per side lets a tile serve every output with one load each. ✅

よくある質問

「ステンシルとスライディングウィンドウ」レッスンは無料ですか?

はい。「ステンシルとスライディングウィンドウ」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、CUDA Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 CUDA Academyコースには全4レッスンが含まれています。

「ステンシルとスライディングウィンドウ」で何を学びますか?

ハローセルを含む近傍領域をタイル化します。 ブラウザで直接実行するハンズオンコードでCUDA Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

CUDA Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのCUDA Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。

「ステンシルとスライディングウィンドウ」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このCUDA Academyレッスンでコードを書いて実行できますか?

はい。すべてのCUDA Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. データ再利用の問題
  2. ロード・同期・計算パターン
  3. ステンシルとスライディングウィンドウ
  4. 端のタイルを処理する
← CUDA Academyに戻る