Shred gpu sigverify (#6520)

Implement APIs for verifying shred signatures on the GPU.
This commit is contained in:
anatoly yakovenko
2019-10-28 10:29:38 -07:00
committed by GitHub
parent 30c0a7d069
commit 243fa6cf63
4 changed files with 436 additions and 22 deletions

View File

@@ -24,6 +24,7 @@ use std::cell::RefCell;
thread_local!(static PAR_THREAD_POOL: RefCell<ThreadPool> = RefCell::new(rayon::ThreadPoolBuilder::new()
.num_threads(get_thread_count())
.thread_name(|ix| format!("sigverify_{}", ix))
.build()
.unwrap()));
@@ -114,7 +115,7 @@ fn verify_packet(packet: &Packet) -> u8 {
1
}
fn batch_size(batches: &[Packets]) -> usize {
pub fn batch_size(batches: &[Packets]) -> usize {
batches.iter().map(|p| p.packets.len()).sum()
}
@@ -271,6 +272,29 @@ pub fn ed25519_verify_disabled(batches: &[Packets]) -> Vec<Vec<u8>> {
rv
}
pub fn copy_return_values(sig_lens: &[Vec<u32>], out: &PinnedVec<u8>, rvs: &mut Vec<Vec<u8>>) {
let mut num = 0;
for (vs, sig_vs) in rvs.iter_mut().zip(sig_lens.iter()) {
for (v, sig_v) in vs.iter_mut().zip(sig_vs.iter()) {
if *sig_v == 0 {
*v = 0;
} else {
let mut vout = 1;
for _ in 0..*sig_v {
if 0 == out[num] {
vout = 0;
}
num += 1;
}
*v = vout;
}
if *v != 0 {
trace!("VERIFIED PACKET!!!!!");
}
}
}
}
pub fn ed25519_verify(
batches: &[Packets],
recycler: &Recycler<TxOffset>,
@@ -340,26 +364,7 @@ pub fn ed25519_verify(
}
}
trace!("done verify");
let mut num = 0;
for (vs, sig_vs) in rvs.iter_mut().zip(sig_lens.iter()) {
for (v, sig_v) in vs.iter_mut().zip(sig_vs.iter()) {
if *sig_v == 0 {
*v = 0;
} else {
let mut vout = 1;
for _ in 0..*sig_v {
if 0 == out[num] {
vout = 0;
}
num += 1;
}
*v = vout;
}
if *v != 0 {
trace!("VERIFIED PACKET!!!!!");
}
}
}
copy_return_values(&sig_lens, &out, &mut rvs);
inc_new_counter_debug!("ed25519_verify_gpu", count);
recycler_out.recycle(out);
recycler.recycle(signature_offsets);