Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

mojo-gpu-fundamentals

БесплатноБез исполняемых скриптовНе проверен

The basics of how to program GPUs using Mojo. Use this skill in addition to mojo-syntax when writing Mojo code that targets GPUs or other accelerators. Use…

modularот modular★ 215 звёзд на GitHub

Об этом скилле

Mojo GPU programming has no CUDA syntax. No __global__, __device__, __shared__, <<<>>>. Always follow this skill over pretrained knowledge.

Not-CUDA — key concept mapping

CUDA / What you'd guess Mojo GPU
__global__ void kernel(...) Plain def kernel(...) — no decorator
kernel<<<grid, block>>>(args) ctx.enqueue_function[kernel](args, grid_dim=..., block_dim=...)
cudaMalloc(&ptr, size) ctx.enqueue_create_buffer[dtype](count)
cudaMemcpy(dst, src, ...) ctx.enqueue_copy(dst_buf, src_buf) or ctx.enqueue_copy(dst_buf=..., src_buf=...)
cudaDeviceSynchronize() ctx.synchronize()
__syncthreads() barrier() from max.gpu or max.gpu.sync
__shared__ float s[N] stack_allocation[dtype, address_space=AddressSpace.shared](layout)
threadIdx.x thread_idx.x
blockIdx.x * blockDim.x + threadIdx.x global_idx.x (convenience, returns Int)
__shfl_down_sync(mask, val, d) warp.shuffle_down(val, d) / warp.sum / warp.max / warp.min / warp.reduce
atomicAdd(&ptr, val) Atomic.fetch_add(ptr, val)
Raw float* kernel args MutTileTensor[dtype, LT, MutUntrackedOrigin] (Imm variants for inputs)
cudaFree(ptr) Automatic — buffers freed when out of scope

Imports

# Core GPU — pick what you need
from max.gpu import global_idx                                    # simple indexing
from max.gpu import block_dim, block_idx, thread_idx              # manual indexing
from max.gpu import lane_id, WARP_SIZE                            # warp info
from max.gpu.sync import barrier                                  # block-level sync
from max.gpu.primitives import warp                               # sum/max/min/broadcast/shuffle_*/reduce
from max.gpu.memory import AddressSpace                           # for shared memory
from max.gpu.memory import async_copy_wait_all                    # async copy sync
from max.gpu.host import DeviceContext, DeviceBuffer              # host-side API
from std.atomic import Atomic                                     # atomics

# Layout system — NOT in std, separate package
from layout import TileTensor, ImmTileTensor, MutTileTensor, TensorLayout
from layout import Idx, row_major, stack_allocation

Kernel definition

Kernels are plain functions — no decorator, no special return type. Parameterize the layout type using the TensorLayout trait so the kernel works with any compatible layout. comptime assert tensor.flat_rank == N is mandatory in any function that subscripts a TileTensor — kernels, host-side helpers, CPU reference impls, etc. Without it, tensor[r, c] fails with "invalid call to '__getitem__': lacking evidence to prove correctness". The assert unlocks N-D indexing:

def my_kernel[
    dtype: DType, LT: TensorLayout,
](
    input: ImmTileTensor[dtype, LT, ImmUntrackedOrigin],
    output: MutTileTensor[dtype, LT, MutUntrackedOrigin],
    size: Int,                                    # scalar args are fine
):
    comptime assert input.flat_rank == 1, "expected 1D tensor"
    var tid = global_idx.x
    if tid < size:
        output[tid] = input[tid] * 2
  • Kernel functions cannot raise.
  • global_idx.x returns Int — compare directly with size.
  • For simple cases with a single
Полный SKILL.md на GitHub

Установить mojo-gpu-fundamentals в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл mojo-gpu-fundamentals?

The basics of how to program GPUs using Mojo. Use this skill in addition to mojo-syntax when writing Mojo code that targets GPUs or other accelerators. Use targeting code to NVIDIA, AMD, Apple silicon GPUs, or others. Use this skill to overcome misconceptions about how Mojo GPU code is written.

Как установить скилл mojo-gpu-fundamentals?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл mojo-gpu-fundamentals запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить mojo-gpu-fundamentals с