Skills

Matlab Optimize Gpu Codegen

Optimize MATLAB design files for GPU Coder to generate faster CUDA code.

Install

npx skills add matlab/matlab-agentic-toolkit --skill matlab-optimize-gpu-codegen -g -a claude-code -y
Category
Design
Updated
8d ago
License
See repository
Context cost
Mediumabout 3,000 tokens
Runs scripts
No, instructions only

What it does

Optimize MATLAB design files for GPU Coder to generate faster CUDA code. Iteratively profiles, rewrites, and benchmarks until performance targets are met or diagnostics are resolved. Use when asked to: optimize for GPU Coder, improve GPU codegen performance, profile generated GPU/CUDA code, profile GPU MEX, fix gpuPerformanceAnalyzer diagnostics, speed up GPU MEX, reduce GPU memory transfers, improve kernel parallelism, rewrite MATLAB for CUDA, or run gpuPerformanceAnalyzer.

Optimize MATLAB for GPU Code Generation

Iteratively optimize a MATLAB design file for GPU Coder: compile, benchmark, apply structural optimizations, profile with gpuPerformanceAnalyzer, fix diagnostics, and verify numerical equivalence at every step.

When to Use

  • User has a MATLAB function and wants faster GPU MEX or CUDA code
  • User mentions GPU Coder, codegen, CUDA, gpuPerformanceAnalyzer
  • User asks to profile generated GPU/CUDA code or GPU MEX (profiling generated GPU code is the entry point to this skill's diagnostic-fix workflow)
  • User wants to reduce GPU memory, improve kernel parallelism, or fix Performance Analyzer diagnostics
  • User has a .m design file and representative inputs

When NOT to Use

  • Workflows with no codegen
  • coder.gpuConfig("exe"), standalone executables cannot be benchmarked or equivalence-checked from MATLAB. Suggest the user switch to mex or lib/dll and regenerate exe from the final optimized source.
  • Simulink GPU code generation
  • Writing new MATLAB functions from scratch (this skill optimizes existing code)
  • Optimizing helper functions called by the design file, this skill optimizes the main design file only
  • Hardware setup or CUDA toolkit installation
  • General MATLAB performance tuning without GPU involvement
  • The user's prompt does not mention GPU, codegen, CUDA, MEX, or profiling. Activation must be driven by the user's prompt alone, do not infer GPU intent from filenames or function contents. If unsure, ask before activating.

Workflow

Setup, Create Session Directory

All codegen artifacts, profiling outputs, and optimized versions go in a single temp directory for the entire session. pwd must be sessionDir for every codegen/benchmark/PA call, otherwise compiled MEX and SIL binaries land in the user's working directory.

Read the whole SKILL.md on GitHub

More in Design