Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow hwloc to be optional, but enabled by default #1468

Merged
merged 2 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,37 @@ The instructions below assume you have independently installed `rust-fil-proofs`

Before building you will need OpenCL to be installed. On Ubuntu, this can be achieved with `apt install ocl-icd-opencl-dev`. Other system dependencies such as 'gcc/clang', 'wall' and 'cmake' are also required.

You will also need to install the hwloc library. On Ubuntu, this can be achieved with `apt install hwloc libhwloc-dev`. For other platforms, please see the [hwloc-rs Prerequisites section](https://github.com/daschl/hwloc-rs).
For the `multicore sdr` feature (enabled by default), you will also need to install the `hwloc` library. On Ubuntu, this can be achieved with `apt install hwloc libhwloc-dev`. For other platforms, please see the [hwloc-rs Prerequisites section](https://github.com/daschl/hwloc-rs).


```
> cargo build --release --all
```

The `hwloc` dependency is optional and may be disabled. Disabling it will not allow the `multicore sdr` feature to be used. The fallback is single core replication, which is the default unless specified otherwise.

To disable `multicore sdr` so that `hwloc` is not required, you can build proofs like this:

```
> cargo build --release --all --no-default-features --features pairing,gpu
```

Note that the `multicore-sdr` feature is omitted from the specified feature list, which removes it from being used by default.


## Building for Arm64

In order to build for arm64 the current requirements are

- nightly rust compiler

Example for building `filecoin-proofs`

```
$ rustup +nightly target add aarch64-unknown-linux-gnu
$ cargo +nightly build -p filecoin-proofs --release --target aarch64-unknown-linux-gnu
```

## Test

```
Expand Down Expand Up @@ -334,19 +358,6 @@ To generate the API documentation locally, follow the instructions to generate d
- [Go implementation of filecoin-proofs sectorbuilder API](https://github.com/filecoin-project/go-sectorbuilder/blob/master/sectorbuilder.go) and [associated interface structures](https://github.com/filecoin-project/go-sectorbuilder/blob/master/interface.go).


## Building for Arm64

In order to build for arm64 the current requirements are

- nightly rust compiler

Example for building `filecoin-proofs`

```
$ rustup +nightly target add aarch64-unknown-linux-gnu
$ cargo +nightly build -p filecoin-proofs --release --target aarch64-unknown-linux-gnu
```

## Contributing

See [Contributing](CONTRIBUTING.md)
Expand Down
5 changes: 3 additions & 2 deletions storage-proofs-porep/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bincode = "1.1.2"
byteorder = "1.3.4"
lazy_static = "1.2"
byte-slice-cast = "1.0.0"
hwloc = "0.3.0"
hwloc = { version = "0.3.0", optional = true }
libc = "0.2"
fdlimit = "0.2.0"
fr32 = { path = "../fr32", version = "^1.0.0", default-features = false }
Expand All @@ -54,11 +54,12 @@ pretty_env_logger = "0.4.0"
filecoin-hashers = { path = "../filecoin-hashers", version = "^3.0.0", default-features = false, features = ["poseidon", "sha256", "blake2s"]}

[features]
default = ["pairing", "gpu"]
default = ["pairing", "gpu", "multicore-sdr"]
gpu = ["storage-proofs-core/gpu", "filecoin-hashers/gpu", "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 = []
multicore-sdr = ["hwloc"]

[[bench]]
name = "encode"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use storage_proofs_core::{

use crate::stacked::vanilla::{proof::LayerState, StackedBucketGraph};

#[cfg(feature = "multicore-sdr")]
pub mod multi;
pub mod single;

Expand Down
2 changes: 2 additions & 0 deletions storage-proofs-porep/src/stacked/vanilla/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ macro_rules! prefetch {
};
}

// Used in multicore sdr only
#[allow(unused_macros)]
macro_rules! compress256 {
($state:expr, $buf:expr, 1) => {
let blocks = [*GenericArray::<u8, U64>::from_slice(&$buf[..64])];
Expand Down
3 changes: 3 additions & 0 deletions storage-proofs-porep/src/stacked/vanilla/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ mod cache;
mod challenges;
mod column;
mod column_proof;
#[cfg(feature = "multicore-sdr")]
mod cores;
mod encoding_proof;
mod graph;
mod labeling_proof;
#[cfg(feature = "multicore-sdr")]
mod memory_handling;
mod params;
mod porep;
mod proof;
mod proof_scheme;
#[cfg(feature = "multicore-sdr")]
mod utils;

pub use challenges::{ChallengeRequirements, LayerChallenges};
Expand Down
70 changes: 50 additions & 20 deletions storage-proofs-porep/src/stacked/vanilla/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,16 +313,31 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr
) -> Result<(Labels<Tree>, Vec<LayerState>)> {
let mut parent_cache = graph.parent_cache()?;

if SETTINGS.use_multicore_sdr {
info!("multi core replication");
create_label::multi::create_labels_for_encoding(
graph,
&parent_cache,
layer_challenges.layers(),
replica_id,
config,
)
} else {
#[cfg(feature = "multicore-sdr")]
{
if SETTINGS.use_multicore_sdr {
info!("multi core replication");
create_label::multi::create_labels_for_encoding(
graph,
&parent_cache,
layer_challenges.layers(),
replica_id,
config,
)
} else {
info!("single core replication");
create_label::single::create_labels_for_encoding(
graph,
&mut parent_cache,
layer_challenges.layers(),
replica_id,
config,
)
}
}

#[cfg(not(feature = "multicore-sdr"))]
{
info!("single core replication");
create_label::single::create_labels_for_encoding(
graph,
Expand All @@ -343,16 +358,31 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr
) -> Result<LabelsCache<Tree>> {
let mut parent_cache = graph.parent_cache()?;

if SETTINGS.use_multicore_sdr {
info!("multi core replication");
create_label::multi::create_labels_for_decoding(
graph,
&parent_cache,
layer_challenges.layers(),
replica_id,
config,
)
} else {
#[cfg(feature = "multicore-sdr")]
{
if SETTINGS.use_multicore_sdr {
info!("multi core replication");
create_label::multi::create_labels_for_decoding(
graph,
&parent_cache,
layer_challenges.layers(),
replica_id,
config,
)
} else {
info!("single core replication");
create_label::single::create_labels_for_decoding(
graph,
&mut parent_cache,
layer_challenges.layers(),
replica_id,
config,
)
}
}

#[cfg(not(feature = "multicore-sdr"))]
{
info!("single core replication");
create_label::single::create_labels_for_decoding(
graph,
Expand Down