vectorization
Qué hace
Esta skill ayuda a optimizar código .NET con SIMD, que procesa varios valores a la vez, manteniendo los mismos resultados que el código original. Está pensada para desarrolladores de .NET con código numérico crítico para el rendimiento.
Cuándo usarla
- ✓Cuando un bucle numérico en .NET es lento y quieres acelerarlo con código vectorial.
- ✓Cuando quieres revisar código SIMD existente en cuanto a corrección y portabilidad.
- ✓Cuando quieres usar TensorPrimitives o intrínsecos de hardware de forma segura.
Link de la skill
https://github.com/dotnet/skills/blob/main/plugins/dotnet-advanced/skills/vectorization/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“Vectoriza esta función de .NET que suma y escala arrays grandes de flotantes, y comprueba que los resultados coinciden con el original.”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
El agente mantiene la versión escalar como referencia, escribe una versión vectorial con manejo correcto de los elementos sobrantes, comprueba que los resultados coinciden y mide la velocidad antes de aceptarla.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de GitHub.
.NET SIMD vectorization
Produce a portable optimization that preserves the scalar contract, remains memory-safe at every length, and earns its complexity with measured results. Read the official SIMD and hardware-intrinsics guidance first and follow its comprehensive implementation templates. In particular, use its self-contained per-width dispatch, dedicated small-input handling, loop, and remainder shapes rather than reducing them to a chain of width checks. This skill supplies the decision rules and validation checks to apply while changing real code.
Inputs and prerequisites
Discover these from the repository before asking the user:
| Input | Required | What to establish |
|---|---|---|
| Scalar implementation and tests | Yes | Existing contract, representative call sites, and supported overlap |
| Target frameworks and platforms | Yes | Available SIMD APIs and architectures that must behave consistently |
| Build and test workflow | Yes | The repository's normal commands and how to launch separate test processes |
| Representative workload or benchmark | For optimization | Typical input sizes and the baseline to beat |
Do not add a package merely because an API exists there. First check the target framework and the project's existing dependency/versioning policy.
Core rules
- Use the highest-level API that matches the contract, then stop.
Span<T>andstringoperations,TensorPrimitives, and tensor types already accelerate many operations. LINQ reductions such asSum,Min,Max, andAveragecan also accelerate when the source exposes its underlying span. Verify empty-input and floating-point behavior rather than assuming similarly named operations are interchangeable. Once an existing API preserves the contract, use it instead of continuing into handwritten SIMD. Before writing an explicit loop, name the framework APIs considered and why none applies. Fixed-shapeSystem.Numericstypes remain appropriate for graphics and similar domains. - Start new explicit SIMD loops with
Vector128<T>. It is accelerated across the broadest hardware set. Add wider fixed-width paths only when measurements justify them. - Keep platforms consistent. Prefer cross-platform operations on the fixed-width vector types;
they lower to the appropriate target instructions. For example,
(vector & mask) == Vector128<byte>.Zerobecomespteston x86/x64. Use architecture-specific intrinsics only for a measured gap, guard them withIsSupported, and retain equivalent portable or scalar behavior. - Read
IsHardwareAccelerated,IsSupported, andCountdirectly. The JIT treats them as constants, so caching them adds no value and obscures which branches disappear. - Prefer operators where they are clear. Parenthesize expressions that mix bitwise and comparison operators so precedence is explicit.
If the task is review-only, do not rewrite the code. Report correctness and memory-safety defects before performance opportunities.
Authoring checklist
- Contract: identify behavior for empty and short inputs, overlap, overflow, NaN, signed zero, ordering, and exceptions before changing the implementation.
- Framework gate: inspect the target framework and existing package references, then compile or probe the highest-level candidate API with the required edge cases. A small contract adapter, such as preserving special empty-input behavior, does not justify reimplementing the operation. If the API preserves the contract, use it and stop; do not claim it is unavailable without checking.
- Structure: for new explicit SIMD, implement
Vector128<T>and scalar first. Only after measurements justify wider paths, checkVector512<T>, thenVector256<T>, optionalVector<T>,Vector128<T>, and finally scalar. Omit paths the implementation does not need. Each outer fixed-width guard checks only itsIsHardwareAcceleratedproperty and, for generic element types,IsSupported. Inside that block, run the width-specific helper when the input has at leastCountelements; otherwise run a dedicated small-input helper, then return. Do not put the length check in the outer guard and fall through to repeat dispatch at narrower widths. Keeping each supported-width block self-contained lets the JIT remove unsupported blocks and avoids redundant work on common sm
Preguntas frecuentes
¿Cambia los resultados?
No. El objetivo es mantener los mismos resultados que el código escalar, comprobados con pruebas.
¿Siempre hace el código más rápido?
No. Mide el resultado y solo conserva la optimización si compensa su complejidad.
¿Qué plataformas cubre?
Cubre APIs vectoriales portables e intrínsecos específicos de hardware en distintas arquitecturas.
Detalles
Descripción original del autor
Design, implement, optimize, and review SIMD code in .NET. USE FOR: vectorizing scalar loops with TensorPrimitives, Vector64/128/256/512, or platform hardware intrinsics; reviewing existing SIMD code, including the generic Vector type, for contract equivalence, tail handling, memory safety, portability, fallbacks, and measured performance. DO NOT USE FOR: performance work unrelated to SIMD or vectorization.
repo: dotnet/skills
Popularidad
- Estrellas en GitHub
- 5,8 mil
- Posición en el ranking
- #14557
- Licencia
- MIT
- Actualizada
- 2/11/2026
Comentarios
- …
Más skills de este repositorio
create-custom-agent
5,8 milAyuda a tu agente a crear archivos de agentes personalizados de VS Code, con sus propias herramientas, instrucciones y traspasos a otros agentes.
create-skill
5,8 milAyuda a tu agente a crear una skill nueva de agente con un nombre válido, una descripción de activación clara y un archivo SKILL.md que siga el estándar.
csharp-scripts
5,8 milAyuda a tu agente a ejecutar un pequeño programa en C# como un único archivo con la herramienta de línea de comandos de .NET, sin crear un proyecto completo.
dotnet-pinvoke
5,8 milAyuda a tu agente a llamar correctamente a librerías nativas de C o C++ desde .NET, cubriendo firmas, manejo de cadenas, memoria y handles seguros.
Skills parecidas
diffs
394 milPermite que tu agente genere un diff real y compartible de los cambios, como enlace de visualización o archivo de imagen, en lugar de un resumen escrito a mano.
coding-agent
394 milAyuda a tu agente a pasar un trabajo de programación grande a Codex, Claude Code u OpenCode como trabajador en segundo plano, y después revisar su progreso.
gh-issues
394 milAyuda a tu agente a encontrar incidencias de GitHub, elegir cuáles trabajar y abrir pull requests con correcciones, incluido el seguimiento de los comentarios de revisión.