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.
npx skills add mindspore-ai/akg --skill cuda-c-patternsgit clone --depth 1 https://github.com/mindspore-ai/akgWrote 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.
[](https://agentmods.dev/skills/mindspore-ai/akg/cuda-c-patterns)<a href="https://agentmods.dev/skills/mindspore-ai/akg/cuda-c-patterns"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/cuda-c-patterns.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00024 | $0.03079 |
| Opus 5 | $0.00012 | $0.01540 |
| Sonnet 5 | $0.00005 | $0.00616 |
| Haiku 4.5 | $0.00002 | $0.00308 |
Grade A, and why
cuda-c-patterns 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 7d 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.
How it starts
The opening of the file, as written. The whole thing — 345 lines — stays where its author put it; the contents beside it link to each section on GitHub.
CUDA C 编程模式
1. 向量操作模式
适用于元素级运算:加法、乘法、激活函数等。
标准代码结构
__global__ void vector_add_kernel(
const float* a, const float* b, float* c, int n_elements
) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < n_elements) {
c[idx] = a[idx] + b[idx];
}
}
适用算子
- 算术运算: add, mul, sub, div
- 激活函数: relu, sigmoid, tanh, gelu, silu
- 数学函数: exp, log, sqrt, pow, abs
- 类型转换: cast
- 广播操作: broadcast
关键要点
- 使用一维索引
blockIdx.x * blockDim.x + threadIdx.x - 边界检查
if (idx < n_elements) - 简单直接的数据流:加载 → 计算 → 存储
- 推荐块大小: 256 或 512
ReLU 示例
__global__ void relu_kernel(
const float* input, float* output, int n
) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < n) {
output[idx] = fmaxf(input[idx], 0.0f);
}
}
GELU 示例
__global__ void gelu_kernel(
const float* input, float* output, int n
) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < n) {
float x = input[idx];
// 近似 GELU: 0.5 * x * (1 + tanh(sqrt(2/pi) * (x + 0.044715 * x^3)))
float cdf = 0.5f * (1.0f + tanhf(0.7978845608f * (x + 0.044715f * x * x * x)));
output[idx] = x * cdf;
}
}
多输入逐元素操作
__global__ void fused_multiply_add_kernel(
const float* a, const float* b, const float* c,
float* output, int n
) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < n) {
output[idx] = a[idx] * b[idx] + c[idx];
}
}
2. 归约模式
适用于求和、最大值、最小值等聚合操作。
标准代码结构(共享内存归约)
__global__ void reduction_sum_kernel(
const float* input, float* output, int n_elements
) {
extern __shared__ float sdata[];
int tid = threadIdx.x;
int idx = blockIdx.x * blockDim.x + threadIdx.x;
// 加载数据到共享内存
sdata[tid] = (idx < n_elements) ? input[idx] : 0.0f;
__syncthreads();
// 块内归约(树形归约)
for (int s = blockDim.x / 2; s > 0; s >>= 1) {
if (tid < s) {
sdata[tid] += sdata[tid + s];
}
__syncthreads();
}
// 第一个线程写入块级结果
if (tid == 0) {
atomicAdd(output, sdata[0]);
}
}
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.
- 7d ago First seen · 345 lines · 24 tokens per session scan A 7627294e09bd
cuda-c-patterns is a skill published in the GitHub repository mindspore-ai/akg (259 stars, last pushed 27d ago), licensed Apache-2.0. It adds 24 tokens to every session and 3,079 once invoked, about $0.0001 per session on Opus 5. 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.
Other skills, from other repositories
tilelang-cuda-patterns
A set of standard TileLang CUDA patterns and templates for elementwise work, reductions, matrix multiplication, and matrix-vector multiplication.
triton-cuda-patterns
A set of standard Triton patterns and templates for three common GPU tasks: element-by-element operations, reductions, and matrix multiplication.
cuda-c-patterns
A guide to three common CUDA C programming patterns for running work on NVIDIA GPUs.
cuda-c-optimization
A set of guidance for optimizing CUDA C programs, keeping numerical results stable, and investigating bugs. CUDA C is used to run parts of programs on NVIDIA graphics processors.
zoom-meeting-sdk-unreal
Zoom Meeting SDK for Unreal Engine wrapper integrations. Use when building Unreal projects that embed Zoom meetings with C++ and Blueprint wrappers, including wrapper-to-SDK mapping concerns.
doca-argp
Use this skill for hands-on DOCA Arg Parser CLI work on a shipped sample or new DOCA-using app — adding / removing / renaming flags; wiring docaargpinit → register params → docaargpstart → docaargpdestroy in order; picking a parameter type from the full public enum (DOCAARGPTYPESTRING, INT, BOOLEAN, DEVICE, DEVICEREP…