diff --git a/hercules_opt/src/editor.rs b/hercules_opt/src/editor.rs index e6db74596fbb85f03333742dc1e8e035a6a9f821..39f1184cc947a35418641a817a86321343f101fc 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 319d32b81dc19f196bc6707464c020b099e728f2..1abb89672ae1d5c4f0f34578ca9d8eb2d69a2bc0 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 8b2c632726e988e4441a2da300b09ce472b70f24..a4605bec7824255b0098cafabb50ed5446773947 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 96fb96d256598ca67ae8aa687d21963033a4a116..730776786598318ccaf60a424164f67f5e16c112 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 dd1d0ab664bdcdb59e0b7078cd115b0a5388f726..f7252d29b66f9fc1882849206bbbf5b327a0f307 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 e59c815da12b505cadc807c4d87e6a2ef913d3fa..8fe978c5c9554fa7d0fd42f480ff724dcdc9cb36 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::*;