optimize-global-memory-access

optimize-global-memory-access is a skill for Claude Code, Codex from tensormux/kernel-skills. It costs 0 tokens per session (3,210 once invoked), scanned A, original, MIT.

Guidance for improving how CUDA programs read and write GPU memory. CUDA is a system for running computations on NVIDIA graphics processors.

In plain words
What is it for?
Diagnosing memory-bandwidth problems, choosing between array layouts, using vectorized reads, and staging data in shared memory.
Why use it?
It helps find slow or inefficient memory access caused by strides, transposed data, irregular layouts, or poor cache use.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/tensormux/kernel-skills/optimize-global-memory-access
Any agent
npx skills add tensormux/kernel-skills --skill optimize-global-memory-access
Clone the repo
git clone --depth 1 https://github.com/tensormux/kernel-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for optimize-global-memory-access

README.md
[![agentmods](https://agentmods.dev/badge/skills/tensormux/kernel-skills/optimize-global-memory-access.svg)](https://agentmods.dev/skills/tensormux/kernel-skills/optimize-global-memory-access)
Your own site
<a href="https://agentmods.dev/skills/tensormux/kernel-skills/optimize-global-memory-access"><img src="https://agentmods.dev/badge/skills/tensormux/kernel-skills/optimize-global-memory-access.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,210 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.03210
Opus 5 $0.00000 $0.01605
Sonnet 5 $0.00000 $0.00642
Haiku 4.5 $0.00000 $0.00321

Measured 6d ago against content hash b149b685eaa3, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

optimize-global-memory-access scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/cuda/optimize-global-memory-access/SKILL.md · 104 lines

How it starts

The opening of the file, as written. The whole thing — 104 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Skill: Optimize Global Memory Access

Purpose

Guide the agent through diagnosing and restructuring CUDA global memory access patterns to maximize effective memory bandwidth, covering coalescing requirements, vectorized loads, AoS vs SoA layouts, shared memory staging for non-coalesced patterns, and L2 cache behavior.

Use this when

  • A kernel's measured memory bandwidth is significantly below device peak (e.g., less than 60% of theoretical peak on an HBM device)
  • Profiling shows high "global memory load/store efficiency" warnings in Nsight Compute, or a high ratio of L2 transactions per access
  • The kernel accesses memory with strides, transposed layouts, or irregular patterns
  • You are redesigning a data structure layout to improve access locality across kernels
  • A new kernel is being written and the access pattern needs to be designed from scratch for maximum coalescing

Do not use this when

  • The kernel is compute-bound (arithmetic intensity is high relative to the roofline): improving memory access will not help until the compute bottleneck is addressed
  • The access pattern is inherently random (e.g., sparse gather/scatter with unpredictable indices): coalescing restructuring has limited benefit and may not be worth the code complexity
  • The data fits in L1/L2 cache across the full kernel launch: memory bandwidth to DRAM is not the bottleneck

Inputs the agent should gather first

  • Access pattern description: for each global memory read and write in the kernel, what is the relationship between threadIdx and the memory address? Is the stride between consecutive threads 1, a constant, or data-dependent?
  • Tensor shape and layout: are tensors row-major (C-contiguous) or column-major (Fortran-contiguous)? What are the leading dimension strides?
  • Dtype and element size: fp32 (4 bytes), fp16 (2 bytes), int8 (1 byte) — determines how many elements fit in one cache line (128 bytes / element_size)
  • Pointer alignment: are base pointers guaranteed 16-byte (or 128-byte) aligned? This determines which vectorized load widths are safe
  • Access frequency: is this access in the inner loop or the outer setup? How many times is each element loaded (reuse factor)?
  • Hardware target: SM architecture, for cache line size (128 bytes on all modern NVIDIA GPUs), L2 cache size, and memory bus width

Read the full file on GitHub · 104 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 104 lines · 0 tokens per session scan A b149b685eaa3

Subscribe to this mod's changes

optimize-global-memory-access is a skill published in the GitHub repository tensormux/kernel-skills (73 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 3,210 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.