Files
Jeff Schwartz 55a7d80527 adding SIMD/TensorPrimitives to dotent-diag/analyzing-dotnet-performance (#330)
* incorporated feedback from previous pr, iterated with 100+ scalar loop tests to come to this skill, moved from skill to reference in the performance skill

* Update tests/dotnet-diag/analyzing-dotnet-performance/eval.yaml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update tests/dotnet-diag/analyzing-dotnet-performance/eval.yaml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update plugins/dotnet-diag/skills/analyzing-dotnet-performance/references/simd-vectorization.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update plugins/dotnet-diag/skills/analyzing-dotnet-performance/references/simd-vectorization.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update plugins/dotnet-diag/skills/analyzing-dotnet-performance/references/simd-vectorization.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update plugins/dotnet-diag/skills/analyzing-dotnet-performance/references/simd-vectorization.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Address review feedback on SIMD vectorization reference

- Check Span<T>/MemoryExtensions before TensorPrimitives (no extra dependency)
- Add all supported types (sbyte, ushort, uint, ulong, nint, nuint, char via ushort)
- TensorPrimitives: add constraint and applicable types columns (not just float/double)
- Add FusedMultiplyAdd, clarify AddMultiply vs MultiplyAdd distinction
- Prefer portable APIs over platform-specific intrinsics (allow when perf justifies)
- Fix dispatch pattern to use if/else if to avoid pessimizing small inputs
- Remove LINQ references

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* addressing more feedback

* move to the experimental plugin

* move the simd tests to exprimental

* add codeowners

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-25 10:51:28 -06:00

73 lines
3.9 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
scenarios:
- name: "Optimize manual min/max with TensorPrimitives"
prompt: "This .NET 10 project has a method that finds the minimum and maximum values in a float array. It's used in a real-time sensor monitoring system to compute value ranges over sliding windows of 10K–100K readings. Please optimize FindMinMax for maximum throughput."
setup:
files:
- path: "RangeCalculator.cs"
source: "fixtures/simd-tensor-primitives-minmax.cs"
assertions:
- type: "exit_success"
rubric:
- "Identifies that finding min and max of a float span is already covered by TensorPrimitives.Min and TensorPrimitives.Max"
- "Replaces the scalar loop with TensorPrimitives.Min/Max or equivalent framework API — not manual SIMD"
- "Does not introduce Vector128/Vector256/Vector512 intrinsics for operations already optimized by TensorPrimitives"
timeout: 180
- name: "Optimize manual product with TensorPrimitives"
prompt: "This .NET 10 project computes the product of all elements in a float array for probability calculations. Arrays are 100-1000 elements. Please optimize Product for maximum throughput."
setup:
files:
- path: "MathOps.cs"
source: "fixtures/simd-tensor-primitives-product.cs"
assertions:
- type: "exit_success"
rubric:
- "Identifies that aggregate product is already covered by TensorPrimitives.Product"
- "Replaces the scalar loop with TensorPrimitives.Product — not manual SIMD"
- "Does not introduce Vector128/Vector256/Vector512 intrinsics for an operation already optimized by TensorPrimitives"
timeout: 180
- name: "No optimization opportunity — dictionary-based lookup service"
prompt: "This .NET 10 project is a product catalog lookup service that maps product codes to categories using dictionaries. The development team suspects it could benefit from SIMD optimization. Please analyze and optimize for maximum throughput."
setup:
files:
- path: "ProductCatalog.cs"
source: "fixtures/simd-no-opportunity-catalog.cs"
assertions:
- type: "exit_success"
rubric:
- "Correctly identifies that this code has no meaningful SIMD optimization opportunity"
- "Explains why SIMD is not applicable (dictionary lookups, hash-based operations, small string keys, branching logic)"
- "Does not introduce unnecessary SIMD code that adds complexity without benefit"
timeout: 180
- name: "Optimize int array conditional increment with SIMD"
prompt: "This .NET 10 project conditionally increments each element of an int array based on a threshold for counter updates. Arrays are 100K+ elements. Please optimize ConditionalIncrement.IncrementAbove for maximum throughput."
setup:
files:
- path: "ConditionalIncrement.cs"
source: "fixtures/simd-conditional-increment.cs"
assertions:
- type: "output_contains"
value: "Vector"
- type: "exit_success"
rubric:
- "Introduces Vector128/Vector256/Vector512 with GreaterThan comparison mask and ConditionalSelect or masked Add for conditional increment"
- "Preserves scalar fallback for trailing elements or non-accelerated hardware"
timeout: 180
- name: "Optimize byte buffer bit reversal with SIMD"
prompt: "This .NET 10 project reverses the bit order of each byte in a buffer for serial protocol decoding. Buffers are 64KB+. Please optimize BitReverser.ReverseInPlace for maximum throughput."
setup:
files:
- path: "BitReverser.cs"
source: "fixtures/simd-bit-reverser.cs"
assertions:
- type: "output_contains"
value: "Vector"
- type: "exit_success"
rubric:
- "Introduces Vector128/Vector256/Vector512 with nibble-based Shuffle lookup tables for parallel bit reversal"
- "Preserves scalar fallback for trailing elements or non-accelerated hardware"
timeout: 180