Skip to content

Commit

Permalink
bump rust versions to stable (#1925)
Browse files Browse the repository at this point in the history
* bump rust versions to stable

* fix some new clippy warnings

* fix another clippy error

* pin versions + strange hack to get around pip external managed libs

* switch to installing python packages into a venv

* fix static computation

---------

Co-authored-by: Rachit Nigam <[email protected]>
  • Loading branch information
sgpthomas and rachitnigam authored Feb 18, 2024
1 parent 60f119e commit 0992141
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion calyx-backend/src/firrtl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fn emit_component<F: io::Write>(

// 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)?;
}
Expand Down
40 changes: 22 additions & 18 deletions calyx-opt/src/analysis/compute_static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T, F>(stmts: &mut [T], extra: &T::Info, merge: F) -> Option<u64>
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<u64> {
// 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<u64> {
// 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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion calyx-opt/src/analysis/inference_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions calyx-opt/src/passes/cell_share.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,7 @@ impl Visitor for CellShare {
let mut coloring: rewriter::RewriteMap<ir::Cell> = HashMap::new();
let mut comp_share_freqs: HashMap<ir::CellType, HashMap<i64, i64>> =
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 = {
Expand Down

0 comments on commit 0992141

Please sign in to comment.