dotnet / dotnet/dotnet-api-docs

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

Abierto
#8,288 3 comentarios 2 reacciones 0 asignados Ver en GitHub
area-System.Runtime.Intrinsics documentation help wanted Pri3
Lenguaje dominante
C#
Estrellas
950
Forks
1.7k
Merge medio
2 d 19 h
PR fusionados (30 d)
52

Descripción

### 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_

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza localizando los comentarios de documentación de la API para Vector256.Create y Vector128.Create; después, compara sus indicaciones dirigidas a IntelliSense con los comentarios existentes de las intrínsecas de Avx2. Actualiza los comentarios relevantes para explicar la correspondencia con setr y el orden invertido de los parámetros; estará terminado cuando la información aparezca en los comentarios de documentación y en los tooltips de IntelliSense.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
csharp
Área
documentation
Tipo de issue
Documentación
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.