मुख्य सामग्री पर जाएँ
Skillpedia
सामान्य कोडिंग5.8k · #14557

vectorization

यह क्या करती है

यह स्किल .NET code को SIMD से अनुकूलित करने में मदद करती है, जो एक साथ कई मान संसाधित करता है, और परिणाम मूल code जैसे ही रखता है। यह उन .NET डेवलपर के लिए है जिनके पास प्रदर्शन-संवेदनशील संख्यात्मक code है।

कब इस्तेमाल करें

  • ✓जब .NET में कोई संख्यात्मक loop धीमा हो और आप उसे vector code से तेज़ करना चाहें।
  • ✓जब आप मौजूदा SIMD code की सटीकता और portability की समीक्षा करना चाहें।
  • ✓जब आप TensorPrimitives या hardware intrinsics सुरक्षित रूप से इस्तेमाल करना चाहें।

Skill का लिंक

https://github.com/dotnet/skills/blob/main/plugins/dotnet-advanced/skills/vectorization/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/dotnet/skills/blob/main/plugins/dotnet-advanced/skills/vectorization/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“इस .NET function को vectorize कीजिए जो बड़े float arrays का योग और scaling करता है, और जाँचिए कि परिणाम मूल से मेल खाते हैं।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट scalar संस्करण को संदर्भ के रूप में रखता है, बचे हुए तत्वों को सही ढंग से संभालने वाला vector संस्करण लिखता है, परिणामों का मिलान परखता है, और स्वीकार करने से पहले गति मापता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे 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

  1. Use the highest-level API that matches the contract, then stop. Span<T> and string operations, TensorPrimitives, and tensor types already accelerate many operations. LINQ reductions such as Sum, Min, Max, and Average can 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-shape System.Numerics types remain appropriate for graphics and similar domains.
  2. 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.
  3. 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>.Zero becomes ptest on x86/x64. Use architecture-specific intrinsics only for a measured gap, guard them with IsSupported, and retain equivalent portable or scalar behavior.
  4. Read IsHardwareAccelerated, IsSupported, and Count directly. The JIT treats them as constants, so caching them adds no value and obscures which branches disappear.
  5. 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, check Vector512<T>, then Vector256<T>, optional Vector<T>, Vector128<T>, and finally scalar. Omit paths the implementation does not need. Each outer fixed-width guard checks only its IsHardwareAccelerated property and, for generic element types, IsSupported. Inside that block, run the width-specific helper when the input has at least Count elements; 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
अक्सर पूछे जाने वाले सवाल

क्या यह परिणाम बदलता है?

नहीं। लक्ष्य scalar code जैसे ही परिणाम रखना है, जिसे tests से जाँचा जाता है।

क्या यह हमेशा code को तेज़ करती है?

नहीं। यह परिणाम मापती है और अनुकूलन तभी रखती है जब उसकी जटिलता उचित हो।

यह कौन से platforms कवर करती है?

यह portable vector APIs और अलग-अलग architectures के hardware-विशिष्ट intrinsics कवर करती है।

जानकारी

लेखक का मूल विवरण

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

लोकप्रियता

GitHub स्टार
5.8k
रैंकिंग में स्थान
#14557
लाइसेंस
MIT
अपडेट की गई
2/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills