diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index b4c1bcc6e2..033082d630 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -12,7 +12,7 @@ jobs: - name: Install stable uses: actions-rs/toolchain@v1 with: - toolchain: 1.69.0 + toolchain: 1.76.0 override: true components: rustfmt, clippy - name: Check formatting diff --git a/Dockerfile b/Dockerfile index f5cbbfcd43..32d92ce264 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Use the official rust image as a parent image. -FROM rust:1.70 +FROM rust:1.76 # Connect to the Calux repository. LABEL org.opencontainers.image.source https://github.com/calyxir/calyx @@ -9,7 +9,11 @@ RUN echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | tee /etc/ap echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | tee /etc/apt/sources.list.d/sbt_old.list && \ curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | apt-key add && \ apt-get update -y && \ - apt-get install -y jq python3.10 python3-pip sbt make autoconf g++ flex bison libfl2 libfl-dev default-jdk ninja-build build-essential cmake autoconf gperf + apt-get install -y jq python3.10 python3-pip python3-venv sbt make autoconf g++ flex bison libfl2 libfl-dev default-jdk ninja-build build-essential cmake autoconf gperf + +# Setup python venv to install python dependencies. Python no longer supports installing packages globally into your system +RUN python3 -m venv /opt/venv +ENV PATH="/opt/venv/bin:$PATH" # Install python dependencies RUN python3 -m pip install numpy flit prettytable wheel hypothesis pytest simplejson cocotb==1.6.2 @@ -25,7 +29,7 @@ RUN autoconf && ./configure && make && make install # Install Icarus verilog WORKDIR /home -RUN git clone --depth 1 --branch v11_0 https://github.com/steveicarus/iverilog +RUN git clone --depth 1 --branch v12_0 https://github.com/steveicarus/iverilog WORKDIR /home/iverilog RUN sh autoconf.sh && ./configure && make && make install @@ -43,7 +47,7 @@ RUN cp ../cmake/config.cmake . && \ cmake -G Ninja .. && ninja && \ python3 -m pip install -Iv antlr4-python3-runtime==4.7.2 WORKDIR /home/tvm/python -RUN python3 setup.py bdist_wheel && python3 -m pip install --user dist/tvm-*.whl +RUN python3 setup.py bdist_wheel && python3 -m pip install dist/tvm-*.whl # Install Dahlia WORKDIR /home diff --git a/calyx-backend/src/firrtl.rs b/calyx-backend/src/firrtl.rs index dabccc39f6..7a743e49dd 100644 --- a/calyx-backend/src/firrtl.rs +++ b/calyx-backend/src/firrtl.rs @@ -86,7 +86,7 @@ fn emit_component( // Inputs and Outputs let sig = comp.signature.borrow(); - for (_idx, port_ref) in sig.ports.iter().enumerate() { + for port_ref in &sig.ports { let port = port_ref.borrow(); emit_port(port, true, f)?; } diff --git a/calyx-opt/src/analysis/compute_static.rs b/calyx-opt/src/analysis/compute_static.rs index 169e1e2233..5255a7ac11 100644 --- a/calyx-opt/src/analysis/compute_static.rs +++ b/calyx-opt/src/analysis/compute_static.rs @@ -78,33 +78,37 @@ impl WithStatic for ir::Invoke { } } +/// Walk over a set of control statements and call `update_static` on each of them. +/// Use a merge function to merge the results of the `update_static` calls. +fn walk_static(stmts: &mut [T], extra: &T::Info, merge: F) -> Option +where + T: WithStatic, + F: Fn(u64, u64) -> u64, +{ + let mut latency = Some(0); + // This is implemented as a loop because we want to call `update_static` on + // each statement even if we cannot compute a total latency anymore. + for stmt in stmts.iter_mut() { + let stmt_latency = stmt.update_static(extra); + latency = match (latency, stmt_latency) { + (Some(l), Some(s)) => Some(merge(l, s)), + (_, _) => None, + } + } + latency +} + impl WithStatic for ir::Seq { type Info = CompTime; fn compute_static(&mut self, extra: &Self::Info) -> Option { - // Go through each stmt in the seq, and try to calculate the latency. - self.stmts.iter_mut().fold(Some(0), |acc, stmt| { - match (acc, stmt.update_static(extra)) { - (Some(cur_latency), Some(stmt_latency)) => { - Some(cur_latency + stmt_latency) - } - (_, _) => None, - } - }) + walk_static(&mut self.stmts, extra, |x, y| x + y) } } impl WithStatic for ir::Par { type Info = CompTime; fn compute_static(&mut self, extra: &Self::Info) -> Option { - // Go through each stmt in the par, and try to calculate the latency. - self.stmts.iter_mut().fold(Some(0), |acc, stmt| { - match (acc, stmt.update_static(extra)) { - (Some(cur_latency), Some(stmt_latency)) => { - Some(std::cmp::max(cur_latency, stmt_latency)) - } - (_, _) => None, - } - }) + walk_static(&mut self.stmts, extra, std::cmp::max) } } diff --git a/calyx-opt/src/analysis/inference_analysis.rs b/calyx-opt/src/analysis/inference_analysis.rs index 315113c08b..a2f2b209c2 100644 --- a/calyx-opt/src/analysis/inference_analysis.rs +++ b/calyx-opt/src/analysis/inference_analysis.rs @@ -441,7 +441,7 @@ impl InferenceAnalysis { log::debug!("FAIL: No path between @go and @done port"); return None; } - let first_path = paths.get(0).unwrap(); + let first_path = paths.first().unwrap(); // Sum the latencies of each primitive along the path. let mut latency_sum = 0; diff --git a/calyx-opt/src/passes/cell_share.rs b/calyx-opt/src/passes/cell_share.rs index 860abd2de8..42e5316a34 100644 --- a/calyx-opt/src/passes/cell_share.rs +++ b/calyx-opt/src/passes/cell_share.rs @@ -387,9 +387,7 @@ impl Visitor for CellShare { let mut coloring: rewriter::RewriteMap = HashMap::new(); let mut comp_share_freqs: HashMap> = HashMap::new(); - let comb_bound = self.bounds.get(0).unwrap_or(&None); - let reg_bound = self.bounds.get(1).unwrap_or(&None); - let other_bound = self.bounds.get(2).unwrap_or(&None); + let [comb_bound, reg_bound, other_bound] = &self.bounds; for (cell_type, mut graph) in graphs_by_type { // getting bound, based on self.bounds and cell_type let bound = {