Guides writing CUDA kernels that efficiently map work onto the grid, coalesce global memory, and achieve sufficient occupancy. Use when hand-writing or reviewing a CUDA kernel that runs far below the card's bandwidth or FLOPs.
A kernel launches one function across thousands of threads, each working on its own slice of data. The classic first attempt is correct but an order of magnitude too slow: it indexes memory like a serial loop and sizes thread blocks by guesswork. These habits, applied on every kernel, close most of that gap before a profiler is even involved.
int i = blockIdx.x * blockDim.x + threadIdx.x and bound it with
if (i >= n) return; so the last, partly full block does not read past the
array. Keep this one-thread-per-element version as the reference you optimize
against.for (int i = tid; i < n; i += blockDim.x * gridDim.x) so a fixed grid
handles any n and each thread covers several elements. This decouples the
launch configuration from problem size and keeps blocks busy.(n + block - 1) / block. Never launch a
block dimension that is not a multiple of 32.a[i] on the global index coalesces; a[i * stride] or indexing the outer
axis of a 2D array scatters into up to 32 separate sectors. Make
threadIdx.x walk the innermost, contiguous axis.cudaOccupancyMaxPotentialBlockSize or read the occupancy line in Nsight
Compute. Registers per thread and shared memory per block cap how many warps
a streaming multiprocessor keeps resident; overspending either starves the SM
of work to hide memory latency. Target at least 50 percent theoretical
occupancy before blaming the algorithm.cudaGetLastError() and a cudaDeviceSynchronize() in debug builds, and run
once under compute-sanitizer to catch out-of-bounds writes and races that
corrupt results only on some launches.compute-sanitizer ./app report zero errors on a representative input?This is single-kernel correctness and first-order speed on one GPU. It does not cover streams and copy overlap, multi-GPU NCCL collectives, or wringing the last percent from a GEMM. Once loads coalesce and occupancy is healthy, move to a profiler-driven pass (kernel-profiling-nsight) and to staging data across the memory tiers (gpu-memory-hierarchy) instead of guessing.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Not loaded · from ai-skills-commands
Claude Code won't load this skill
It ships in ai-skills-commands at skills/, but Claude Code only loads skills/<name>/SKILL.md and folders listed under skills in plugin.json. Installing the plugin doesn't add it.
npx claudepluginhub amey-thakur/ai-skills --plugin ai-skills-commands1,000 skills in this plugin
/ab-test-designDesign product experiments with real hypotheses, honest sample-size math, guardrails, and peeking discipline. Use when validating a change by experiment or reviewing a test before believing its result./accessibility-reviewAudit a UI for real accessibility, keyboard-first, with concrete failures and fixes rather than checkbox compliance. Use when reviewing or building any user interface./accessibility-specialist-roleOperate as an accessibility specialist who audits against WCAG, trains teams to stop shipping the same defects, and owns the compliance sign-off. Use when a product needs to be usable with a keyboard, a screen reader, or magnification and someone must certify it before launch.Other plugins' skills for the same job