0Pricing
CUDA Academy · 课时

数据复用问题

了解朴素内核为何反复读取全局内存

数据复用问题 是 CoddyKit 上的免费 CUDA Academy 课时。 这是第 1 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 CUDA Academy 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 CUDA Academy 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

The Hidden Cost

A kernel can be correct yet slow because it keeps fetching the same data from slow global memory over and over. 🐢

Memory Is the Bottleneck

On the GPU, arithmetic is cheap but reaching global memory is expensive. Many kernels wait on memory far more than they compute.

Data Reuse Defined

Data reuse means one value loaded from global memory is used by many computations instead of being read again each time.

A Naive Stencil

Picture blurring an image. Each output pixel averages its neighbors, so every input pixel gets read by several different threads.

out[i] = (in[i-1] + in[i] + in[i+1]) / 3.0f;

Counting the Reads

In that blur, the value in[i] is read by threads i-1, i, and i+1. The same byte travels across the slow PCIe-fed bus three times.

Redundancy Adds Up

With a wider window or a 2D grid, each element may be re-read dozens of times. This redundant traffic dominates the runtime.

Bandwidth Is Finite

Global memory has a fixed peak bandwidth. Reading the same data repeatedly wastes that budget on bytes you already had.

Compute Sits Idle

While warps stall waiting on repeated global loads, the math units sit idle. You paid for cores you are barely using. 😴

Arithmetic Intensity

Arithmetic intensity is the ratio of math operations to bytes moved. Low intensity means memory, not compute, limits you.

The Goal: Read Once

The fix is to load each needed value once into fast on-chip storage, then let many threads reuse it from there.

Enter Shared Memory

That fast on-chip storage is shared memory. Staging data there is the foundation of every tiling optimization ahead.

Quick Check

Why is a naive stencil kernel often slow?

Recap

Naive kernels re-read shared data from global memory, wasting bandwidth and stalling compute. Tiling exists to load once and reuse. ✅

常见问题解答

「数据复用问题」课时是免费的吗?

是的 — 「数据复用问题」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 CUDA Academy 课程的其余内容,请升级到 CoddyKit PRO。 CUDA Academy 课程共包含 4 节课。

「数据复用问题」这节课中我会学到什么?

了解朴素内核为何反复读取全局内存 你通过在浏览器中直接运行的动手代码来练习 CUDA Academy,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 CUDA Academy 需要有经验吗?

无需任何先前经验。CoddyKit 上的 CUDA Academy 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 1 节课,共 4 节。

「数据复用问题」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 CUDA Academy 课中编写并运行代码吗?

能。每节 CUDA Academy 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 数据复用问题
  2. 加载—同步—计算模式
  3. 模板与滑动窗口
  4. 处理边缘数据块
← 返回 CUDA Academy