From c46b7587209de283a34cbcaf8deef3edbdd59678 Mon Sep 17 00:00:00 2001 From: Russel Arbore <russel.jma@gmail.com> Date: Thu, 30 Jan 2025 10:49:15 -0600 Subject: [PATCH] more warning fixes --- hercules_opt/src/editor.rs | 2 +- hercules_opt/src/fork_guard_elim.rs | 2 -- hercules_opt/src/fork_transforms.rs | 32 ++++++------------ hercules_opt/src/forkify.rs | 50 ++++++----------------------- hercules_opt/src/ivar.rs | 7 ++-- hercules_opt/src/outline.rs | 1 - 6 files changed, 23 insertions(+), 71 deletions(-) diff --git a/hercules_opt/src/editor.rs b/hercules_opt/src/editor.rs index e6db7459..39f1184c 100644 --- a/hercules_opt/src/editor.rs +++ b/hercules_opt/src/editor.rs @@ -1,6 +1,6 @@ use std::borrow::Borrow; use std::cell::{Ref, RefCell}; -use std::collections::{BTreeMap, HashMap, HashSet}; +use std::collections::{BTreeMap, HashSet}; use std::mem::take; use std::ops::Deref; diff --git a/hercules_opt/src/fork_guard_elim.rs b/hercules_opt/src/fork_guard_elim.rs index 319d32b8..1abb8967 100644 --- a/hercules_opt/src/fork_guard_elim.rs +++ b/hercules_opt/src/fork_guard_elim.rs @@ -1,7 +1,5 @@ use std::collections::{HashMap, HashSet}; -use either::Either; - use hercules_ir::*; use crate::*; diff --git a/hercules_opt/src/fork_transforms.rs b/hercules_opt/src/fork_transforms.rs index 8b2c6327..a4605bec 100644 --- a/hercules_opt/src/fork_transforms.rs +++ b/hercules_opt/src/fork_transforms.rs @@ -1,25 +1,11 @@ use std::collections::{HashMap, HashSet}; -use std::ops::Sub; - -use itertools::Itertools; use bimap::BiMap; +use itertools::Itertools; -use hercules_ir::LoopTree; - -use hercules_ir::{Index, TypeID}; - -use hercules_ir::Subgraph; - -use hercules_ir::DynamicConstantID; - -use hercules_ir::Node; - -use hercules_ir::{get_uses, Function}; - -use hercules_ir::{NodeID, ID}; +use hercules_ir::*; -use crate::{DenseNodeMap, FunctionEditor, Loop, SparseNodeMap}; +use crate::*; type ForkID = usize; @@ -245,11 +231,11 @@ pub fn fork_bufferize_fission_helper<'a>( let thread_stuff_it = factors.into_iter().enumerate(); // FIxme: try to use unzip here? Idk why it wasn't working. - let (tids) = thread_stuff_it.clone().map(|(dim, _)| { - (edit.add_node(Node::ThreadID { + let tids = thread_stuff_it.clone().map(|(dim, _)| { + edit.add_node(Node::ThreadID { control: fork, dimension: dim, - })) + }) }); let array_dims = thread_stuff_it.clone().map(|(_, factor)| (factor)); @@ -279,11 +265,11 @@ pub fn fork_bufferize_fission_helper<'a>( edit = edit.replace_all_uses_where(NodeID::new(0), reduce, |usee| *usee == write)?; // Create read from buffer - let (tids) = thread_stuff_it.clone().map(|(dim, _)| { - (edit.add_node(Node::ThreadID { + let tids = thread_stuff_it.clone().map(|(dim, _)| { + edit.add_node(Node::ThreadID { control: new_fork_id, dimension: dim, - })) + }) }); let position_idx = Index::Position(tids.collect::<Vec<_>>().into_boxed_slice()); diff --git a/hercules_opt/src/forkify.rs b/hercules_opt/src/forkify.rs index 96fb96d2..73077678 100644 --- a/hercules_opt/src/forkify.rs +++ b/hercules_opt/src/forkify.rs @@ -1,39 +1,14 @@ -use core::panic; use std::collections::HashMap; use std::collections::HashSet; use std::iter::zip; use std::iter::FromIterator; +use itertools::Itertools; use nestify::nest; -use bitvec::order::Lsb0; -use bitvec::vec::BitVec; - -use hercules_ir::Subgraph; - -use hercules_ir::control_subgraph; - -use crate::calculate_loop_nodes; -use crate::compute_induction_vars; -use crate::compute_iv_ranges; -use crate::compute_loop_variance; -use crate::get_loop_exit_conditions; -use crate::has_canonical_iv; -use crate::walk_all_users; -use crate::walk_all_users_stop_on; -use crate::walk_all_uses; -use crate::walk_all_uses_stop_on; -use crate::DenseNodeMap; -use crate::FunctionEditor; -use crate::InductionVariable; -use crate::Loop; -use crate::LoopExit; -use crate::LoopVarianceInfo; - -use hercules_ir::def_use::*; -use hercules_ir::ir::*; -use hercules_ir::loops::*; -use itertools::Itertools; +use hercules_ir::*; + +use crate::*; pub fn forkify( editor: &mut FunctionEditor, @@ -442,7 +417,7 @@ pub fn analyze_phis<'a>( let data = &editor.func().nodes[node.idx()]; // External Phi - if let Node::Phi { control, data } = data { + if let Node::Phi { control, data: _ } = data { if *control != natural_loop.header { return true; } @@ -450,8 +425,8 @@ pub fn analyze_phis<'a>( // External Reduce if let Node::Reduce { control, - init, - reduct, + init: _, + reduct: _, } = data { if !natural_loop.control[control.idx()] { @@ -487,16 +462,11 @@ pub fn analyze_phis<'a>( let data = &editor.func().nodes[node.idx()]; // Phi, Reduce - if let Node::Phi { control, data } = data { + if data.is_phi() { return true; } - if let Node::Reduce { - control, - init, - reduct, - } = data - { + if data.is_reduce() { return true; } @@ -521,7 +491,7 @@ pub fn analyze_phis<'a>( // we use `phis` because this phi can actually contain the loop iv and its fine. if uses_for_dependance.any(|node| phis.contains(&node) && node != *phi) { LoopPHI::LoopDependant(*phi) - } else if intersection.clone().iter().any(|node| true) { + } else if intersection.clone().iter().next().is_some() { // PHIs on the frontier of the uses by the candidate phi, i.e in uses_for_dependance need // to have headers that postdominate the loop continue latch. The value of the PHI used needs to be defined // by the time the reduce is triggered (at the end of the loop's internal control). diff --git a/hercules_opt/src/ivar.rs b/hercules_opt/src/ivar.rs index dd1d0ab6..f7252d29 100644 --- a/hercules_opt/src/ivar.rs +++ b/hercules_opt/src/ivar.rs @@ -1,10 +1,9 @@ -use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; -use std::path::Iter; +use std::collections::HashSet; +use bitvec::prelude::*; use nestify::nest; -use slotmap::{new_key_type, SlotMap}; -use hercules_ir::ir::*; +use hercules_ir::*; use crate::*; diff --git a/hercules_opt/src/outline.rs b/hercules_opt/src/outline.rs index e59c815d..8fe978c5 100644 --- a/hercules_opt/src/outline.rs +++ b/hercules_opt/src/outline.rs @@ -4,7 +4,6 @@ use std::sync::atomic::{AtomicUsize, Ordering}; use hercules_ir::def_use::*; use hercules_ir::dom::*; -use hercules_ir::fork_join_analysis::*; use hercules_ir::ir::*; use hercules_ir::subgraph::*; -- GitLab