dotnet / dotnet/dotnet-api-docs

Vector256.Create() doesn't document that it corresponds to _mm256_setr_epiN (set reverse)

オープン
#8,288 コメント 3 件 リアクション 2 件 担当者 0 名 GitHub で見る
area-System.Runtime.Intrinsics documentation help wanted Pri3
主要言語
C#
スター
949
フォーク
1.7k
平均マージ
2日 19時間
マージ済み PR(30日)
52

説明

### Description

(This also matters for `Vector128.Create()` and any other similar methods)

`Vector256.Create()` is a helper function that, on Intel/AVX2, corresponds to `_mm256_setr_epiN` where `N` is 8, 16, 32, 64. When the .NET intrinsics were designed, they were intentionally done such that the order of these parameters was reversed. This makes sense, but it causes pain when porting code from C/C++. I think this can be improved with a very simple addition to the doc comments (and therefore the Intellisense tooltips).

All of the `Avx2` method intrinsics have a _very_ helpful note in the doc comment (and therefore Intellisense tooltip) specifying which intrinsic and which instruction they line up with, e.g.

image

However, the `Create()` methods do not. Since these correspond to `setr` instead of `set`, the order that is needed is reversed from what we see in C/C++ code.

This just burned a bunch of my time, and I know it bit @EgorBo at some point too and he lost an hour to it. I just ported 1300 lines of vectorized instrinsics code over to C# and everything is _almost_ right, but my validation code was catching some off-by-1 errors.

I know these are supposed to be instruction-set agnostic, but they really need to list which intrinsic they line up with, even if they have to list it for every instruction set (i.o.w. AVX and ARM). I was going line-by-line, validating all of my instructions to make sure that they matched up, and everything does, until I realized "wait, those Create() methods are backwards from the set() intrinsics, right?" When writing or porting vectorized/intrinsics code, finding these errors is often a needle-in-a-haystack problem, and simple things like helpful doc comments go a very long way toward shortening the time that's needed to debug and these. (the existing doc comments on the intrinsics are _extremely_ helpful in that regard)

image

Put another way, these are _helper_ methods. They should be _helpful_ ... they are currently _unhelpful_ :)

EDIT: Apparently the docs pages on MSDN _do_ list this information in the Remarks section. However, this is not useful enough because it does not show up in the IntelliSense popups in Visual Studio:

image

### Reproduction Steps

Port some C++ intrinsics code that uses `_mm256_set_epiN` and/or `_mm128_set_epiN` over to C#

### Expected behavior

The doc pages, doc comments, and IntelliSense popups are helpful at every step of the process

### Actual behavior

The doc pages, doc comments, and IntelliSense popups are helpful at every step of the process _except when it comes to `_mm256_set_epiN` / `Vector256.Create()`, and `_mm128_set_epiN` / `Vector128.Create()`_

### Regression?

Not a regression

### Known Workarounds

Just reverse the order of the parameters. There's no code bug here, just a docs bug (IMO).

### Configuration

_No response_

### Other information

_No response_

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず Vector256.Create と Vector128.Create の API ドキュメントコメントを探し、IntelliSense に表示される説明と、既存の Avx2 intrinsic のコメントを比較します。setr との対応関係とパラメーターの順序が逆であることを説明するよう、該当するコメントを更新します。ドキュメントコメントと IntelliSense のツールチップにその情報が表示されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
csharp
領域
documentation
issue の種類
ドキュメント
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。