JuliaSIMD / JuliaSIMD/LoopVectorization.jl
Multiply 2 16-bit integers and accumulate to 32-bit integer
- Vorherrschende Sprache
- Julia
- Sterne
- 789
- Forks
- 73
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
How would I multiply 2 16-bit integers and accumulate to 32-bit integer? Something like `_mm_madd_epi16`
So far the result of the multiplication seems to be done in 16-bit:
```julia
a = Int16.([1 << 8, 1 << 9, 1 << 10, 1 << 10])
b = Int16.([1 << 7, 1 << 8, 1 << 11, 1 << 10])
function fma_avx(a, b)
res = Int32(0)
@avx for i = 1:4
res = res + a[i] * b[i]
end
res
end
```
```julia
julia> fma_avx(a, b)
-32768
julia> fma_avx(Int32.(a), Int32.(b))
3309568
```
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Start with the provided `fma_avx` reproducer and its `@avx` loop, comparing the `Int16` and `Int32` calls. Check how the loop handles `Int16` multiplication and accumulation, then verify the behavior against the requested 32-bit result; done means the intended result is supported or the limitation is clearly established with a regression test.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- julia
- Bereich
- performance
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100