0Pricing
CUDA Academy · Lesson

Fusing Filters into One Kernel

Cutting launches and global traffic.

Fusing Filters into One Kernel is a free CUDA Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the CUDA Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Why Fuse At All

Running five kernels means five launches and five round-trips to global memory. Fusing filters into one kernel cuts both, often giving a big speedup. 🚀

Launch Overhead Adds Up

Every kernel launch costs a few microseconds. On a tiny image that fixed launch overhead can dwarf the real work, so fewer launches means more useful time.

Global Traffic Is the Enemy

Separate stages write a pixel to global memory then read it right back. Fusing keeps that value in a register, erasing the wasted round-trip entirely.

Load Once Per Thread

In a fused kernel each thread reads its pixel a single time. That one load then feeds every filter in sequence without touching global memory again.

float v = input[idx];

Chain Operations in Registers

Apply each filter to the value already in hand. The pixel flows through brightness, gamma, and contrast as plain math, all kept in fast registers.

v = v * brightness;
v = powf(v, gamma);
v = (v - 0.5f) * contrast + 0.5f;

Write Once At the End

After the whole chain runs, store the final result. One store replaces the many writes that separate kernels would have made.

output[idx] = v;

Pointwise Filters Fuse Cleanly

Filters that touch only one pixel are pointwise and fuse with zero fuss. Brightness, gamma, and color tweaks are the easiest wins to combine.

Neighborhood Filters Are Harder

A blur reads nearby pixels, so fusing it needs shared memory tiles, not just registers. Fuse pointwise stages freely and treat stencils with extra care.

Watch Register Pressure

A big fused kernel uses more registers per thread. Too many and occupancy drops or values spill, so fuse aggressively but keep an eye on the cost.

Verify After Fusing

Fusing reorders work, so always compare the fused output against the staged version. A quick diff confirms the math still matches before you celebrate.

One Kernel, Many Filters

The payoff is real: a single launch reads, transforms, and writes each pixel exactly once. That is the heart of a well-tuned fused image kernel.

Quick Check

You merged three pointwise filters into one kernel. What is the main performance win?

Recap

You learned to fuse filters: load once, chain pointwise math in registers, write once. It cuts launches and global traffic, but watch register pressure and verify the output. ✅

Frequently asked questions

Is the “Fusing Filters into One Kernel” lesson free?

Yes — the full text of “Fusing Filters into One Kernel” is free to read here on the web, and the CUDA Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the CUDA Academy course, upgrade to CoddyKit PRO.

What will I learn in “Fusing Filters into One Kernel”?

Cutting launches and global traffic. You practise CUDA Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start CUDA Academy?

No prior experience is required. CUDA Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Fusing Filters into One Kernel” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this CUDA Academy lesson?

Yes. Every CUDA Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Designing the Processing Pipeline
  2. Fusing Filters into One Kernel
  3. Streaming Tiles for Big Images
  4. Profile, Optimize, Ship
← Back to CUDA Academy