Skip to content
Snippets Groups Projects
Verified Commit 78bbb643 authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

Merge branch 'main' into add-more-curves-to-linalg

parents b20dec73 1395283f
No related branches found
No related tags found
1 merge request!156add more curves to linalg benchmarks
Pipeline #5623 passed
.env.nu 0 → 100644
const MODULES = [
".nushell/math.nu",
".nushell/formats.nu",
]
def log-load [m: string] {
print $"[(ansi cyan_bold).env.nu(ansi reset)] loading (ansi purple)($m)(ansi reset)"
}
log-load $MODULES.0
use $MODULES.0 *
log-load $MODULES.1
use $MODULES.1 *
...@@ -8,8 +8,8 @@ use .nushell/formats.nu * ...@@ -8,8 +8,8 @@ use .nushell/formats.nu *
## atomic operations ## atomic operations
```nushell ```nushell
cargo run --release --example bench_field_operations -- --nb-measurements 1000 out> field.ndjson cargo run --release --package benchmarks --bin field_operations -- --nb-measurements 1000 out> field.ndjson
cargo run --release --example bench_curve_group_operations -- --nb-measurements 1000 out> curve_group.ndjson cargo run --release --package benchmarks --bin curve_group_operations -- --nb-measurements 1000 out> curve_group.ndjson
``` ```
```nushell ```nushell
use .nushell/parse.nu read-atomic-ops use .nushell/parse.nu read-atomic-ops
...@@ -39,10 +39,11 @@ gplt multi_bar --title "complex curve group operations" -l "time (in ns)" ( ...@@ -39,10 +39,11 @@ gplt multi_bar --title "complex curve group operations" -l "time (in ns)" (
## linear algebra ## linear algebra
```nushell ```nushell
let sizes = seq 0 7 | each { 2 ** $in } let sizes = seq 0 7 | each { 2 ** $in }
cargo run --release --example bench_linalg -- --nb-measurements 10 ...$sizes out> linalg.ndjson cargo run --release --package benchmarks --bin linalg -- --nb-measurements 10 ...$sizes out> linalg.ndjson
| save --force linalg.ndjson
``` ```
```nushell ```nushell
use .nushell/plot.nu [ "into-axis-options", COMMON_OPTIONS ]
let linalg = open linalg.ndjson let linalg = open linalg.ndjson
| ns-to-ms $.times | ns-to-ms $.times
| compute-stats $.times | compute-stats $.times
...@@ -53,24 +54,23 @@ let linalg = open linalg.ndjson ...@@ -53,24 +54,23 @@ let linalg = open linalg.ndjson
for graph in [ for graph in [
[op, title]; [op, title];
["inverse", "time to inverse an nxn matrix on certain curves"], ["inverse", "time to inverse an $n \\times n$ matrix"],
["transpose", "time to transpose an nxn matrix on certain curves"], ["transpose", "time to transpose an $n \\times n$ matrix"],
["mul", "time to multiply two nxn matrices on certain curves"] ["mul", "time to multiply two $n \\times n$ matrices"]
] { ] {
let graphs = $linalg
| where op == $graph.op
| rename --column { n: "x", mean: "y", stddev: "e" }
| group-by name --to-table
| rename --column { group: "name", items: "points" }
gplt plot ...[ gplt plot ...[
--title $graph.title --title $graph.title
--x-label "size" --x-label "n"
--y-label "time (in ms)" --use-tex
--x-scale "log" ($graphs | to json)
--y-scale "log" ...$COMMON_OPTIONS
( ...($graphs.points | flatten | into-axis-options -x "plain" -y "duration")
$linalg --x-ticks-rotation 0
| where op == $graph.op
| rename --column { n: "x", mean: "y", stddev: "e" }
| group-by name --to-table
| rename --column { group: "name", items: "points" }
| to json
)
] ]
} }
``` ```
......
...@@ -115,6 +115,9 @@ enum Curve { ...@@ -115,6 +115,9 @@ enum Curve {
SECP256K1, SECP256K1,
SECP256R1, SECP256R1,
Vesta, Vesta,
EDOnMnt4298,
CP6782,
MNT4753,
} }
#[derive(Parser)] #[derive(Parser)]
...@@ -213,6 +216,33 @@ fn main() { ...@@ -213,6 +216,33 @@ fn main() {
name = "VESTA" name = "VESTA"
) )
} }
Curve::EDOnMnt4298 => {
measure!(
ark_ed_on_mnt4_298,
degrees,
cli.nb_measurements,
G1 = EdwardsProjective,
name = "ED-MNT4-298"
)
}
Curve::CP6782 => {
measure!(
ark_cp6_782,
degrees,
cli.nb_measurements,
G1 = G1Projective,
name = "CP6-782"
)
}
Curve::MNT4753 => {
measure!(
ark_mnt4_753,
degrees,
cli.nb_measurements,
G1 = G1Projective,
name = "MNT4-753"
)
}
} }
} }
} }
...@@ -55,6 +55,7 @@ fn main() { ...@@ -55,6 +55,7 @@ fn main() {
inverse_template::<ark_bls12_381::Fr>(&b.with_name("BLS12-381"), n); inverse_template::<ark_bls12_381::Fr>(&b.with_name("BLS12-381"), n);
inverse_template::<ark_bn254::Fr>(&b.with_name("BN254"), n); inverse_template::<ark_bn254::Fr>(&b.with_name("BN254"), n);
inverse_template::<ark_pallas::Fr>(&b.with_name("PALLAS"), n); inverse_template::<ark_pallas::Fr>(&b.with_name("PALLAS"), n);
inverse_template::<benchmarks::fields::Fq128>(&b.with_name("small"), n);
inverse_template::<ark_ed_on_mnt4_298::Fr>(&b.with_name("ED-MNT4-298"), n); inverse_template::<ark_ed_on_mnt4_298::Fr>(&b.with_name("ED-MNT4-298"), n);
inverse_template::<ark_cp6_782::Fr>(&b.with_name("CP6-782"), n); inverse_template::<ark_cp6_782::Fr>(&b.with_name("CP6-782"), n);
inverse_template::<ark_mnt4_753::Fr>(&b.with_name("MNT4-753"), n); inverse_template::<ark_mnt4_753::Fr>(&b.with_name("MNT4-753"), n);
...@@ -62,6 +63,7 @@ fn main() { ...@@ -62,6 +63,7 @@ fn main() {
transpose_template::<ark_bls12_381::Fr>(&b.with_name("BLS12-381"), n); transpose_template::<ark_bls12_381::Fr>(&b.with_name("BLS12-381"), n);
transpose_template::<ark_bn254::Fr>(&b.with_name("BN254"), n); transpose_template::<ark_bn254::Fr>(&b.with_name("BN254"), n);
transpose_template::<ark_pallas::Fr>(&b.with_name("PALLAS"), n); transpose_template::<ark_pallas::Fr>(&b.with_name("PALLAS"), n);
transpose_template::<benchmarks::fields::Fq128>(&b.with_name("small"), n);
transpose_template::<ark_ed_on_mnt4_298::Fr>(&b.with_name("ED-MNT4-298"), n); transpose_template::<ark_ed_on_mnt4_298::Fr>(&b.with_name("ED-MNT4-298"), n);
transpose_template::<ark_cp6_782::Fr>(&b.with_name("CP6-782"), n); transpose_template::<ark_cp6_782::Fr>(&b.with_name("CP6-782"), n);
transpose_template::<ark_mnt4_753::Fr>(&b.with_name("MNT4-753"), n); transpose_template::<ark_mnt4_753::Fr>(&b.with_name("MNT4-753"), n);
...@@ -69,6 +71,7 @@ fn main() { ...@@ -69,6 +71,7 @@ fn main() {
mul_template::<ark_bls12_381::Fr>(&b.with_name("BLS12-381"), n); mul_template::<ark_bls12_381::Fr>(&b.with_name("BLS12-381"), n);
mul_template::<ark_bn254::Fr>(&b.with_name("BN254"), n); mul_template::<ark_bn254::Fr>(&b.with_name("BN254"), n);
mul_template::<ark_pallas::Fr>(&b.with_name("PALLAS"), n); mul_template::<ark_pallas::Fr>(&b.with_name("PALLAS"), n);
mul_template::<benchmarks::fields::Fq128>(&b.with_name("small"), n);
mul_template::<ark_ed_on_mnt4_298::Fr>(&b.with_name("ED-MNT4-298"), n); mul_template::<ark_ed_on_mnt4_298::Fr>(&b.with_name("ED-MNT4-298"), n);
mul_template::<ark_cp6_782::Fr>(&b.with_name("CP6-782"), n); mul_template::<ark_cp6_782::Fr>(&b.with_name("CP6-782"), n);
mul_template::<ark_mnt4_753::Fr>(&b.with_name("MNT4-753"), n); mul_template::<ark_mnt4_753::Fr>(&b.with_name("MNT4-753"), n);
......
...@@ -93,4 +93,5 @@ fn main() { ...@@ -93,4 +93,5 @@ fn main() {
bench_template::<ark_bls12_381::Fr>(&bencher.with_name("BLS12-381")); bench_template::<ark_bls12_381::Fr>(&bencher.with_name("BLS12-381"));
bench_template::<ark_bn254::Fr>(&bencher.with_name("BN254")); bench_template::<ark_bn254::Fr>(&bencher.with_name("BN254"));
bench_template::<ark_pallas::Fr>(&bencher.with_name("PALLAS")); bench_template::<ark_pallas::Fr>(&bencher.with_name("PALLAS"));
bench_template::<benchmarks::fields::Fq128>(&bencher.with_name("small"));
} }
...@@ -160,6 +160,9 @@ enum Curve { ...@@ -160,6 +160,9 @@ enum Curve {
BLS12381, BLS12381,
BN254, BN254,
Pallas, Pallas,
EDOnMnt4298,
CP6782,
MNT4753,
ARKBLS12381, ARKBLS12381,
ARKBN254, ARKBN254,
} }
...@@ -216,6 +219,27 @@ fn main() { ...@@ -216,6 +219,27 @@ fn main() {
"BLS12-381", "BLS12-381",
); );
} }
Curve::EDOnMnt4298 => {
setup::<ark_ed_on_mnt4_298::Fr, ark_ed_on_mnt4_298::EdwardsProjective>(
&cli.degrees,
cli.nb_measurements,
"ED-MNT4-298",
);
}
Curve::CP6782 => {
setup::<ark_cp6_782::Fr, ark_cp6_782::G1Projective>(
&cli.degrees,
cli.nb_measurements,
"CP6-782",
);
}
Curve::MNT4753 => {
setup::<ark_mnt4_753::Fr, ark_mnt4_753::G1Projective>(
&cli.degrees,
cli.nb_measurements,
"MNT4-753",
);
}
} }
} }
......
use ark_ff::{Fp128, MontBackend, MontConfig};
#[derive(MontConfig)]
#[modulus = "340282366920938463463374557953744961537"]
#[generator = "3"]
pub struct Test;
/// A prime, fft-friendly field isomorph to [`winter_math::fields::f128::BaseElement`].
pub type Fq128 = Fp128<MontBackend<Test, 2>>;
pub mod fields;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment