JuliaSIMD / JuliaSIMD/LoopVectorization.jl

Multiply 2 16-bit integers and accumulate to 32-bit integer

Aperta
#37 10 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Julia
Stelle
789
Fork
73
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.