Skip to content

Commit

Permalink
Add gpu2 feature flag for neptune/opencl. (#1397)
Browse files Browse the repository at this point in the history
Co-authored-by: porcuquine <porcuquine@users.noreply.github.com>
  • Loading branch information
porcuquine and porcuquine authored Feb 16, 2021
1 parent 9b3bab2 commit 64390b6
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 9 deletions.
44 changes: 44 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,45 @@ jobs:
RUST_TEST_THREADS: 1
FIL_PROOFS_USE_MULTICORE_SDR: true

# Running with `use_multicore_sdr=true` should be integrated directly into the test code. For now we
# just re-run the lifecycle tests to exercise the use_multicore_sdr code path with that setting set.
test_multicore_sdr_gpu2:
executor: default
environment: *setup-env
steps:
- checkout
- attach_workspace:
at: "."
- restore_cache:
keys:
- cargo-v28-b-{{ checksum "rust-toolchain" }}-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}-{{ arch }}
- restore_parameter_cache
- run:
name: Test with use_multicore_sdr pairing enabled
command: |
ulimit -n 20000
ulimit -u 20000
ulimit -n 20000
cargo +<< pipeline.parameters.nightly-toolchain >> -Zpackage-features test --all --verbose --release lifecycle -- --ignored --nocapture
cargo +<< pipeline.parameters.nightly-toolchain >> -Zpackage-features test -p storage-proofs-porep --features single-threaded --release checkout_cores -- --test-threads=1
no_output_timeout: 30m
environment:
RUST_TEST_THREADS: 1
FIL_PROOFS_USE_MULTICORE_SDR: true

- run:
name: Test with use_multicore_sdr and blst enabled
command: |
ulimit -n 20000
ulimit -u 20000
ulimit -n 20000
cargo +<< pipeline.parameters.nightly-toolchain >> -Zpackage-features test --all --no-default-features --features gpu2,blst --verbose --release lifecycle -- --ignored --nocapture
no_output_timeout: 30m
environment:
RUST_TEST_THREADS: 1
FIL_PROOFS_USE_MULTICORE_SDR: true


test_no_gpu:
executor: default
environment: *setup-env
Expand Down Expand Up @@ -467,6 +506,11 @@ workflows:
- cargo_fetch
- ensure_groth_parameters_and_keys_linux

- test_multicore_sdr_gpu2:
requires:
- cargo_fetch
- ensure_groth_parameters_and_keys_linux

- test_blst:
name: test_blst_filecoin_proofs
crate: "filecoin-proofs"
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ members = [
"sha2raw",
"filecoin-hashers",
]

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 @@ -375,7 +375,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 @@ -406,7 +406,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 @@ -428,7 +428,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 @@ -549,7 +549,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 @@ -731,7 +734,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 @@ -764,7 +767,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 @@ -786,7 +789,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 @@ -894,7 +897,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 @@ -1306,7 +1312,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 @@ -1341,7 +1347,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 @@ -1436,7 +1445,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 64390b6

Please sign in to comment.