diff --git a/Cargo.lock b/Cargo.lock index 61b68c2a..ef1ca195 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "adler" @@ -10,9 +10,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.7" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ "cfg-if", "once_cell", @@ -31,9 +31,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "anes" @@ -467,9 +467,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", "allocator-api2", @@ -594,6 +594,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf4e226dcd58b4be396f7bd3c20da8fdee2911400705297ba7d2d7cc2c30f716" dependencies = [ + "cc", "pkg-config", "vcpkg", ] @@ -1440,9 +1441,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vtkio" @@ -1734,18 +1735,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" dependencies = [ "proc-macro2", "quote", diff --git a/benches/rcb_cartesian.rs b/benches/rcb_cartesian.rs index 00d345f6..85bd28dd 100644 --- a/benches/rcb_cartesian.rs +++ b/benches/rcb_cartesian.rs @@ -37,7 +37,7 @@ pub fn bench(c: &mut Criterion) { }) .build() .unwrap(); - group.bench_function(&thread_count.to_string(), |b| { + group.bench_function(thread_count.to_string(), |b| { pool.install(|| { b.iter(|| grid.rcb(black_box(&mut partition), black_box(&weights), 12)) }); diff --git a/ffi/src/data.rs b/ffi/src/data.rs index 289165c8..b7b3b0fb 100644 --- a/ffi/src/data.rs +++ b/ffi/src/data.rs @@ -38,7 +38,7 @@ impl Constant { Ok(v) } - pub unsafe fn iter<'a, T>(&'a self) -> impl Iterator + ExactSizeIterator + 'a + pub unsafe fn iter<'a, T>(&'a self) -> impl ExactSizeIterator + 'a where T: 'a + Copy, { @@ -73,7 +73,7 @@ impl Array { slice::from_raw_parts(self.array as *const T, self.len) } - pub unsafe fn iter<'a, T>(&'a self) -> impl Iterator + ExactSizeIterator + 'a + pub unsafe fn iter<'a, T>(&'a self) -> impl ExactSizeIterator + 'a where T: 'a + Copy, { @@ -117,7 +117,7 @@ impl Fn { Ok(v) } - pub unsafe fn iter<'a, T>(&'a self) -> impl Iterator + ExactSizeIterator + 'a + pub unsafe fn iter<'a, T>(&'a self) -> impl ExactSizeIterator + 'a where T: 'a + Copy, { diff --git a/src/algorithms/graph_growth.rs b/src/algorithms/graph_growth.rs index 483c11ce..f3bc5a48 100644 --- a/src/algorithms/graph_growth.rs +++ b/src/algorithms/graph_growth.rs @@ -118,7 +118,7 @@ pub struct GraphGrowth { pub part_count: usize, } -impl<'a, W> crate::Partition<(CsMatView<'a, f64>, W)> for GraphGrowth +impl crate::Partition<(CsMatView<'_, f64>, W)> for GraphGrowth where W: AsRef<[f64]>, { diff --git a/src/algorithms/hilbert_curve.rs b/src/algorithms/hilbert_curve.rs index b6b749bf..f33d9dcb 100644 --- a/src/algorithms/hilbert_curve.rs +++ b/src/algorithms/hilbert_curve.rs @@ -331,7 +331,7 @@ fn encode_2d(x: u64, y: u64, order: usize) -> u64 { order, ); - const LUT: [u16; 16_384] = { + static LUT: [u16; 16_384] = { let mut lut = [0; 16_384]; let mut i: usize = 0; while i < 16_384 { diff --git a/src/algorithms/k_means.rs b/src/algorithms/k_means.rs index ba8b044b..8e56a504 100644 --- a/src/algorithms/k_means.rs +++ b/src/algorithms/k_means.rs @@ -45,10 +45,8 @@ fn imbalance(weights: &[f64]) -> f64 { /// - `imbalance_tol`: the relative imbalance tolerance of the generated partitions, in `%` of the target weight of each partition. /// - `delta_threshold`: the distance threshold for the cluster movements under which the algorithm stops. /// - `max_iter`: the maximum number of times each cluster will move before stopping the algorithm -/// - `max_balance_iter`: the maximum number of iterations of the load balancing loop. It will limit how much each cluster -/// influence can grow between each cluster movement. +/// - `max_balance_iter`: the maximum number of iterations of the load balancing loop. It will limit how much each cluster influence can grow between each cluster movement. /// - `erode`: sets whether or not cluster influence is modified according to errosion's rules between each cluster movement -/// - `hilbert`: sets wheter or not an Hilbert curve is used to create the initial partition. If false, a Z curve is used instead. /// - `mbr_early_break`: sets whether or not bounding box optimization is enabled. #[derive(Debug, Clone, Copy)] pub struct BalancedKmeansSettings { @@ -58,7 +56,6 @@ pub struct BalancedKmeansSettings { pub max_iter: usize, pub max_balance_iter: usize, pub erode: bool, - pub hilbert: bool, pub mbr_early_break: bool, } @@ -71,7 +68,6 @@ impl Default for BalancedKmeansSettings { max_iter: 50, max_balance_iter: 1, // for now, `max_balance_iter > 1` yields poor convergence time erode: false, // for now, `erode` yields` enabled yields wrong results - hilbert: true, mbr_early_break: false, // for now, `mbr_early_break` enabled yields wrong results } } @@ -129,7 +125,7 @@ fn balanced_k_means_with_initial_partition( // Generate initial lower and upper bounds. These two variables represent bounds on // the effective distance between an point and the cluster it is assigned to. let mut lbs: Vec<_> = points.par_iter().map(|_| 0.).collect(); - let mut ubs: Vec<_> = points.par_iter().map(|_| std::f64::MAX).collect(); // we use f64::MAX to represent infinity + let mut ubs: Vec<_> = points.par_iter().map(|_| f64::MAX).collect(); // we use f64::MAX to represent infinity balanced_k_means_iter( Inputs { points, weights }, @@ -480,8 +476,8 @@ fn best_values( f64, // new ub Option, // new cluster assignment for the current point (None if the same assignment is kept) ) { - let mut best_value = std::f64::MAX; - let mut snd_best_value = std::f64::MAX; + let mut best_value = f64::MAX; + let mut snd_best_value = f64::MAX; let mut assignment = None; for (((center, id), distance_to_mbr), influence) in centers @@ -578,7 +574,6 @@ pub struct KMeans { pub max_iter: usize, pub max_balance_iter: usize, pub erode: bool, - pub hilbert: bool, pub mbr_early_break: bool, } @@ -590,7 +585,6 @@ impl Default for KMeans { max_iter: 500, max_balance_iter: 20, // for now, `max_balance_iter > 1` yields poor convergence time erode: false, // for now, `erode` yields` enabled yields wrong results - hilbert: true, mbr_early_break: false, // for now, `mbr_early_break` enabled yields wrong results } } @@ -621,7 +615,6 @@ where max_iter: self.max_iter, max_balance_iter: self.max_balance_iter, erode: self.erode, - hilbert: self.hilbert, mbr_early_break: self.mbr_early_break, }; balanced_k_means_with_initial_partition(points, weights, settings, part_ids); diff --git a/src/algorithms/kernighan_lin.rs b/src/algorithms/kernighan_lin.rs index 20bfad48..3bdae44c 100644 --- a/src/algorithms/kernighan_lin.rs +++ b/src/algorithms/kernighan_lin.rs @@ -78,8 +78,7 @@ fn kernighan_lin_2_impl( let mut locks = vec![false; initial_partition.len()]; // pass loop - for _ in 0..(initial_partition.len() / 2).min(max_flips_per_pass.unwrap_or(std::usize::MAX)) - { + for _ in 0..(initial_partition.len() / 2).min(max_flips_per_pass.unwrap_or(usize::MAX)) { // construct gains for (idx, gain) in gains.iter_mut().enumerate() { for (j, w) in adjacency.neighbors(idx) { diff --git a/src/algorithms/multi_jagged.rs b/src/algorithms/multi_jagged.rs index 1fc4de1e..a2cb9198 100644 --- a/src/algorithms/multi_jagged.rs +++ b/src/algorithms/multi_jagged.rs @@ -239,7 +239,7 @@ pub(crate) fn compute_split_positions( let mut scan = permutation .par_iter() .enumerate() - .fold_with((std::usize::MAX, 0.), |(low, acc), (idx, val)| { + .fold_with((usize::MAX, 0.), |(low, acc), (idx, val)| { (usize::min(idx, low), acc + weights[*val]) }) .collect::>() diff --git a/src/algorithms/z_curve.rs b/src/algorithms/z_curve.rs index ea070b53..593851d8 100644 --- a/src/algorithms/z_curve.rs +++ b/src/algorithms/z_curve.rs @@ -36,7 +36,7 @@ use std::sync::atomic::{self, AtomicPtr}; // in 2D, an order greater than 64 will overflow u128. // maybe it would be more appropriate to use a BigInt type HashType = u128; -const HASH_TYPE_MAX: HashType = std::u128::MAX; +const HASH_TYPE_MAX: HashType = u128::MAX; fn z_curve_partition( partition: &mut [usize], diff --git a/src/cartesian/mod.rs b/src/cartesian/mod.rs index 9b50f33f..da84ec24 100644 --- a/src/cartesian/mod.rs +++ b/src/cartesian/mod.rs @@ -78,7 +78,7 @@ impl Grid { _ => { for (s, p) in self.size.into_iter().zip(&mut pos) { *p = i % s; - i = i / s; + i /= s; } } } @@ -265,7 +265,10 @@ impl Topology for Grid where E: One, { - type Neighbors<'a> = GridNeighbors where Self: 'a; + type Neighbors<'a> + = GridNeighbors + where + Self: 'a; fn len(&self) -> usize { self.len() diff --git a/src/geometry.rs b/src/geometry.rs index 01e08b63..2f583242 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -42,8 +42,8 @@ impl BoundingBox { let (p_min, p_max) = points .fold_with( ( - PointND::::from_element(std::f64::MAX), - PointND::::from_element(std::f64::MIN), + PointND::::from_element(f64::MAX), + PointND::::from_element(f64::MIN), ), |(mut mins, mut maxs), vals| { for ((min, max), val) in mins.iter_mut().zip(maxs.iter_mut()).zip(&vals) { @@ -118,7 +118,7 @@ impl BoundingBox { } pub fn contains(&self, point: &PointND) -> bool { - let eps = 10. * std::f64::EPSILON; + let eps = 10. * f64::EPSILON; self.p_min .iter() .zip(self.p_max.iter()) diff --git a/src/nextafter.rs b/src/nextafter.rs index 6ed36318..5f38ba47 100644 --- a/src/nextafter.rs +++ b/src/nextafter.rs @@ -30,25 +30,25 @@ pub fn nextafter(from: f64, to: f64) -> f64 { mod tests { use super::*; - const POS_INF: f64 = std::f64::INFINITY; - const NEG_INF: f64 = std::f64::NEG_INFINITY; + const POS_INF: f64 = f64::INFINITY; + const NEG_INF: f64 = f64::NEG_INFINITY; const POS_ZERO: f64 = 0.0; const NEG_ZERO: f64 = -0.0; // Note: Not the same as f64::MIN_POSITIVE, because that is only the min *normal* number. const SMALLEST_POS: f64 = 5e-324; const SMALLEST_NEG: f64 = -5e-324; - const LARGEST_POS: f64 = std::f64::MAX; - const LARGEST_NEG: f64 = std::f64::MIN; + const LARGEST_POS: f64 = f64::MAX; + const LARGEST_NEG: f64 = f64::MIN; const POS_ONE: f64 = 1.0; const NEG_ONE: f64 = -1.0; - const NEXT_LARGER_THAN_ONE: f64 = 1.0 + std::f64::EPSILON; + const NEXT_LARGER_THAN_ONE: f64 = 1.0 + f64::EPSILON; const NEXT_SMALLER_THAN_ONE: f64 = 0.999_999_999_999_999_9; const SEQUENCE_BIG_NUM: (f64, f64) = (16_237_485_966.000_004, 16_237_485_966.000_006); - const NAN: f64 = std::f64::NAN; + const NAN: f64 = f64::NAN; fn is_pos_zero(x: f64) -> bool { x.to_bits() == POS_ZERO.to_bits() diff --git a/src/topology/mod.rs b/src/topology/mod.rs index 53167942..a0ed7ccb 100644 --- a/src/topology/mod.rs +++ b/src/topology/mod.rs @@ -94,13 +94,15 @@ pub trait Topology { } } -impl<'a, T, E> Topology for &'a T +impl Topology for &T where E: Copy, T: Topology, { - type Neighbors<'n> = T::Neighbors<'n> - where Self: 'n; + type Neighbors<'n> + = T::Neighbors<'n> + where + Self: 'n; fn len(&self) -> usize { T::len(self) diff --git a/src/topology/sprs.rs b/src/topology/sprs.rs index 402e994f..16e54776 100644 --- a/src/topology/sprs.rs +++ b/src/topology/sprs.rs @@ -10,12 +10,14 @@ use std::iter::Sum; use std::iter::Zip; use std::ops::Mul; -impl<'a, E> Topology for sprs::CsMatView<'a, E> +impl Topology for sprs::CsMatView<'_, E> where E: Copy + Sync, { - type Neighbors<'n> = Zip>, Cloned>> - where Self: 'n; + type Neighbors<'n> + = Zip>, Cloned>> + where + Self: 'n; fn len(&self) -> usize { debug_assert_eq!(self.rows(), self.cols()); diff --git a/src/work_share.rs b/src/work_share.rs index 6bf67d3d..e0d4b2cd 100644 --- a/src/work_share.rs +++ b/src/work_share.rs @@ -12,10 +12,10 @@ pub fn work_share(total_work: usize, max_threads: usize) -> (usize, usize) { let max_threads = usize::min(total_work, max_threads); // ceil(total_work / max_threads) - let work_per_thread = (total_work + max_threads - 1) / max_threads; + let work_per_thread = total_work.div_ceil(max_threads); // ceil(total_work / work_per_thread) - let thread_count = (total_work + work_per_thread - 1) / work_per_thread; + let thread_count = total_work.div_ceil(work_per_thread); (work_per_thread, thread_count) } diff --git a/tools/mesh-io/ffi/src/lib.rs b/tools/mesh-io/ffi/src/lib.rs index f7fb5711..c0281f90 100644 --- a/tools/mesh-io/ffi/src/lib.rs +++ b/tools/mesh-io/ffi/src/lib.rs @@ -5,7 +5,6 @@ use std::ffi::c_int; use std::fs; use std::io; use std::os::unix::io::FromRawFd as _; -use std::os::unix::io::IntoRawFd as _; use std::ptr; const ERROR_OTHER: c_int = -1; @@ -50,8 +49,8 @@ pub unsafe extern "C" fn mio_partition_write(fd: c_int, size: u64, partition: *c return ERROR_OTHER; } match w.into_inner() { - Ok(f) => { - f.into_raw_fd(); + Ok(_) => { + //f.into_raw_fd(); 0 } Err(_) => ERROR_OTHER, diff --git a/tools/mesh-io/src/vtk.rs b/tools/mesh-io/src/vtk.rs index d68928f8..82d05e82 100644 --- a/tools/mesh-io/src/vtk.rs +++ b/tools/mesh-io/src/vtk.rs @@ -98,7 +98,7 @@ fn add_piece(mesh: &mut Mesh, piece: UnstructuredGridPiece) { mesh.coordinates.extend(piece.points.iter().unwrap()); // TODO extract attributes mesh.node_refs - .extend(iter::repeat(1).take(piece.num_points())); + .extend(std::iter::repeat_n(1, piece.num_points())); match piece.cells.cell_verts { VertexNumbers::Legacy { num_cells, diff --git a/tools/num-part/Cargo.toml b/tools/num-part/Cargo.toml index 1ba1a663..78b0813d 100644 --- a/tools/num-part/Cargo.toml +++ b/tools/num-part/Cargo.toml @@ -27,7 +27,7 @@ itertools = { version = "0.12", default-features = false } coupe = { version = "0.1", path = "../.." } # SQLite interface to save experiments -rusqlite = { version = "0.30", default-features = false } +rusqlite = { version = "0.30", default-features = false, features = ["bundled"] } # Command-line interface getopts = { version = "0.2", default-features = false } diff --git a/tools/src/lib.rs b/tools/src/lib.rs index c8dd087c..46153350 100644 --- a/tools/src/lib.rs +++ b/tools/src/lib.rs @@ -35,7 +35,7 @@ mod scotch; #[cfg(any(feature = "metis", feature = "scotch"))] mod zoom_in; -#[cfg_attr(not(feature = "ittapi"), path = "ittapi_stub.rs")] +#[cfg_attr(not(feature = "intel-perf"), path = "ittapi_stub.rs")] pub mod ittapi; pub struct Problem { @@ -92,7 +92,7 @@ pub type Metadata = Option>; pub type Runner<'a> = Box Result + Send + Sync + 'a>; -fn runner_error(message: &'static str) -> Runner { +fn runner_error(message: &'static str) -> Runner<'static> { Box::new(move |_partition| Err(anyhow::anyhow!("{}", message))) }