Skip to content
Open
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
10 changes: 5 additions & 5 deletions jets-bench/benches/elements/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use elements::confidential;
use rand::rngs::ThreadRng;
use simplicity::elements;
use simplicity::jet::elements::ElementsEnv;
use simplicity::jet::{Elements, Jet};
use simplicity::jet::{Elements, ElementsTxEnv, Jet, JetEnvironment};
use simplicity::types;
use simplicity::types::Final;
use simplicity::Value;
Expand Down Expand Up @@ -625,7 +625,7 @@ fn bench(c: &mut Criterion) {
let (src, dst) = buffer.write(&src_ty, params, &mut rng);
(dst, src, &env, buffer)
},
|(mut dst, src, env, _buffer)| jet.c_jet_ptr()(&mut dst, src, env.c_tx_env()),
|(mut dst, src, env, _buffer)| ElementsTxEnv::c_jet_ptr(&jet)(&mut dst, src, env.c_tx_env()),
BatchSize::SmallInput,
)
});
Expand Down Expand Up @@ -743,7 +743,7 @@ fn bench(c: &mut Criterion) {
let (src, dst) = buffer.write(&src_ty, params, &mut rng);
(dst, src, buffer)
},
|(mut dst, src, _buffer)| jet.c_jet_ptr()(&mut dst, src, env.c_tx_env()),
|(mut dst, src, _buffer)| ElementsTxEnv::c_jet_ptr(&jet)(&mut dst, src, env.c_tx_env()),
BatchSize::SmallInput,
)
});
Expand Down Expand Up @@ -806,7 +806,7 @@ fn bench(c: &mut Criterion) {
let (src, dst) = buffer.write(&src_ty, params, &mut rng);
(dst, src, buffer)
},
|(mut dst, src, _buffer)| jet.c_jet_ptr()(&mut dst, src, env.c_tx_env()),
|(mut dst, src, _buffer)| ElementsTxEnv::c_jet_ptr(&jet)(&mut dst, src, env.c_tx_env()),
BatchSize::SmallInput,
)
});
Expand Down Expand Up @@ -903,7 +903,7 @@ fn bench(c: &mut Criterion) {
let (src, dst) = buffer.write(&src_ty, params, &mut rng);
(dst, src, buffer)
},
|(mut dst, src, _buffer)| jet.c_jet_ptr()(&mut dst, src, env.c_tx_env()),
|(mut dst, src, _buffer)| ElementsTxEnv::c_jet_ptr(&jet)(&mut dst, src, env.c_tx_env()),
BatchSize::SmallInput,
)
});
Expand Down
18 changes: 11 additions & 7 deletions jets-bench/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use simplicity::ffi::c_jets::frame_ffi::c_writeBit;
use simplicity::ffi::ffi::UWORD;
use simplicity::ffi::CFrameItem;
use simplicity::hashes::Hash;
use simplicity::jet::Elements;
use simplicity::jet::{Elements, ElementsTxEnv, JetEnvironment};
use simplicity::types::{self, CompleteBound};
use simplicity::Value;

Expand Down Expand Up @@ -296,7 +296,6 @@ impl FlatValue {
fn call_jet(&self, jet: Elements, dest_bits: usize) -> Self {
use core::{mem, ptr};
use simplicity::ffi::c_jets::uword_width;
use simplicity::jet::Jet as _;

assert!(dest_bits <= 8 * MAX_VALUE_BYTES);
let mut ret = Self::zero_n_bits(dest_bits);
Expand Down Expand Up @@ -354,10 +353,11 @@ impl FlatValue {

// We can assert this because in our sampling code jets should never
// fail. In the benchmarking code they might.
assert!(jet.c_jet_ptr()(

assert!(ElementsTxEnv::c_jet_ptr(&jet)(
&mut dst_write_frame,
src_read_frame,
Elements::c_jet_env(&env)
env.c_tx_env()
));
// The write frame winds up as an array of usizes with all bytes in
// reverse order. (The bytes of the usizes are in reverse order due
Expand Down Expand Up @@ -1366,8 +1366,12 @@ impl InputSample for DivMod12864Input {
for (bit1, bit2) in sample_1.bit_iter().zip(sample_2.bit_iter()) {
match (bit1, bit2) {
(false, false) | (true, true) => {} // both equal
(true, false) => return FlatValue::product(&[sample_2, UniformBits.sample(0, 64), sample_1]),
(false, true) => return FlatValue::product(&[sample_1, UniformBits.sample(0, 64), sample_2]),
(true, false) => {
return FlatValue::product(&[sample_2, UniformBits.sample(0, 64), sample_1])
}
(false, true) => {
return FlatValue::product(&[sample_1, UniformBits.sample(0, 64), sample_2])
}
}
}
unreachable!("if we get here, two uniform 63-bit samples were exactly equal")
Expand Down Expand Up @@ -1428,7 +1432,7 @@ mod tests {

let (src, mut dst) = buffer.write(&src_ty, &params, &mut rand::thread_rng());

jet.c_jet_ptr()(&mut dst, src, env.c_tx_env());
ElementsTxEnv::c_jet_ptr(&jet)(&mut dst, src, env.c_tx_env());
}

#[test]
Expand Down
Loading
Loading