mirror of
https://github.com/vacp2p/linea-monorepo.git
synced 2026-01-09 04:08:01 -05:00
Prover: apply the AVX optimizations for math/vector (#185)
* feat: apply the AVX optimizations * style: remove redundant boundary check
This commit is contained in:
@@ -5,10 +5,10 @@ go 1.22.7
|
||||
toolchain go1.23.0
|
||||
|
||||
require (
|
||||
github.com/consensys/bavard v0.1.15
|
||||
github.com/consensys/bavard v0.1.22
|
||||
github.com/consensys/compress v0.2.5
|
||||
github.com/consensys/gnark v0.11.1-0.20240910135928-e8cb61d0be1d
|
||||
github.com/consensys/gnark-crypto v0.14.1-0.20240909204211-78a6dc12799c
|
||||
github.com/consensys/gnark-crypto v0.14.1-0.20241007145620-e26bbdf97a4a
|
||||
github.com/consensys/go-corset v0.0.0-20241009181119-b687f2ec84ed
|
||||
github.com/crate-crypto/go-kzg-4844 v1.1.0
|
||||
github.com/dlclark/regexp2 v1.11.2
|
||||
|
||||
@@ -92,14 +92,14 @@ github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwP
|
||||
github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
|
||||
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo=
|
||||
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
|
||||
github.com/consensys/bavard v0.1.15 h1:fxv2mg1afRMJvZgpwEgLmyr2MsQwaAYcyKf31UBHzw4=
|
||||
github.com/consensys/bavard v0.1.15/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
|
||||
github.com/consensys/bavard v0.1.22 h1:Uw2CGvbXSZWhqK59X0VG/zOjpTFuOMcPLStrp1ihI0A=
|
||||
github.com/consensys/bavard v0.1.22/go.mod h1:k/zVjHHC4B+PQy1Pg7fgvG3ALicQw540Crag8qx+dZs=
|
||||
github.com/consensys/compress v0.2.5 h1:gJr1hKzbOD36JFsF1AN8lfXz1yevnJi1YolffY19Ntk=
|
||||
github.com/consensys/compress v0.2.5/go.mod h1:pyM+ZXiNUh7/0+AUjUf9RKUM6vSH7T/fsn5LLS0j1Tk=
|
||||
github.com/consensys/gnark v0.11.1-0.20240910135928-e8cb61d0be1d h1:TmNupI1+K5/LOg1K0kqEhRf5sZwRtxXah5iTHQ6fJvw=
|
||||
github.com/consensys/gnark v0.11.1-0.20240910135928-e8cb61d0be1d/go.mod h1:f9CH911SPCrbSZp5z9LYzJ3rZvI7mOUzzf48lCZO/5o=
|
||||
github.com/consensys/gnark-crypto v0.14.1-0.20240909204211-78a6dc12799c h1:fkRJCyz4EBjDNhiNTyyyEJBEW7RsFzmDVd/ot4jtSrE=
|
||||
github.com/consensys/gnark-crypto v0.14.1-0.20240909204211-78a6dc12799c/go.mod h1:AL8vs/7MyZ0P93tcNDkUWVwf2rWLUGFUP/1iqiF7h4E=
|
||||
github.com/consensys/gnark-crypto v0.14.1-0.20241007145620-e26bbdf97a4a h1:yUHuYq+v1C3maTwnntLYhTDmboq3scSo1PQIl375/sE=
|
||||
github.com/consensys/gnark-crypto v0.14.1-0.20241007145620-e26bbdf97a4a/go.mod h1:F/hJyWBcTr1sWeifAKfEN3aVb3G4U5zheEC8IbWQun4=
|
||||
github.com/consensys/go-corset v0.0.0-20241009181119-b687f2ec84ed h1:tA+JpjGO3tB2+Q7lsrlDper2L5BcvgS2sNd6DLS2ViM=
|
||||
github.com/consensys/go-corset v0.0.0-20241009181119-b687f2ec84ed/go.mod h1:J64guTfpmfXl4Yk2D7lsWdYg0ilP+N8JWPudP7+sZpA=
|
||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
|
||||
@@ -34,16 +34,9 @@ func ScalarMul(res, vec []field.Element, scalar field.Element) {
|
||||
// if a and b do not have the same size. If they have both empty vectors, the
|
||||
// function returns 0.
|
||||
func ScalarProd(a, b []field.Element) field.Element {
|
||||
|
||||
if len(b) != len(a) {
|
||||
utils.Panic("The inputs should have the same length %v %v", len(a), len(b))
|
||||
}
|
||||
|
||||
var res, tmp field.Element
|
||||
for i := range a {
|
||||
tmp.Mul(&a[i], &b[i])
|
||||
res.Add(&res, &tmp)
|
||||
}
|
||||
// The length checks is done by gnark-crypto already
|
||||
a_ := fr.Vector(a)
|
||||
res := a_.InnerProduct(fr.Vector(b))
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -63,14 +56,9 @@ func Rand(n int) []field.Element {
|
||||
// MulElementWise multiplies two vectors element wise and write the result in
|
||||
// res. res = a is a valid assignment.
|
||||
func MulElementWise(res, a, b []field.Element) {
|
||||
|
||||
if len(res) != len(a) || len(b) != len(a) {
|
||||
utils.Panic("The inputs should have the same length %v %v %v", len(res), len(a), len(b))
|
||||
}
|
||||
|
||||
for i := range a {
|
||||
res[i].Mul(&a[i], &b[i])
|
||||
}
|
||||
// The length checks is done by gnark-crypto already
|
||||
res_ := fr.Vector(res)
|
||||
res_.Mul(fr.Vector(a), fr.Vector(b))
|
||||
}
|
||||
|
||||
// Prettify returns a string representing `a` in a human-readable fashion
|
||||
|
||||
Reference in New Issue
Block a user