From 3bb18fee072cd88eedc9f4bce2c08f5106a09657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20G=C3=B6rgens?= Date: Thu, 12 Dec 2024 12:34:55 +0800 Subject: [PATCH] Remove broken features `non_pow2_rayon_thread` and `riv64` (#723) Features `non_pow2_rayon_thread` and `riv64` are not tested: we can't even compile with them. Because `riv64` is gone, we can make `riv32` invisible: it's effects are now just the default. --- Makefile.toml | 4 --- ceno_zkvm/Cargo.toml | 5 +-- ceno_zkvm/src/instructions/riscv/constants.rs | 4 +-- sumcheck/Cargo.toml | 3 -- sumcheck/src/lib.rs | 2 -- sumcheck/src/local_thread_pool.rs | 32 ------------------- sumcheck/src/prover.rs | 27 +++------------- sumcheck/src/prover_v2.rs | 28 +++------------- 8 files changed, 12 insertions(+), 93 deletions(-) delete mode 100644 sumcheck/src/local_thread_pool.rs diff --git a/Makefile.toml b/Makefile.toml index 8d6ab5edf..a62827fcc 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -11,10 +11,6 @@ CUR_TARGET = { script = [''' '''] } RAYON_NUM_THREADS = "${CORE}" -[tasks.build] -# Override the default `--all-features`, that's broken, because some of our features are mutually exclusive. -args = ["build"] - [tasks.tests] args = [ "test", diff --git a/ceno_zkvm/Cargo.toml b/ceno_zkvm/Cargo.toml index 4bb427eb9..f3217a3bc 100644 --- a/ceno_zkvm/Cargo.toml +++ b/ceno_zkvm/Cargo.toml @@ -52,12 +52,9 @@ pprof2.workspace = true glob = "0.3" [features] -default = ["riv32", "forbid_overflow"] +default = ["forbid_overflow"] flamegraph = ["pprof2/flamegraph", "pprof2/criterion"] forbid_overflow = [] -non_pow2_rayon_thread = [] -riv32 = [] -riv64 = [] [[bench]] harness = false diff --git a/ceno_zkvm/src/instructions/riscv/constants.rs b/ceno_zkvm/src/instructions/riscv/constants.rs index fb3858ddc..b604f7c92 100644 --- a/ceno_zkvm/src/instructions/riscv/constants.rs +++ b/ceno_zkvm/src/instructions/riscv/constants.rs @@ -14,10 +14,8 @@ pub const PUBLIC_IO_IDX: usize = 6; pub const LIMB_BITS: usize = 16; pub const LIMB_MASK: u32 = 0xFFFF; -#[cfg(feature = "riv32")] pub const BIT_WIDTH: usize = 32usize; -#[cfg(feature = "riv64")] -pub const BIT_WIDTH: usize = 64usize; + pub type UInt = UIntLimbs; pub type UIntMul = UIntLimbs<{ 2 * BIT_WIDTH }, LIMB_BITS, E>; /// use UInt for x bits limb size diff --git a/sumcheck/Cargo.toml b/sumcheck/Cargo.toml index 092187cba..5d747be06 100644 --- a/sumcheck/Cargo.toml +++ b/sumcheck/Cargo.toml @@ -29,6 +29,3 @@ criterion.workspace = true [[bench]] harness = false name = "devirgo_sumcheck" - -[features] -non_pow2_rayon_thread = [] diff --git a/sumcheck/src/lib.rs b/sumcheck/src/lib.rs index 09d916e21..4578b7ec2 100644 --- a/sumcheck/src/lib.rs +++ b/sumcheck/src/lib.rs @@ -1,7 +1,5 @@ #![deny(clippy::cargo)] #![feature(decl_macro)] -#[cfg(feature = "non_pow2_rayon_thread")] -pub mod local_thread_pool; pub mod macros; mod prover; mod prover_v2; diff --git a/sumcheck/src/local_thread_pool.rs b/sumcheck/src/local_thread_pool.rs deleted file mode 100644 index 8df2f620e..000000000 --- a/sumcheck/src/local_thread_pool.rs +++ /dev/null @@ -1,32 +0,0 @@ -use std::sync::{Arc, Once}; - -use rayon::ThreadPool; - -pub(crate) static mut LOCAL_THREAD_POOL: Option> = None; -static LOCAL_THREAD_POOL_SET: Once = Once::new(); - -pub fn create_local_pool_once(size: usize, in_place: bool) { - unsafe { - let size = if in_place { size - 1 } else { size }; - let pool_size = LOCAL_THREAD_POOL - .as_ref() - .map(|a| a.current_num_threads()) - .unwrap_or(0); - if pool_size > 0 && pool_size != size { - panic!( - "calling prove_batch_polys with different polys size. prev size {} vs now size {}", - pool_size, size - ); - } - LOCAL_THREAD_POOL_SET.call_once(|| { - let _ = Some(&*LOCAL_THREAD_POOL.get_or_insert_with(|| { - Arc::new( - rayon::ThreadPoolBuilder::new() - .num_threads(size) - .build() - .unwrap(), - ) - })); - }); - } -} diff --git a/sumcheck/src/prover.rs b/sumcheck/src/prover.rs index 7cee2169b..0dc5de870 100644 --- a/sumcheck/src/prover.rs +++ b/sumcheck/src/prover.rs @@ -12,9 +12,6 @@ use rayon::{ }; use transcript::{Challenge, Transcript, TranscriptSyncronized}; -#[cfg(feature = "non_pow2_rayon_thread")] -use crate::local_thread_pool::{LOCAL_THREAD_POOL, create_local_pool_once}; - use crate::{ macros::{entered_span, exit_span}, structs::{IOPProof, IOPProverMessage, IOPProverState}, @@ -119,25 +116,11 @@ impl IOPProverState { if rayon::current_num_threads() >= max_thread_id { rayon::spawn(spawn_task); } else { - #[cfg(not(feature = "non_pow2_rayon_thread"))] - { - panic!( - "rayon global thread pool size {} mismatch with desired poly size {}, add --features non_pow2_rayon_thread", - rayon::current_num_threads(), - polys.len() - ); - } - - #[cfg(feature = "non_pow2_rayon_thread")] - unsafe { - create_local_pool_once(max_thread_id, true); - - if let Some(pool) = LOCAL_THREAD_POOL.as_ref() { - pool.spawn(spawn_task) - } else { - panic!("empty local pool") - } - } + panic!( + "rayon global thread pool size {} mismatch with desired poly size {}.", + rayon::current_num_threads(), + polys.len() + ); } } diff --git a/sumcheck/src/prover_v2.rs b/sumcheck/src/prover_v2.rs index 3dae3a101..b4021b77d 100644 --- a/sumcheck/src/prover_v2.rs +++ b/sumcheck/src/prover_v2.rs @@ -18,9 +18,6 @@ use rayon::{ }; use transcript::{Challenge, Transcript, TranscriptSyncronized}; -#[cfg(feature = "non_pow2_rayon_thread")] -use crate::local_thread_pool::{LOCAL_THREAD_POOL, create_local_pool_once}; - use crate::{ macros::{entered_span, exit_span}, structs::{IOPProof, IOPProverMessage, IOPProverStateV2}, @@ -235,26 +232,11 @@ impl<'a, E: ExtensionField> IOPProverStateV2<'a, E> { { rayon::in_place_scope(scoped_fn) } else { - #[cfg(not(feature = "non_pow2_rayon_thread"))] - { - panic!( - "rayon global thread pool size {} mismatch with desired poly size {}, add - --features non_pow2_rayon_thread", - rayon::current_num_threads(), - polys.len() - ); - } - - #[cfg(feature = "non_pow2_rayon_thread")] - unsafe { - create_local_pool_once(max_thread_id, true); - - if let Some(pool) = LOCAL_THREAD_POOL.as_ref() { - pool.scope(scoped_fn) - } else { - panic!("empty local pool") - } - } + panic!( + "rayon global thread pool size {} mismatch with desired poly size {}.", + rayon::current_num_threads(), + polys.len() + ); }; if log2_max_thread_id == 0 {