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

fix tree-c and tree-r-last generation in GPU mode #1375

Merged
merged 1 commit into from
Nov 24, 2020
Merged
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
108 changes: 57 additions & 51 deletions storage-proofs/porep/src/stacked/vanilla/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,38 +527,41 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr

// Loop until all trees for all configs have been built.
for i in 0..config_count {
let (columns, is_final): (Vec<GenericArray<Fr, ColumnArity>>, bool) =
builder_rx.recv().expect("failed to recv columns");

// Just add non-final column batches.
if !is_final {
column_tree_builder
.add_columns(&columns)
.expect("failed to add columns");
continue;
};
loop {
let (columns, is_final): (Vec<GenericArray<Fr, ColumnArity>>, bool) =
builder_rx.recv().expect("failed to recv columns");

// Just add non-final column batches.
if !is_final {
column_tree_builder
.add_columns(&columns)
.expect("failed to add columns");
continue;
};

// If we get here, this is a final column: build a sub-tree.
let (base_data, tree_data) = column_tree_builder
.add_final_columns(&columns)
.expect("failed to add final columns");
trace!(
"base data len {}, tree data len {}",
base_data.len(),
tree_data.len()
);

let tree_len = base_data.len() + tree_data.len();
info!(
"persisting base tree_c {}/{} of length {}",
i + 1,
tree_count,
tree_len,
);
// If we get here, this is a final column: build a sub-tree.
let (base_data, tree_data) = column_tree_builder
.add_final_columns(&columns)
.expect("failed to add final columns");
trace!(
"base data len {}, tree data len {}",
base_data.len(),
tree_data.len()
);

let tree_len = base_data.len() + tree_data.len();
info!(
"persisting base tree_c {}/{} of length {}",
i + 1,
tree_count,
tree_len,
);

writer_tx
.send((base_data, tree_data))
.expect("failed to send base_data, tree_data");
writer_tx
.send((base_data, tree_data))
.expect("failed to send base_data, tree_data");
break;
}
}
});

Expand Down Expand Up @@ -804,28 +807,31 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr

// Loop until all trees for all configs have been built.
for i in 0..config_count {
let (encoded, is_final) =
builder_rx.recv().expect("failed to recv encoded data");

// Just add non-final leaf batches.
if !is_final {
tree_builder
.add_leaves(&encoded)
.expect("failed to add leaves");
continue;
};
loop {
let (encoded, is_final) =
builder_rx.recv().expect("failed to recv encoded data");

// Just add non-final leaf batches.
if !is_final {
tree_builder
.add_leaves(&encoded)
.expect("failed to add leaves");
continue;
};

// If we get here, this is a final leaf batch: build a sub-tree.
info!(
"building base tree_r_last with GPU {}/{}",
i + 1,
tree_count
);
let (_, tree_data) = tree_builder
.add_final_leaves(&encoded)
.expect("failed to add final leaves");

writer_tx.send(tree_data).expect("failed to send tree_data");
// If we get here, this is a final leaf batch: build a sub-tree.
info!(
"building base tree_r_last with GPU {}/{}",
i + 1,
tree_count
);
let (_, tree_data) = tree_builder
.add_final_leaves(&encoded)
.expect("failed to add final leaves");

writer_tx.send(tree_data).expect("failed to send tree_data");
break;
}
}
});

Expand Down