From 1e3ffb44386e13d7c3ad342eee46c5b1b02e7239 Mon Sep 17 00:00:00 2001 From: mm Date: Fri, 17 May 2024 11:22:52 +0200 Subject: [PATCH 1/6] newest nightly without packed_simd --- Cargo.toml | 3 ++- rust-toolchain.toml | 2 +- src/implementations/poseidon2/state_generic_impl.rs | 4 ++-- src/lib.rs | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3d658ff..ec48bf8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ itertools = "0.10" blake2 = "0.10" sha2 = "0.10" num-modular = "0.5.1" -packed_simd = { version = "0.3.9" } +packed_simd = { version = "0.3.9" , optional = true} pairing = { package = "pairing_ce", git = "https://github.com/matter-labs/pairing.git" } crypto-bigint = "0.5" convert_case = "*" @@ -53,3 +53,4 @@ opt-level = 3 [features] log_tracing = ["tracing"] +optimized_impl = ["packed_simd"] \ No newline at end of file diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 6b48c00..a671fa6 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "nightly-2023-06-25" +channel = "nightly-2024-05-07" diff --git a/src/implementations/poseidon2/state_generic_impl.rs b/src/implementations/poseidon2/state_generic_impl.rs index 02cb079..5a53f58 100644 --- a/src/implementations/poseidon2/state_generic_impl.rs +++ b/src/implementations/poseidon2/state_generic_impl.rs @@ -29,8 +29,8 @@ 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; - pub const EPSILON_VECTOR: packed_simd::u64x4 = packed_simd::u64x4::splat(Self::EPSILON); - pub const EPSILON_VECTOR_D: packed_simd::u64x8 = packed_simd::u64x8::splat(Self::EPSILON); + //pub const EPSILON_VECTOR: packed_simd::u64x4 = packed_simd::u64x4::splat(Self::EPSILON); + //pub const EPSILON_VECTOR_D: packed_simd::u64x8 = packed_simd::u64x8::splat(Self::EPSILON); pub const RATE: usize = poseidon_goldilocks_params::RATE; pub const CAPACITY: usize = poseidon_goldilocks_params::CAPACITY; diff --git a/src/lib.rs b/src/lib.rs index 72775d5..12e0c3a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,7 +43,6 @@ #![feature(generic_const_exprs)] #![feature(iter_array_chunks)] // #![recursion_limit = "1024"] -#![feature(stdsimd)] #![feature(avx512_target_feature)] #![feature(associated_type_defaults)] #![feature(trait_alias)] @@ -51,6 +50,8 @@ #![feature(return_position_impl_trait_in_trait)] #![feature(type_changing_struct_update)] #![feature(slice_flatten)] +//#![cfg(feature = "optimized_impl")] +//#![feature(stdsimd)] pub mod algebraic_props; pub mod config; From 95c786c58fd2cca228b1df14ff9b1a91be3b9613 Mon Sep 17 00:00:00 2001 From: mm Date: Mon, 20 May 2024 09:40:42 +0200 Subject: [PATCH 2/6] added a feature include_packed_simd --- Cargo.toml | 3 ++- src/implementations/poseidon2/state_generic_impl.rs | 6 ++++-- src/lib.rs | 3 +-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ec48bf8..5385917 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,4 +53,5 @@ opt-level = 3 [features] log_tracing = ["tracing"] -optimized_impl = ["packed_simd"] \ No newline at end of file +# Currently packed_simd is no longer working with the newest nightly. +include_packed_simd = ["packed_simd"] \ No newline at end of file diff --git a/src/implementations/poseidon2/state_generic_impl.rs b/src/implementations/poseidon2/state_generic_impl.rs index 5a53f58..c9b74e8 100644 --- a/src/implementations/poseidon2/state_generic_impl.rs +++ b/src/implementations/poseidon2/state_generic_impl.rs @@ -29,8 +29,10 @@ 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; - //pub const EPSILON_VECTOR: packed_simd::u64x4 = packed_simd::u64x4::splat(Self::EPSILON); - //pub const EPSILON_VECTOR_D: packed_simd::u64x8 = packed_simd::u64x8::splat(Self::EPSILON); + #[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; pub const CAPACITY: usize = poseidon_goldilocks_params::CAPACITY; diff --git a/src/lib.rs b/src/lib.rs index 12e0c3a..c10e81c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,8 +50,7 @@ #![feature(return_position_impl_trait_in_trait)] #![feature(type_changing_struct_update)] #![feature(slice_flatten)] -//#![cfg(feature = "optimized_impl")] -//#![feature(stdsimd)] +#![cfg_attr(feature = "include_packed_simd", feature(stdsimd))] pub mod algebraic_props; pub mod config; From 05a3d79c4775d4e00a59f088fd2ea95d5e085b3f Mon Sep 17 00:00:00 2001 From: mm Date: Mon, 20 May 2024 10:14:01 +0200 Subject: [PATCH 3/6] cleanup warnings related to the new compiler --- Cargo.toml | 4 ++- src/cs/traits/cs.rs | 2 +- src/dag/guide.rs | 4 +-- src/dag/resolver_box.rs | 12 ++++++--- src/dag/resolvers/mt/mod.rs | 12 ++++----- src/dag/resolvers/mt/registrar.rs | 2 +- src/dag/resolvers/mt/resolution_window.rs | 28 ++++++++++----------- src/dag/resolvers/mt/sorters/sorter_live.rs | 14 +++++------ src/lib.rs | 3 +++ 9 files changed, 46 insertions(+), 35 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5385917..5e5b0e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,4 +54,6 @@ opt-level = 3 [features] log_tracing = ["tracing"] # Currently packed_simd is no longer working with the newest nightly. -include_packed_simd = ["packed_simd"] \ No newline at end of file +include_packed_simd = ["packed_simd"] +cr_paranoia_mode = [] +debug_track = [] \ No newline at end of file diff --git a/src/cs/traits/cs.rs b/src/cs/traits/cs.rs index da3b51d..5d4d786 100644 --- a/src/cs/traits/cs.rs +++ b/src/cs/traits/cs.rs @@ -20,7 +20,7 @@ impl<'set, 'tgt: 'set, T: SmallField> DstBuffer<'set, 'tgt, T> { *offset += 1; } DstBuffer::MutSliceIndirect(dst, debug_track, offset) => { - if cfg!(debug_track) && *debug_track { + if cfg!(feature = "debug_track") && *debug_track { log!(" set out {} <- {}", *offset, value.as_raw_u64()) } diff --git a/src/dag/guide.rs b/src/dag/guide.rs index 0eba95b..47a6315 100644 --- a/src/dag/guide.rs +++ b/src/dag/guide.rs @@ -384,7 +384,7 @@ impl<'a, T: Copy + Debug, F: SmallField, Cfg: CSResolverConfig> GuideOrder<'a, T pos += span.buffer.len(); } - if cfg!(cr_paranoia_mode) && self.guide.tracing { + if cfg!(feature = "cr_paranoia_mode") && self.guide.tracing { log!( "Released span {}: {:?}", self.guide.spans[0].id.0, @@ -684,7 +684,7 @@ impl BufferGuide { } pub(crate) fn flush(&mut self) -> BufferGuideFinalization<'_, T, F, Cfg> { - if cfg!(cr_paranoia_mode) && self.tracing { + if cfg!(feature = "cr_paranoia_mode") && self.tracing { log!("CRG: flush."); } diff --git a/src/dag/resolver_box.rs b/src/dag/resolver_box.rs index 397d551..d0f7dd8 100644 --- a/src/dag/resolver_box.rs +++ b/src/dag/resolver_box.rs @@ -424,7 +424,7 @@ pub(crate) fn invocation_binder( // Safety: This is the actual type of the provided function. let bound = resolver.resolve_fn::(); - if (cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA) && false { + if (cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA) && false { log!( "Ivk: Ins [{}], Out [{}], Out-addr [{}], Thread [{}]", resolver @@ -448,7 +448,10 @@ pub(crate) fn invocation_binder( ) } - if (cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA) && debug_track && false { + if (cfg!(feature = "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() @@ -457,7 +460,10 @@ pub(crate) fn invocation_binder( bound(ins, &mut DstBuffer::MutSliceIndirect(out, debug_track, 0)); - if (cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA) && debug_track && true { + if (cfg!(feature = "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() diff --git a/src/dag/resolvers/mt/mod.rs b/src/dag/resolvers/mt/mod.rs index cad5822..1cde660 100644 --- a/src/dag/resolvers/mt/mod.rs +++ b/src/dag/resolvers/mt/mod.rs @@ -169,7 +169,7 @@ impl, CFG: CSResolverConfig> let debug_track = vec![]; - if cfg!(cr_paranoia_mode) || PARANOIA { + if cfg!(feature="cr_paranoia_mode") || PARANOIA { log!("Contains tracked keys {:?} ", debug_track); } @@ -269,7 +269,7 @@ impl, CFG: CSResolverConfig> self.sorter.write_sequence(); - if cfg!(cr_paranoia_mode) || PARANOIA { + if cfg!(feature="cr_paranoia_mode") || PARANOIA { log!("CR {:?}", unsafe { self.common.awaiters_broker.stats.u_deref() }); @@ -1487,7 +1487,7 @@ mod test { storage.wait_till_resolved(); - if cfg!(cr_paranoia_mode) { + if cfg!(feature="cr_paranoia_mode") { log!("Test: total value result: \n - {}", unsafe { (*storage.common.values.get()) .variables @@ -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!(cr_paranoia_mode) { + if cfg!(feature="cr_paranoia_mode") { log!("Test: per item value: ix {}, value {}", ix, act); } @@ -1542,7 +1542,7 @@ mod test { storage.wait_till_resolved(); - if cfg!(cr_paranoia_mode) { + if cfg!(feature="cr_paranoia_mode") { log!("Test: total value result: \n - {}", unsafe { (*storage.common.values.get()) .variables @@ -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!(cr_paranoia_mode) { + if cfg!(feature="cr_paranoia_mode") { log!("Test: per item value: ix {}, value {}", ix, act); } diff --git a/src/dag/resolvers/mt/registrar.rs b/src/dag/resolvers/mt/registrar.rs index 3c43c6b..22551c5 100644 --- a/src/dag/resolvers/mt/registrar.rs +++ b/src/dag/resolvers/mt/registrar.rs @@ -116,7 +116,7 @@ impl Registrar { } pub(crate) fn is_empty(&self) -> bool { - if cfg!(cr_paranoia_mode) { + if cfg!(feature="cr_paranoia_mode") { log!( "CRR: total remaining resolvers: {}", self.vars.values().map(|x| x.len()).sum::() diff --git a/src/dag/resolvers/mt/resolution_window.rs b/src/dag/resolvers/mt/resolution_window.rs index 9efe2cb..213a21a 100644 --- a/src/dag/resolvers/mt/resolution_window.rs +++ b/src/dag/resolvers/mt/resolution_window.rs @@ -163,7 +163,7 @@ impl + 'static> comms, track_list: Vec::new(), - execution_list: if cfg!(cr_paranoia_mode) { 1 << 26 } else { 0 } + execution_list: if cfg!(feature="cr_paranoia_mode") { 1 << 26 } else { 0 } .to(|x| Vec::with_capacity(x).op(|v| v.resize(x, 0))), phantom: PhantomData, }; @@ -207,7 +207,7 @@ impl + 'static> data[data_ix].push(order_ix.into(), task.order_info.value); - if cfg!(cr_paranoia_mode) { + if cfg!(feature="cr_paranoia_mode") { self.execution_list[order_ix] += 1; if self.execution_list[order_ix] > 1 { @@ -238,7 +238,7 @@ impl + 'static> } } - if (cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA) && true { + if (cfg!(feature="cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA) && true { log!("RW: Batch! {} tasks.", count); } @@ -264,7 +264,7 @@ impl + 'static> .for_each(|x| { x.state = ResolverState::Done; - if cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA { + if cfg!(feature="cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA { unsafe { let r = self.common.resolvers.u_deref().get(x.order_info.value); @@ -291,7 +291,7 @@ impl + 'static> } }); - if cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA { + if cfg!(feature="cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA { if self .exec_order_buffer .iter() @@ -343,7 +343,7 @@ impl + 'static> drop(awaiters); - if cfg!(cr_paranoia_mode) && count > 0 { + if cfg!(feature="cr_paranoia_mode") && count > 0 { log!( "RW: Shifted by {}, new range is: {}..{}, buffer len: {}", count, @@ -412,7 +412,7 @@ impl + 'static> self.stats.total_consumption = extend_to as u64; - if crate::dag::resolvers::mt::PARANOIA || cfg!(cr_paranoia_mode) { + if crate::dag::resolvers::mt::PARANOIA || cfg!(feature="cr_paranoia_mode") { log!( "RW: Extended range by {}, new range {}..{}", extend_to, @@ -474,7 +474,7 @@ impl + 'static> } } - if crate::dag::resolvers::mt::PARANOIA || cfg!(cr_paranoia_mode) { + if crate::dag::resolvers::mt::PARANOIA || cfg!(feature="cr_paranoia_mode") { log!("[{:?}] RW: Exit conditions met.", std::time::Instant::now()) } @@ -484,7 +484,7 @@ impl + 'static> self.stats.total_time = start_instant.elapsed(); - if cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA { + if cfg!(feature="cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA { log!("CR {:#?}", self.stats); log!("CR {:#?}", unsafe { &*self.channel.stats.get() }); @@ -554,7 +554,7 @@ impl, const SIZE: usize> // here, as this is an unsynchronizd access. let resolver = this.common.resolvers.u_deref().get(*resolver_ix); - if cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA { + if cfg!(feature="cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA { std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { this.invoke(resolver, *order_ix); @@ -590,7 +590,7 @@ impl, const SIZE: usize> }); } - if cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA { + if cfg!(feature="cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA { log!( "{}\n{:#?}\n{:#?}", std::thread::current().name().unwrap_or_default(), @@ -629,7 +629,7 @@ impl, const SIZE: usize> .map(|x| { let (vs, md) = self.common.values.u_deref().get_item_ref(*x); - if cfg!(cr_paranoia_mode) || true { + if cfg!(feature="cr_paranoia_mode") || true { if Cfg::ASSERT_TRACKED_VALUES { assert!(md.is_tracked()); } @@ -678,7 +678,7 @@ impl, const SIZE: usize> let mut track = false; - if cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA { + if cfg!(feature="cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA { if let Some(x) = self .debug_track .iter() @@ -831,7 +831,7 @@ impl LockStepChannel { fn execute(&self) { use std::sync::atomic::Ordering::*; - if (cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA) && false { + if (cfg!(feature="cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA) && false { log!("RW: batch sent {:#?}", unsafe { self.data.u_deref() }); } diff --git a/src/dag/resolvers/mt/sorters/sorter_live.rs b/src/dag/resolvers/mt/sorters/sorter_live.rs index c0c1298..e61b0df 100644 --- a/src/dag/resolvers/mt/sorters/sorter_live.rs +++ b/src/dag/resolvers/mt/sorters/sorter_live.rs @@ -191,7 +191,7 @@ impl } } - if cfg!(cr_paranoia_mode) { + if cfg!(feature="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, @@ -297,7 +297,7 @@ impl ResolverS } fn set_value(&mut self, key: crate::cs::Place, value: F) { - if (cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA) + if (cfg!(feature="cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA) && self.debug_track.contains(&key) && false { @@ -378,7 +378,7 @@ impl ResolverS let mut hit = false; - if (cfg!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA) && true { + if (cfg!(feature="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); @@ -498,7 +498,7 @@ impl ResolverS outputs: &[Place], added_at: RegistrationNum, ) -> Vec { - if cfg!(cr_paranoia_mode) { + if cfg!(feature="cr_paranoia_mode") { if let Some(x) = self.debug_track.iter().find(|x| inputs.contains(x)) { log!("CR: internalized resolution with tracked input {:?}", x); } @@ -519,7 +519,7 @@ impl ResolverS let deps = inputs.iter().map(|x| &values.get_item_ref(*x).1); - if cfg!(cr_paranoia_mode) { + if cfg!(feature="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." @@ -610,14 +610,14 @@ impl 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!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA { + if cfg!(feature="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!(cr_paranoia_mode) || crate::dag::resolvers::mt::PARANOIA { + if cfg!(feature="cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA { self.guide.stats.finalize(); log!("CR {:?}", self.guide.stats); diff --git a/src/lib.rs b/src/lib.rs index c10e81c..4f2e1ee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,6 +21,9 @@ #![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)] From 3928af5d80087ec88d92cd7341a786bc889fc467 Mon Sep 17 00:00:00 2001 From: mm Date: Mon, 20 May 2024 10:15:18 +0200 Subject: [PATCH 4/6] fmt --- src/dag/resolvers/mt/mod.rs | 12 ++++---- src/dag/resolvers/mt/registrar.rs | 2 +- src/dag/resolvers/mt/resolution_window.rs | 32 ++++++++++++--------- src/dag/resolvers/mt/sorters/sorter_live.rs | 14 ++++----- 4 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/dag/resolvers/mt/mod.rs b/src/dag/resolvers/mt/mod.rs index 1cde660..8de30f5 100644 --- a/src/dag/resolvers/mt/mod.rs +++ b/src/dag/resolvers/mt/mod.rs @@ -169,7 +169,7 @@ impl, CFG: CSResolverConfig> let debug_track = vec![]; - if cfg!(feature="cr_paranoia_mode") || PARANOIA { + if cfg!(feature = "cr_paranoia_mode") || PARANOIA { log!("Contains tracked keys {:?} ", debug_track); } @@ -269,7 +269,7 @@ impl, CFG: CSResolverConfig> self.sorter.write_sequence(); - if cfg!(feature="cr_paranoia_mode") || PARANOIA { + if cfg!(feature = "cr_paranoia_mode") || PARANOIA { log!("CR {:?}", unsafe { self.common.awaiters_broker.stats.u_deref() }); @@ -1487,7 +1487,7 @@ mod test { storage.wait_till_resolved(); - if cfg!(feature="cr_paranoia_mode") { + if cfg!(feature = "cr_paranoia_mode") { log!("Test: total value result: \n - {}", unsafe { (*storage.common.values.get()) .variables @@ -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!(feature = "cr_paranoia_mode") { log!("Test: per item value: ix {}, value {}", ix, act); } @@ -1542,7 +1542,7 @@ mod test { storage.wait_till_resolved(); - if cfg!(feature="cr_paranoia_mode") { + if cfg!(feature = "cr_paranoia_mode") { log!("Test: total value result: \n - {}", unsafe { (*storage.common.values.get()) .variables @@ -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!(feature = "cr_paranoia_mode") { log!("Test: per item value: ix {}, value {}", ix, act); } diff --git a/src/dag/resolvers/mt/registrar.rs b/src/dag/resolvers/mt/registrar.rs index 22551c5..257703f 100644 --- a/src/dag/resolvers/mt/registrar.rs +++ b/src/dag/resolvers/mt/registrar.rs @@ -116,7 +116,7 @@ impl Registrar { } pub(crate) fn is_empty(&self) -> bool { - if cfg!(feature="cr_paranoia_mode") { + if cfg!(feature = "cr_paranoia_mode") { log!( "CRR: total remaining resolvers: {}", self.vars.values().map(|x| x.len()).sum::() diff --git a/src/dag/resolvers/mt/resolution_window.rs b/src/dag/resolvers/mt/resolution_window.rs index 213a21a..60d1d23 100644 --- a/src/dag/resolvers/mt/resolution_window.rs +++ b/src/dag/resolvers/mt/resolution_window.rs @@ -163,8 +163,12 @@ impl + '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!(feature = "cr_paranoia_mode") { + 1 << 26 + } else { + 0 + } + .to(|x| Vec::with_capacity(x).op(|v| v.resize(x, 0))), phantom: PhantomData, }; @@ -207,7 +211,7 @@ impl + 'static> data[data_ix].push(order_ix.into(), task.order_info.value); - if cfg!(feature="cr_paranoia_mode") { + if cfg!(feature = "cr_paranoia_mode") { self.execution_list[order_ix] += 1; if self.execution_list[order_ix] > 1 { @@ -238,7 +242,7 @@ impl + 'static> } } - if (cfg!(feature="cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA) && true { + if (cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA) && true { log!("RW: Batch! {} tasks.", count); } @@ -264,7 +268,7 @@ impl + 'static> .for_each(|x| { x.state = ResolverState::Done; - if cfg!(feature="cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA { + if cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA { unsafe { let r = self.common.resolvers.u_deref().get(x.order_info.value); @@ -291,7 +295,7 @@ impl + 'static> } }); - if cfg!(feature="cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA { + if cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA { if self .exec_order_buffer .iter() @@ -343,7 +347,7 @@ impl + 'static> drop(awaiters); - if cfg!(feature="cr_paranoia_mode") && count > 0 { + if cfg!(feature = "cr_paranoia_mode") && count > 0 { log!( "RW: Shifted by {}, new range is: {}..{}, buffer len: {}", count, @@ -412,7 +416,7 @@ impl + '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!(feature = "cr_paranoia_mode") { log!( "RW: Extended range by {}, new range {}..{}", extend_to, @@ -474,7 +478,7 @@ impl + 'static> } } - if crate::dag::resolvers::mt::PARANOIA || cfg!(feature="cr_paranoia_mode") { + if crate::dag::resolvers::mt::PARANOIA || cfg!(feature = "cr_paranoia_mode") { log!("[{:?}] RW: Exit conditions met.", std::time::Instant::now()) } @@ -484,7 +488,7 @@ impl + 'static> self.stats.total_time = start_instant.elapsed(); - if cfg!(feature="cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA { + if cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA { log!("CR {:#?}", self.stats); log!("CR {:#?}", unsafe { &*self.channel.stats.get() }); @@ -590,7 +594,7 @@ impl, const SIZE: usize> }); } - if cfg!(feature="cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA { + if cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA { log!( "{}\n{:#?}\n{:#?}", std::thread::current().name().unwrap_or_default(), @@ -629,7 +633,7 @@ impl, 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!(feature = "cr_paranoia_mode") || true { if Cfg::ASSERT_TRACKED_VALUES { assert!(md.is_tracked()); } @@ -678,7 +682,7 @@ impl, const SIZE: usize> let mut track = false; - if cfg!(feature="cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA { + if cfg!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA { if let Some(x) = self .debug_track .iter() @@ -831,7 +835,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!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA) && false { log!("RW: batch sent {:#?}", unsafe { self.data.u_deref() }); } diff --git a/src/dag/resolvers/mt/sorters/sorter_live.rs b/src/dag/resolvers/mt/sorters/sorter_live.rs index e61b0df..6b1e423 100644 --- a/src/dag/resolvers/mt/sorters/sorter_live.rs +++ b/src/dag/resolvers/mt/sorters/sorter_live.rs @@ -191,7 +191,7 @@ impl } } - if cfg!(feature="cr_paranoia_mode") { + if cfg!(feature = "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, @@ -297,7 +297,7 @@ impl 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!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA) && self.debug_track.contains(&key) && false { @@ -378,7 +378,7 @@ impl ResolverS let mut hit = false; - if (cfg!(feature="cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA) && true { + if (cfg!(feature = "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); @@ -498,7 +498,7 @@ impl ResolverS outputs: &[Place], added_at: RegistrationNum, ) -> Vec { - if cfg!(feature="cr_paranoia_mode") { + if cfg!(feature = "cr_paranoia_mode") { if let Some(x) = self.debug_track.iter().find(|x| inputs.contains(x)) { log!("CR: internalized resolution with tracked input {:?}", x); } @@ -519,7 +519,7 @@ impl ResolverS let deps = inputs.iter().map(|x| &values.get_item_ref(*x).1); - if cfg!(feature="cr_paranoia_mode") { + if cfg!(feature = "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." @@ -610,14 +610,14 @@ impl 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!(feature = "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!(feature = "cr_paranoia_mode") || crate::dag::resolvers::mt::PARANOIA { self.guide.stats.finalize(); log!("CR {:?}", self.guide.stats); From 98923742a6f178fbdab9847bffe463991e104810 Mon Sep 17 00:00:00 2001 From: mm Date: Tue, 21 May 2024 10:25:09 +0200 Subject: [PATCH 5/6] changed toolchain to nightly --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index a671fa6..5d56faf 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "nightly-2024-05-07" +channel = "nightly" From 0b6eaa09170b37c7d78321af781da89df305a4a6 Mon Sep 17 00:00:00 2001 From: mm Date: Tue, 21 May 2024 16:33:04 +0200 Subject: [PATCH 6/6] Revert "changed toolchain to nightly" This reverts commit 98923742a6f178fbdab9847bffe463991e104810. --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5d56faf..a671fa6 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "nightly" +channel = "nightly-2024-05-07"