Skip to content

Commit

Permalink
Add gpu2 feature flag for neptune/opencl.
Browse files Browse the repository at this point in the history
  • Loading branch information
porcuquine committed Jan 22, 2021
1 parent d8de812 commit 4121d26
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 8 deletions.
1 change: 1 addition & 0 deletions fil-proofs-param/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ heap-profile = ["gperftools/heap"]
simd = ["storage-proofs-core/simd"]
asm = ["storage-proofs-core/asm"]
gpu = ["storage-proofs-core/gpu", "storage-proofs-porep/gpu", "storage-proofs-post/gpu", "bellperson/gpu"]
gpu2 = ["storage-proofs-core/gpu2", "storage-proofs-porep/gpu2", "storage-proofs-post/gpu2", "bellperson/gpu"]
pairing = ["storage-proofs-core/pairing", "storage-proofs-porep/pairing", "storage-proofs-post/pairing", "bellperson/pairing"]
blst = ["storage-proofs-core/blst", "storage-proofs-porep/blst", "storage-proofs-post/blst", "bellperson/blst"]
8 changes: 8 additions & 0 deletions fil-proofs-tooling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ gpu = [
"bellperson/gpu",
"filecoin-hashers/gpu",
]
gpu2 = [
"storage-proofs-core/gpu2",
"storage-proofs-porep/gpu2",
"storage-proofs-post/gpu2",
"filecoin-proofs/gpu2",
"bellperson/gpu",
"filecoin-hashers/gpu2",
]
measurements = ["storage-proofs-core/measurements"]
profile = ["storage-proofs-core/profile", "measurements"]
pairing = [
Expand Down
1 change: 1 addition & 0 deletions filecoin-hashers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ hex = "0.4.2"
default = ["gpu", "pairing", "blake2s", "poseidon", "sha256"]

gpu = ["bellperson/gpu", "neptune/gpu"]
gpu2 = ["bellperson/gpu", "neptune/opencl"]

pairing = ["bellperson/pairing", "neptune/pairing", "bellperson/pairing-serde"]
blst = ["bellperson/blst", "neptune/blst", "bellperson/blst-serde"]
Expand Down
8 changes: 8 additions & 0 deletions filecoin-proofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ gpu = [
"filecoin-hashers/gpu",
"fr32/gpu",
]
gpu2 = [
"storage-proofs-core/gpu2",
"storage-proofs-porep/gpu2",
"storage-proofs-post/gpu2",
"bellperson/gpu",
"filecoin-hashers/gpu2",
"fr32/gpu",
]
pairing = [
"storage-proofs-core/pairing",
"storage-proofs-porep/pairing",
Expand Down
1 change: 1 addition & 0 deletions storage-proofs-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ measurements = ["cpu-time", "gperftools"]
profile = ["measurements"]

gpu = ["bellperson/gpu", "neptune/gpu", "filecoin-hashers/gpu", "fr32/gpu"]
gpu2 = ["bellperson/gpu", "neptune/opencl", "filecoin-hashers/gpu2", "fr32/gpu"]
pairing = ["bellperson/pairing", "neptune/pairing", "bellperson/pairing-serde", "filecoin-hashers/pairing", "fr32/pairing"]
blst = ["bellperson/blst", "neptune/blst", "bellperson/blst-serde", "filecoin-hashers/blst", "fr32/blst"]

Expand Down
1 change: 1 addition & 0 deletions storage-proofs-porep/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ filecoin-hashers = { path = "../filecoin-hashers", version = "1.0.0", default-fe
[features]
default = ["pairing", "gpu"]
gpu = ["storage-proofs-core/gpu", "filecoin-hashers/gpu", "neptune/gpu", "bellperson/gpu", "fr32/gpu"]
gpu2 = ["storage-proofs-core/gpu2", "filecoin-hashers/gpu2", "neptune/opencl", "bellperson/gpu", "fr32/gpu"]
pairing = ["storage-proofs-core/pairing", "bellperson/pairing", "neptune/pairing", "filecoin-hashers/pairing", "fr32/pairing"]
blst = ["storage-proofs-core/blst", "bellperson/blst", "neptune/blst", "filecoin-hashers/blst", "fr32/blst"]
single-threaded = []
Expand Down
25 changes: 17 additions & 8 deletions storage-proofs-porep/src/stacked/vanilla/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr
Ok(tree)
}

#[cfg(feature = "gpu")]
#[cfg(any(feature = "gpu", feature = "gpu2"))]
fn generate_tree_c<ColumnArity, TreeArity>(
layers: usize,
nodes_count: usize,
Expand Down Expand Up @@ -398,7 +398,7 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr
}
}

#[cfg(not(feature = "gpu"))]
#[cfg(not(any(feature = "gpu", feature = "gpu2")))]
fn generate_tree_c<ColumnArity, TreeArity>(
layers: usize,
nodes_count: usize,
Expand All @@ -420,7 +420,7 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr
}

#[allow(clippy::needless_range_loop)]
#[cfg(feature = "gpu")]
#[cfg(any(feature = "gpu", feature = "gpu2"))]
fn generate_tree_c_gpu<ColumnArity, TreeArity>(
layers: usize,
nodes_count: usize,
Expand Down Expand Up @@ -536,7 +536,10 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr
s.spawn(move |_| {
let _gpu_lock = GPU_LOCK.lock().unwrap();
let mut column_tree_builder = ColumnTreeBuilder::<ColumnArity, TreeArity>::new(
#[cfg(feature = "gpu")]
Some(BatcherType::GPU),
#[cfg(feature = "gpu2")]
Some(BatcherType::OpenCL),
nodes_count,
max_gpu_column_batch_size,
max_gpu_tree_batch_size,
Expand Down Expand Up @@ -720,7 +723,7 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr
})
}

#[cfg(feature = "gpu")]
#[cfg(any(feature = "gpu", feature = "gpu2"))]
fn generate_tree_r_last<TreeArity>(
data: &mut Data<'_>,
nodes_count: usize,
Expand Down Expand Up @@ -753,7 +756,7 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr
}
}

#[cfg(not(feature = "gpu"))]
#[cfg(not(any(feature = "gpu", feature = "gpu2")))]
fn generate_tree_r_last<TreeArity>(
data: &mut Data<'_>,
nodes_count: usize,
Expand All @@ -775,7 +778,7 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr
)
}

