원클릭으로
analyze-simd-usage
Analyze SIMD usage opportunities in Mojo code. Use to find performance optimization opportunities.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Analyze SIMD usage opportunities in Mojo code. Use to find performance optimization opportunities.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Run section orchestrators to coordinate multi-component workflows. Use when starting work on a section.
Validate agent YAML frontmatter and configuration. Use before committing agent changes or in CI.
Reply to PR review comments using the correct GitHub API endpoint. Use when responding to inline code review feedback (not gh pr comment).
Run Mojo tests using mojo test command. Use when executing tests or verifying test coverage.
Track implementation progress against plan. Use to monitor component delivery and identify blockers.
Check agent configuration coverage across hierarchy levels and phases. Use to ensure complete agent system coverage.
| name | analyze-simd-usage |
| description | Analyze SIMD usage opportunities in Mojo code. Use to find performance optimization opportunities. |
| category | mojo |
| mcp_fallback | none |
Identify where SIMD (Single Instruction Multiple Data) can improve performance.
# Find loops processing arrays/tensors
grep -n "for.*in.*range\|@unroll\|@vectorize" *.mojo
# Find element-wise operations
grep -n "\.load\|\.store\|\.broadcast" *.mojo
# Check for SIMD parameters
grep -n "simd_width\|nelems\|\[.*:\]" *.mojo
# Identify candidates
grep -n "for i in range.*:" -A 10 *.mojo | grep -E "array\[i\]|tensor\[i\]"
Vectorizable Patterns:
a[i] + b[i] for all ia[i] * scalar for all isin(a[i]), exp(a[i]) for all ia[i] = a[i-1] + value (sequential)if a[i] > threshold: (hard to vectorize)SIMD Width Selection:
@parameter fn[simd_width: Int] - Generic SIMD widthsimd_width=4 - Typically good for float32simd_width=8 - Optimal for many operationssimd_width=16+ - For int32 or specialized opsVectorization Patterns:
@vectorize decorator for simple loops@unroll for small loops (2-4 iterations).load[] and .store[]Report SIMD analysis with:
Example 1: Element-wise Addition
# Before: scalar loop
fn add_scalar(a: Tensor, b: Tensor) -> Tensor:
var result = Tensor(a.shape)
for i in range(a.num_elements()):
result._data[i] = a._data[i] + b._data[i]
return result
# After: vectorized
@vectorize
fn add_simd[simd_width: Int](i: Int):
result._data.store[simd_width](i,
a._data.load[simd_width](i) + b._data.load[simd_width](i))
def add_vectorized(a: Tensor, b: Tensor) -> Tensor:
var result = Tensor(a.shape)
# 4x-8x speedup typical
return result
Example 2: Reduction (Sum)
# Before: scalar loop
fn sum_scalar(tensor: Tensor) -> Float32:
var total: Float32 = 0
for i in range(tensor.num_elements()):
total += tensor._data[i]
return total
# After: SIMD reduction
fn sum_simd[simd_width: Int](tensor: Tensor) -> Float32:
# Process simd_width elements at a time
# Then reduce results - can be much faster
return total
| Problem | Solution |
|---|---|
| Vectorization causes wrong results | Check for loop-carried dependencies |
| Segment fault with SIMD | Verify alignment and bounds |
| Minimal speedup | May not be vectorizable, profile to confirm |
| Complex logic | Break into simpler vectorizable operations |
| Type mismatches | Ensure SIMD width compatible with element type |