Skip to content

Commit

Permalink
build Merkle Tree only with leaves allocated from Rust and remove locks
Browse files Browse the repository at this point in the history
  • Loading branch information
dloghin committed Apr 18, 2024
1 parent 3779c03 commit 0bdacd8
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 309 deletions.
2 changes: 1 addition & 1 deletion field/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ rand = { workspace = true, features = ["getrandom"] }
serde = { workspace = true, features = ["alloc"] }
static_assertions = { workspace = true }
unroll = { workspace = true }
cryptography_cuda ={git="ssh://[email protected]/okx/cryptography_cuda.git", rev="56cee09dd044de44f05c7d54383c6a8cb4078b29", optional=true}
cryptography_cuda = { git = "ssh://[email protected]/okx/cryptography_cuda.git", rev = "173510160183f3299f4765b30bd4f2c1685353f9", optional = true }

[dev-dependencies]
rand = { version = "0.8.5", default-features = false, features = ["getrandom"] }
Expand Down
2 changes: 1 addition & 1 deletion plonky2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ once_cell = { version = "1.18.0" }
plonky2_field = { version = "0.2.0", path = "../field", default-features = false }
plonky2_maybe_rayon = { version = "0.2.0", path = "../maybe_rayon", default-features = false }
plonky2_util = { version = "0.2.0", path = "../util", default-features = false }
cryptography_cuda ={git="ssh://[email protected]/okx/cryptography_cuda.git", rev="56cee09dd044de44f05c7d54383c6a8cb4078b29", optional=true}
cryptography_cuda = { git = "ssh://[email protected]/okx/cryptography_cuda.git", rev = "173510160183f3299f4765b30bd4f2c1685353f9", optional = true }

[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
getrandom = { version = "0.2", default-features = false, features = ["js"] }
Expand Down
9 changes: 0 additions & 9 deletions plonky2/src/fri/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use cryptography_cuda::{
device::memory::HostOrDeviceSlice, lde_batch, lde_batch_multi_gpu, transpose_rev_batch,
types::*,
};
#[cfg(feature = "cuda")]
use crate::hash::merkle_tree::GPU_LOCK;

use itertools::Itertools;
use plonky2_field::types::Field;
Expand Down Expand Up @@ -245,10 +243,6 @@ impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
log_n: usize,
_degree: usize,
) -> MerkleTree<F, <C as GenericConfig<D>>::Hasher> {

let mut lock = GPU_LOCK.lock().unwrap();
*lock += 1;

// let salt_size = if blinding { SALT_SIZE } else { 0 };
// println!("salt_size: {:?}", salt_size);
let output_domain_size = log_n + rate_bits;
Expand Down Expand Up @@ -374,9 +368,6 @@ impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>

#[cfg(all(feature = "cuda", feature = "batch"))]
if log_n > 10 && polynomials.len() > 0 {
let mut lock = GPU_LOCK.lock().unwrap();
*lock += 1;

println!("log_n: {:?}", log_n);
let start_lde = std::time::Instant::now();

Expand Down
Loading

0 comments on commit 0bdacd8

Please sign in to comment.