#[cfg(feature = "gpu")]
#[cfg(any(feature = "gpu", feature = "gpu2"))]
fn generate_tree_r_last_gpu<TreeArity>(
data: &mut Data<'_>,
nodes_count: usize,
Expand Down Expand Up @@ -879,7 +882,10 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr
s.spawn(move |_| {
let _gpu_lock = GPU_LOCK.lock().unwrap();
let mut tree_builder = TreeBuilder::<Tree::Arity>::new(
#[cfg(feature = "gpu")]
Some(BatcherType::GPU),
#[cfg(feature = "gpu2")]
Some(BatcherType::OpenCL),
nodes_count,
max_gpu_tree_batch_size,
tree_r_last_config.rows_to_discard,
Expand Down Expand Up @@ -1287,7 +1293,7 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr
// Assumes data is all zeros.
// Replica path is used to create configs, but is not read.
// Instead new zeros are provided (hence the need for replica to be all zeros).
#[cfg(feature = "gpu")]
#[cfg(any(feature = "gpu", feature = "gpu2"))]
fn generate_fake_tree_r_last<TreeArity>(
nodes_count: usize,
tree_count: usize,
Expand Down Expand Up @@ -1319,7 +1325,10 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr

let _gpu_lock = GPU_LOCK.lock().unwrap();
let mut tree_builder = TreeBuilder::<Tree::Arity>::new(
#[cfg(feature = "gpu")]
Some(BatcherType::GPU),
#[cfg(feature = "gpu2")]
Some(BatcherType::OpenCL),
nodes_count,
max_gpu_tree_batch_size,
tree_r_last_config.rows_to_discard,
Expand Down Expand Up @@ -1411,7 +1420,7 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr
// Assumes data is all zeros.
// Replica path is used to create configs, but is not read.
// Instead new zeros are provided (hence the need for replica to be all zeros).
#[cfg(not(feature = "gpu"))]
#[cfg(not(any(feature = "gpu", feature = "gpu2")))]
fn generate_fake_tree_r_last<TreeArity>(
nodes_count: usize,
tree_count: usize,
Expand Down
1 change: 1 addition & 0 deletions storage-proofs-post/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ filecoin-hashers = { path = "../filecoin-hashers", version = "1.0.0", default-fe
[features]
default = ["pairing", "gpu"]
gpu = ["storage-proofs-core/gpu", "filecoin-hashers/gpu", "fr32/gpu"]
gpu2 = ["storage-proofs-core/gpu2", "filecoin-hashers/gpu2", "fr32/gpu"]
pairing = ["storage-proofs-core/pairing", "bellperson/pairing", "neptune/pairing", "filecoin-hashers/pairing", "fr32/pairing"]
blst = ["storage-proofs-core/blst", "bellperson/blst", "neptune/blst", "filecoin-hashers/blst", "fr32/blst"]

0 comments on commit 4121d26

Please sign in to comment.