Skip to content

Commit

Permalink
better integration of gbench, including ci checks
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Oct 27, 2020
1 parent 8c2f7b7 commit 7bb1c45
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 20 deletions.
20 changes: 20 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
- run: cargo fetch
- run: rustup install $(cat rust-toolchain)
- run: rustup default $(cat rust-toolchain)
- run: rustup install nightly
- run: rustup component add rustfmt-preview
- run: rustup component add clippy-preview
- run: rustc --version
Expand Down Expand Up @@ -162,6 +163,22 @@ jobs:
name: Run cargo release build (blst, gpu)
command: cargo build --release --no-default-features --features blst,gpu

build_gbench:
executor: default
steps:
- *restore-workspace
- *restore-cache
- run: echo 'export PATH="$HOME:~/.cargo/bin:$PATH"' >> $BASH_ENV
- run: source $BASH_ENV
- run: sudo apt-get update -y
- run: apt-cache search opencl
- run: sudo apt install -y ocl-icd-opencl-dev
- run:
name: Run cargo release build (pairing, gpu)
command: cargo +nightly build -Zpackage-features --release -p gbench --no-default-features --features pairing,gpu
- run:
name: Run cargo release build (blst, gpu)
command: cargo +nightly build -Zpackage-features --release -p gbench --no-default-features --features blst,gpu

benches:
executor: default
Expand Down Expand Up @@ -201,6 +218,9 @@ workflows:
- build:
requires:
- cargo_fetch
- build_gbench:
requires:
- cargo_fetch
- benches:
requires:
- cargo_fetch
13 changes: 9 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ repository = "https://github.com/porcuquine/poseidon"

[dependencies]
lazy_static = "1.4.0"
bellperson = { git = "https://github.com/filecoin-project/bellman", branch = "blstrs", default-features = false }
bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs", default-features = false }
blake2s_simd = "0.5"
byteorder = "1"
ff = { version = "0.2.1", package = "fff" }
generic-array = "0.13.2"
generic-array = "0.14.4"
triton = { version = "2.0.0", package = "neptune-triton", default-features = false, features = ["opencl"], optional = true }
log = "0.4.8"

[dev-dependencies]
criterion = "0.3"
rand = "0.7.0"
sha2 = "0.8"
sha2 = "0.9"
tempdir = "0.3"
rand_xorshift = "0.2.0"
serde_json = "1.0.53"

[build-dependencies]
bellperson = { git = "https://github.com/filecoin-project/bellman", branch = "blstrs", default-features = false }
bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs", default-features = false }
ff = { version = "0.2.1", package = "fff" }

[[bench]]
Expand All @@ -46,3 +46,8 @@ default = ["pairing"]
gpu = ["triton"]
pairing = ["bellperson/pairing"]
blst = ["bellperson/blst"]

[workspace]
members = [
"gbench",
]
15 changes: 7 additions & 8 deletions benches/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@ where
BenchmarkId::new("Sha2 256", "Generated scalars"),
&scalars,
|b, s| {
let mut h = Sha256::new();
b.iter(|| {
let mut h = Sha256::new();

std::iter::repeat(())
.take(A::to_usize())
.map(|_| s.choose(&mut OsRng).unwrap())
.for_each(|scalar| {
for val in scalar.into_repr().as_ref() {
h.input(&val.to_le_bytes());
h.update(&val.to_le_bytes());
}
});

h.result();
h.finalize_reset()
})
},
);
Expand All @@ -45,19 +44,19 @@ where
BenchmarkId::new("Sha2 512", "Generated scalars"),
&scalars,
|b, s| {
b.iter(|| {
let mut h = Sha512::new();
let mut h = Sha512::new();

b.iter(|| {
std::iter::repeat(())
.take(A::to_usize())
.map(|_| s.choose(&mut OsRng).unwrap())
.for_each(|scalar| {
for val in scalar.into_repr().as_ref() {
h.input(&val.to_le_bytes());
h.update(&val.to_le_bytes());
}
});

h.result();
h.finalize_reset()
})
},
);
Expand Down
12 changes: 6 additions & 6 deletions gbench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ license = "MIT OR Apache-2.0"

[dependencies]
lazy_static = "1.4.0"
bellperson = "0.6.3"
bellperson = { git = "https://github.com/filecoin-project/bellperson", branch = "blstrs", default-features = false }
blake2s_simd = "0.5"
byteorder = "1"
env_logger = "0.7.1"
ff = { version = "0.2.1", package = "fff" }
generic-array = "0.13.2"
generic-array = "0.14.4"
log = "0.4.8"
neptune = { path = "../", features = ["gpu"] }
neptune = { path = "../", default-features = false }

[features]
default = ["pairing"]
default = ["pairing", "gpu"]
gpu = ["neptune/gpu"]
pairing = ["neptune/pairing"]
blst = ["neptune/blst"]
pairing = ["neptune/pairing", "bellperson/pairing"]
blst = ["neptune/blst", "bellperson/blst"]

4 changes: 2 additions & 2 deletions gbench/src/bin/gbench.rs → gbench/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use bellperson::bls::Fr;
use ff::Field;
use generic_array::sequence::GenericSequence;
use generic_array::typenum::{U11, U8};
Expand All @@ -7,7 +8,6 @@ use neptune::batch_hasher::BatcherType;
use neptune::column_tree_builder::{ColumnTreeBuilder, ColumnTreeBuilderTrait};
use neptune::error::Error;
use neptune::BatchHasher;
use bellperson::bls::Fr;
use std::result::Result;
use std::thread;
use std::time::Instant;
Expand Down Expand Up @@ -57,7 +57,7 @@ fn bench_column_building(
let _ = builder.add_columns(columns.as_slice()).unwrap();
total_columns += columns.len();
}
println!("");
println!();

let final_columns: Vec<_> = (0..leaves - total_columns)
.map(|_| GenericArray::<Fr, U11>::generate(|_| constant_element))
Expand Down

0 comments on commit 7bb1c45

Please sign in to comment.