Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Commit

Permalink
Revert "feat: Update boojum nightly - feature gate packed_simd (#46)"
Browse files Browse the repository at this point in the history
This reverts commit e3a59d5.
  • Loading branch information
mm-zk committed May 22, 2024
1 parent e3a59d5 commit bd424ce
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 57 deletions.
6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ itertools = "0.10"
blake2 = "0.10"
sha2 = "0.10"
num-modular = "0.5.1"
packed_simd = { version = "0.3.9" , optional = true}
packed_simd = { version = "0.3.9" }
pairing = { package = "pairing_ce", git = "https://github.com/matter-labs/pairing.git" }
crypto-bigint = "0.5"
convert_case = "*"
Expand Down Expand Up @@ -53,7 +53,3 @@ opt-level = 3

[features]
log_tracing = ["tracing"]
# Currently packed_simd is no longer working with the newest nightly.
include_packed_simd = ["packed_simd"]
cr_paranoia_mode = []
debug_track = []
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "nightly-2024-05-07"
channel = "nightly-2023-06-25"
2 changes: 1 addition & 1 deletion src/cs/traits/cs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl<'set, 'tgt: 'set, T: SmallField> DstBuffer<'set, 'tgt, T> {
*offset += 1;
}
DstBuffer::MutSliceIndirect(dst, debug_track, offset) => {
if cfg!(feature = "debug_track") && *debug_track {
if cfg!(debug_track) && *debug_track {
log!(" set out {} <- {}", *offset, value.as_raw_u64())
}

Expand Down
4 changes: 2 additions & 2 deletions src/dag/guide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ impl<'a, T: Copy + Debug, F: SmallField, Cfg: CSResolverConfig> GuideOrder<'a, T
pos += span.buffer.len();
}

if cfg!(feature = "cr_paranoia_mode") && self.guide.tracing {
if cfg!(cr_paranoia_mode) && self.guide.tracing {
log!(
"Released span {}: {:?}",
self.guide.spans[0].id.0,
Expand Down Expand Up @@ -684,7 +684,7 @@ impl<T: Debug, F: SmallField, Cfg: CSResolverConfig> BufferGuide<T, F, Cfg> {
}

pub(crate) fn flush(&mut self) -> BufferGuideFinalization<'_, T, F, Cfg> {
if cfg!(feature = "cr_paranoia_mode") && self.tracing {
if cfg!(cr_paranoia_mode) && self.tracing {
log!("CRG: flush.");
}

Expand Down
12 changes: 3 additions & 9 deletions src/dag/resolver_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ pub(crate) fn invocation_binder<Fn, F: SmallField>(
// Safety: This is the actual type of the provided function.
let bound = resolver.resolve_fn::<Fn>();

if (cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA) && false {
if (cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA) && false {
log!(
"Ivk: Ins [{}], Out [{}], Out-addr [{}], Thread [{}]",
resolver
Expand All @@ -448,10 +448,7 @@ pub(crate) fn invocation_binder<Fn, F: SmallField>(
)
}

if (cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA)
&& debug_track
&& false
{
if (cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA) && debug_track && false {
log!(
"Ivk: provided inputs:\n - {:?}",
ins.iter().map(|x| x.as_raw_u64()).collect_vec()
Expand All @@ -460,10 +457,7 @@ pub(crate) fn invocation_binder<Fn, F: SmallField>(

bound(ins, &mut DstBuffer::MutSliceIndirect(out, debug_track, 0));

if (cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA)
&& debug_track
&& true
{
if (cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA) && debug_track && true {
log!(
"Ivk: calculated outputs:\n - {:?}",
out.iter().map(|x| x.as_raw_u64()).collect_vec()
Expand Down
12 changes: 6 additions & 6 deletions src/dag/resolvers/mt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl<V: SmallField, RS: ResolverSortingMode<V>, CFG: CSResolverConfig>

let debug_track = vec![];

if cfg!(feature = "cr_paranoia_mode") || PARANOIA {
if cfg!(cr_paranoia_mode) || PARANOIA {
log!("Contains tracked keys {:?} ", debug_track);
}

Expand Down Expand Up @@ -269,7 +269,7 @@ impl<V: SmallField, RS: ResolverSortingMode<V>, CFG: CSResolverConfig>

self.sorter.write_sequence();

if cfg!(feature = "cr_paranoia_mode") || PARANOIA {
if cfg!(cr_paranoia_mode) || PARANOIA {
log!("CR {:?}", unsafe {
self.common.awaiters_broker.stats.u_deref()
});
Expand Down Expand Up @@ -1487,7 +1487,7 @@ mod test {

storage.wait_till_resolved();

if cfg!(feature = "cr_paranoia_mode") {
if cfg!(cr_paranoia_mode) {
log!("Test: total value result: \n - {}", unsafe {
(*storage.common.values.get())
.variables
Expand All @@ -1509,7 +1509,7 @@ mod test {
let act = Place::from_variable(Variable::from_variable_index(ix as u64))
.to(|x| storage.get_value_unchecked(x));

if cfg!(feature = "cr_paranoia_mode") {
if cfg!(cr_paranoia_mode) {
log!("Test: per item value: ix {}, value {}", ix, act);
}

Expand Down Expand Up @@ -1542,7 +1542,7 @@ mod test {

storage.wait_till_resolved();

if cfg!(feature = "cr_paranoia_mode") {
if cfg!(cr_paranoia_mode) {
log!("Test: total value result: \n - {}", unsafe {
(*storage.common.values.get())
.variables
Expand All @@ -1564,7 +1564,7 @@ mod test {
let act = Place::from_variable(Variable::from_variable_index(ix as u64))
.to(|x| storage.get_value_unchecked(x));

if cfg!(feature = "cr_paranoia_mode") {
if cfg!(cr_paranoia_mode) {
log!("Test: per item value: ix {}, value {}", ix, act);
}

Expand Down
2 changes: 1 addition & 1 deletion src/dag/resolvers/mt/registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl Registrar {
}

pub(crate) fn is_empty(&self) -> bool {
if cfg!(feature = "cr_paranoia_mode") {
if cfg!(cr_paranoia_mode) {
log!(
"CRR: total remaining resolvers: {}",
self.vars.values().map(|x| x.len()).sum::<usize>()
Expand Down
34 changes: 15 additions & 19 deletions src/dag/resolvers/mt/resolution_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,8 @@ impl<V: SmallField + 'static, T: TrackId + 'static, Cfg: RWConfig<T> + 'static>
comms,

track_list: Vec::new(),
execution_list: if cfg!(feature = "cr_paranoia_mode") {
1 << 26
} else {
0
}
.to(|x| Vec::with_capacity(x).op(|v| v.resize(x, 0))),
execution_list: if cfg!(cr_paranoia_mode) { 1 << 26 } else { 0 }
.to(|x| Vec::with_capacity(x).op(|v| v.resize(x, 0))),
phantom: PhantomData,
};

Expand Down Expand Up @@ -211,7 +207,7 @@ impl<V: SmallField + 'static, T: TrackId + 'static, Cfg: RWConfig<T> + 'static>

data[data_ix].push(order_ix.into(), task.order_info.value);

if cfg!(feature = "cr_paranoia_mode") {
if cfg!(cr_paranoia_mode) {
self.execution_list[order_ix] += 1;

if self.execution_list[order_ix] > 1 {
Expand Down Expand Up @@ -242,7 +238,7 @@ impl<V: SmallField + 'static, T: TrackId + 'static, Cfg: RWConfig<T> + 'static>
}
}

if (cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA) && true {
if (cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA) && true {
log!("RW: Batch! {} tasks.", count);
}

Expand All @@ -268,7 +264,7 @@ impl<V: SmallField + 'static, T: TrackId + 'static, Cfg: RWConfig<T> + 'static>
.for_each(|x| {
x.state = ResolverState::Done;

if cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA {
if cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA {
unsafe {
let r = self.common.resolvers.u_deref().get(x.order_info.value);

Expand All @@ -295,7 +291,7 @@ impl<V: SmallField + 'static, T: TrackId + 'static, Cfg: RWConfig<T> + 'static>
}
});

if cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA {
if cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA {
if self
.exec_order_buffer
.iter()
Expand Down Expand Up @@ -347,7 +343,7 @@ impl<V: SmallField + 'static, T: TrackId + 'static, Cfg: RWConfig<T> + 'static>

drop(awaiters);

if cfg!(feature = "cr_paranoia_mode") && count > 0 {
if cfg!(cr_paranoia_mode) && count > 0 {
log!(
"RW: Shifted by {}, new range is: {}..{}, buffer len: {}",
count,
Expand Down Expand Up @@ -416,7 +412,7 @@ impl<V: SmallField + 'static, T: TrackId + 'static, Cfg: RWConfig<T> + 'static>

self.stats.total_consumption = extend_to as u64;

if crate::dag::resolvers::mt::PARANOIA || cfg!(feature = "cr_paranoia_mode") {
if crate::dag::resolvers::mt::PARANOIA || cfg!(cr_paranoia_mode) {
log!(
"RW: Extended range by {}, new range {}..{}",
extend_to,
Expand Down Expand Up @@ -478,7 +474,7 @@ impl<V: SmallField + 'static, T: TrackId + 'static, Cfg: RWConfig<T> + 'static>
}
}

if crate::dag::resolvers::mt::PARANOIA || cfg!(feature = "cr_paranoia_mode") {
if crate::dag::resolvers::mt::PARANOIA || cfg!(cr_paranoia_mode) {
log!("[{:?}] RW: Exit conditions met.", std::time::Instant::now())
}

Expand All @@ -488,7 +484,7 @@ impl<V: SmallField + 'static, T: TrackId + 'static, Cfg: RWConfig<T> + 'static>

self.stats.total_time = start_instant.elapsed();

if cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA {
if cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA {
log!("CR {:#?}", self.stats);
log!("CR {:#?}", unsafe { &*self.channel.stats.get() });

Expand Down Expand Up @@ -558,7 +554,7 @@ impl<V: SmallField, T: TrackId + 'static, Cfg: RWConfig<T>, const SIZE: usize>
// here, as this is an unsynchronizd access.
let resolver = this.common.resolvers.u_deref().get(*resolver_ix);

if cfg!(feature="cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA {
if cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA {
std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
this.invoke(resolver, *order_ix);

Expand Down Expand Up @@ -594,7 +590,7 @@ impl<V: SmallField, T: TrackId + 'static, Cfg: RWConfig<T>, const SIZE: usize>
});
}

if cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA {
if cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA {
log!(
"{}\n{:#?}\n{:#?}",
std::thread::current().name().unwrap_or_default(),
Expand Down Expand Up @@ -633,7 +629,7 @@ impl<V: SmallField, T: TrackId + 'static, Cfg: RWConfig<T>, const SIZE: usize>
.map(|x| {
let (vs, md) = self.common.values.u_deref().get_item_ref(*x);

if cfg!(feature = "cr_paranoia_mode") || true {
if cfg!(cr_paranoia_mode) || true {
if Cfg::ASSERT_TRACKED_VALUES {
assert!(md.is_tracked());
}
Expand Down Expand Up @@ -682,7 +678,7 @@ impl<V: SmallField, T: TrackId + 'static, Cfg: RWConfig<T>, const SIZE: usize>

let mut track = false;

if cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA {
if cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA {
if let Some(x) = self
.debug_track
.iter()
Expand Down Expand Up @@ -835,7 +831,7 @@ impl LockStepChannel {
fn execute(&self) {
use std::sync::atomic::Ordering::*;

if (cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA) && false {
if (cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA) && false {
log!("RW: batch sent {:#?}", unsafe { self.data.u_deref() });
}

Expand Down
14 changes: 7 additions & 7 deletions src/dag/resolvers/mt/sorters/sorter_live.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<F: SmallField, Cfg: CSResolverConfig, RW: ResolutionRecordWriter>
}
}

if cfg!(feature = "cr_paranoia_mode") {
if cfg!(cr_paranoia_mode) {
// This ugly block checks that the calculated parallelism is
// correct. It's a bit slower than O(n^2). Also note, that it
// checks only the last 1050 items, so it's not a full check,
Expand Down Expand Up @@ -297,7 +297,7 @@ impl<F: SmallField, Cfg: CSResolverConfig, RW: ResolutionRecordWriter> ResolverS
}

fn set_value(&mut self, key: crate::cs::Place, value: F) {
if (cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA)
if (cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA)
&& self.debug_track.contains(&key)
&& false
{
Expand Down Expand Up @@ -378,7 +378,7 @@ impl<F: SmallField, Cfg: CSResolverConfig, RW: ResolutionRecordWriter> ResolverS

let mut hit = false;

if (cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA) && true {
if (cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA) && true {
if let Some(x) = self.debug_track.iter().find(|x| inputs.contains(x)) {
log!("CR: added resolution with tracked input {:?}", x);

Expand Down Expand Up @@ -498,7 +498,7 @@ impl<F: SmallField, Cfg: CSResolverConfig, RW: ResolutionRecordWriter> ResolverS
outputs: &[Place],
added_at: RegistrationNum,
) -> Vec<ResolverIx> {
if cfg!(feature = "cr_paranoia_mode") {
if cfg!(cr_paranoia_mode) {
if let Some(x) = self.debug_track.iter().find(|x| inputs.contains(x)) {
log!("CR: internalized resolution with tracked input {:?}", x);
}
Expand All @@ -519,7 +519,7 @@ impl<F: SmallField, Cfg: CSResolverConfig, RW: ResolutionRecordWriter> ResolverS

let deps = inputs.iter().map(|x| &values.get_item_ref(*x).1);

if cfg!(feature = "cr_paranoia_mode") {
if cfg!(cr_paranoia_mode) {
debug_assert!(
deps.clone().all(|x| { x.is_tracked() }),
"Attempting to internalize a resolution with an untracked input. All inputs must be tracked."
Expand Down Expand Up @@ -610,14 +610,14 @@ impl<F: SmallField, Cfg: CSResolverConfig, RW: ResolutionRecordWriter> ResolverS
self.record.values_count = unsafe { self.common.values.u_deref().max_tracked + 1 } as usize;
self.record.registrations_count = self.stats.registrations_added as usize;

if cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA {
if cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA {
log!(
"CR: Final order written. Order len {}",
self.common.exec_order.lock().unwrap().items.len()
);
}

if cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA {
if cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA {
self.guide.stats.finalize();

log!("CR {:?}", self.guide.stats);
Expand Down
2 changes: 0 additions & 2 deletions src/implementations/poseidon2/state_generic_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ impl State {
pub const T: u64 = (Self::ORDER - 1) >> Self::TWO_ADICITY;
pub const BARRETT: u128 = 18446744078004518912; // 0x10000000100000000
pub const EPSILON: u64 = (1 << 32) - 1;
#[cfg(feature = "include_packed_simd")]
pub const EPSILON_VECTOR: packed_simd::u64x4 = packed_simd::u64x4::splat(Self::EPSILON);
#[cfg(feature = "include_packed_simd")]
pub const EPSILON_VECTOR_D: packed_simd::u64x8 = packed_simd::u64x8::splat(Self::EPSILON);

pub const RATE: usize = poseidon_goldilocks_params::RATE;
Expand Down
5 changes: 1 addition & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
#![allow(dead_code)]
#![allow(dropping_references)] // Required to explicitly show that mutable references are dropped.
#![allow(incomplete_features)]
#![allow(internal_features)] // Required for core_intrinsics
#![allow(stable_features)]
#![allow(unused_unsafe)]
// Enabled features
#![feature(allocator_api)]
#![feature(const_mut_refs)]
Expand All @@ -46,14 +43,14 @@
#![feature(generic_const_exprs)]
#![feature(iter_array_chunks)]
// #![recursion_limit = "1024"]
#![feature(stdsimd)]
#![feature(avx512_target_feature)]
#![feature(associated_type_defaults)]
#![feature(trait_alias)]
#![feature(vec_push_within_capacity)]
#![feature(return_position_impl_trait_in_trait)]
#![feature(type_changing_struct_update)]
#![feature(slice_flatten)]
#![cfg_attr(feature = "include_packed_simd", feature(stdsimd))]

pub mod algebraic_props;
pub mod config;
Expand Down

0 comments on commit bd424ce

Please sign in to comment.