apple-silicon
БесплатноБез исполняемых скриптовНе проверенApple Silicon skill for M-series development and profiling. Use when leveraging unified memory, Metal Performance Shaders, Instruments profiling, sysctl…
от mohitmishra786★ 307 звёзд на GitHubОб этом скилле
Apple Silicon
Purpose
Guide agents through Apple Silicon (M-series) development: unified memory architecture, AMX matrix coprocessor access via Accelerate, Metal Performance Shaders for GPU compute, sysctl hardware queries, Instruments profiling, command-line leak tools, Rosetta 2 translation behavior, and 16KB page size implications.
Triggers
- Optimizing native ARM64 apps on macOS for M1/M2/M3/M4
- Using GPU/NPU compute without discrete GPU PCIe transfers
- Profiling memory and CPU with Instruments or command-line tools
- Understanding Rosetta 2 compatibility for x86 binaries
- Adapting code for 16KB page size on Apple Silicon
- Accessing matrix acceleration via Accelerate/vDSP/BLAS
Workflow
1. Unified memory architecture
Apple Silicon SoC
├── CPU cores (P + E cores)
├── GPU cores
├── Neural Engine (NPU)
└── Unified DRAM — single address space, no PCIe copy
Implications:
cudaMemcpyequivalent is unnecessary for CPU↔GPU on Metal- Memory bandwidth shared across agents — profile holistically
- Process memory includes all unified allocations
2. Hardware information
# CPU and chip info
sysctl -n machdep.cpu.brand_string
sysctl hw.physicalcpu hw.logicalcpu
sysctl hw.memsize
# ARM64 features (keys vary by chip — grep if specific FEAT_* is missing)
sysctl -a hw.optional.arm 2>/dev/null | grep -iE 'sve|bf16|mte'
# Cache line size
sysctl hw.cachelinesize
# Page size (16KB on macOS Apple Silicon)
sysctl hw.pagesize # 16384
getconf PAGESIZE
3. 16KB page size considerations
macOS on Apple Silicon uses 16KB pages (not 4KB):
// Align hot buffers to page size
size_t page = sysconf(_SC_PAGESIZE); // 16384
void *buf = aligned_alloc(page, size);
// mmap alignment must be page-aligned
mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
Impact:
posix_memalignminimum alignment often 16KB for large allocs- JVM/Go runtimes auto-tune; custom allocators must adapt
- Test on device — x86 CI may use 4KB pages
4. AMX (Apple Matrix Coprocessor)
AMX is undocumented at ISA level; access through frameworks:
// Accelerate framework — uses AMX internally for matrix ops
#include <Accelerate/Accelerate.h>
void matrix_multiply(const float *A, const float *B, float *C,
int M, int N, int K) {
cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,
M, N, K, 1.0f, A, K, B, N, 0.0f, C, N);
}
# Link Accelerate (default on macOS)
clang -framework Accelerate -o gemm gemm.c -lcblas
For custom AMX kernels: study community reverse engineering or use Metal Performance Shaders as supported path.
5. Metal Performance Shaders (MPS)
// Objective-C / Swift — GPU compute via MPS
#import <Metal/Metal.h>
#import <MetalPerformanceShaders/MetalPerformanceShaders.h>
id<MTLDevice> device = MTLCreateSystemDefaultDevice();
id<MTLCommandQueue> queue = [device newCommandQueue];
MPSMatrixMultiplication *gemm = [[MPSMatrixMultiplication alloc]
initWithDevice:device transposeLeft:NO transposeRight:NO
resultRows:M columns:N interiorColumns:K alpha:1.0 beta:0.0];
Metal provides unified memory path to GPU — no explicit copy for buffers allocated with MTLResourceStorageModeShared.
6. Instruments profiling
# Command-line Instruments (xctrace)
xctrace record --template 'Time Profiler' --launch -- /path/to/app
xctrace record --template 'Allocations' --launch -- /path/to/app
xctrace record --template 'Leaks' --launch -- /path/to/app
xctrace export --input trace.trace --toc
| Template | Use |
|---|---|
| Time Profiler | CPU hotspots, P/E core usage |
| Allocations | Heap growth, allocation call trees |
| Leaks | Retained memory |
| System Trace | Thread scheduling, syscalls |
GUI: Xcode → Product → Profile (⌘I)
7. Command-line debugging tools
# Process memory map
vmmap <pid>
# Heap analysis
heap <pid>
heap <pid> -addresses all # all allocations
# Leak detection
leaks <pid>
leaks --list <pid>
# Sample call stacks
sample <pid> 5 -file sample.txt
8. Rosetta 2 translation
# Check if process runs under Rosetta
sysctl sysctl.proc_translated # 1 = translated x86
# Force arch
arch -arm64 ./native_binary
arch -x86_64 ./x86_binary
# Universal binary info
lipo -info myapp
file myapp
| Runs native ARM64 | Runs under Rosetta |
|---|---|
| ARM64 build | x86_64-only binary |
-arch arm64 compile |
Downloaded Intel-only app |
Rosetta 2: translates x86_64 to ARM64 with JIT cache. AVX/AVX2 translated but may be slower. Not for kernel extensions or VM guests.
9. Memory tagging (ARM MTE)
Future Apple hardware may expose MTE — monitor via:
sysctl hw.optional.arm.FEAT_MTE # when available
Prepare with pointer authentication already on ARM64e Apple platforms.
10. Build and perf tips
# Native optimized build
clang -arch arm64 -O3 -mcpu=apple-m1 -
Установить apple-silicon в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл apple-silicon?
Apple Silicon skill for M-series development and profiling. Use when leveraging unified memory, Metal Performance Shaders, Instruments profiling, sysctl hardware queries, Rosetta 2 behavior, or 16KB page size considerations. Activates on queries about Apple Silicon, unified memory, AMX, MPS, Instruments, Rosetta, or M-series page size.
Как установить скилл apple-silicon?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл apple-silicon запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic