Skip to content

Commit

Permalink
Update toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmilson committed Sep 22, 2024
1 parent a51f630 commit 0fae216
Show file tree
Hide file tree
Showing 42 changed files with 491 additions and 456 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/benchmarks-pages.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name:
name:

on:
push:
Expand All @@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-01-04
toolchain: nightly-2024-09-21
- name: Run benchmark
run: ./scripts/bench.sh -- --output-format bencher | tee output.txt
- name: Download previous benchmark data
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
tool: 'cargo'
tool: "cargo"
output-file-path: output.txt
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
34 changes: 17 additions & 17 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: dtolnay/rust-toolchain@master
with:
components: rustfmt
toolchain: nightly-2024-01-04
toolchain: nightly-2024-09-21
- uses: Swatinem/rust-cache@v2
- run: scripts/rust_fmt.sh --check

Expand All @@ -36,7 +36,7 @@ jobs:
- uses: dtolnay/rust-toolchain@master
with:
components: clippy
toolchain: nightly-2024-01-04
toolchain: nightly-2024-09-21
- uses: Swatinem/rust-cache@v2
- run: scripts/clippy.sh

Expand All @@ -46,17 +46,17 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-01-04
toolchain: nightly-2024-09-21
- uses: Swatinem/rust-cache@v2
- run: cargo +nightly-2024-01-04 doc
- run: cargo +nightly-2024-09-21 doc

run-wasm32-wasi-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-01-04
toolchain: nightly-2024-09-21
targets: wasm32-wasi
- uses: taiki-e/install-action@v2
with:
Expand All @@ -73,7 +73,7 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-01-04
toolchain: nightly-2024-09-21
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- uses: jetli/wasm-pack-action@v0.4.0
Expand All @@ -89,9 +89,9 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-01-04
toolchain: nightly-2024-09-21
- uses: Swatinem/rust-cache@v2
- run: cargo +nightly-2024-01-04 test
- run: cargo +nightly-2024-09-21 test
env:
RUSTFLAGS: -C target-feature=+neon

Expand All @@ -104,9 +104,9 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-01-04
toolchain: nightly-2024-09-21
- uses: Swatinem/rust-cache@v2
- run: cargo +nightly-2024-01-04 test
- run: cargo +nightly-2024-09-21 test
env:
RUSTFLAGS: -C target-cpu=native -C target-feature=+${{ matrix.target-feature }}

Expand All @@ -116,7 +116,7 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-01-04
toolchain: nightly-2024-09-21
- name: Run benchmark
run: ./scripts/bench.sh -- --output-format bencher | tee output.txt
- name: Download previous benchmark data
Expand All @@ -142,19 +142,19 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-01-04
toolchain: nightly-2024-09-21
- uses: Swatinem/rust-cache@v2
- run: cargo +nightly-2024-01-04 test
- run: cargo +nightly-2024-09-21 test

run-slow-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-01-04
toolchain: nightly-2024-09-21
- uses: Swatinem/rust-cache@v2
- run: cargo +nightly-2024-01-04 test --release --features="slow-tests"
- run: cargo +nightly-2024-09-21 test --release --features="slow-tests"

udeps:
runs-on: ubuntu-latest
Expand All @@ -163,7 +163,7 @@ jobs:
- uses: dtolnay/rust-toolchain@master
name: "Rust Toolchain Setup"
with:
toolchain: nightly-2024-01-04
toolchain: nightly-2024-09-21
- uses: Swatinem/rust-cache@v2
id: "cache-cargo"
- if: ${{ steps.cache-cargo.outputs.cache-hit != 'true' }}
Expand All @@ -172,7 +172,7 @@ jobs:
wget -O - -c https://github.com/est31/cargo-udeps/releases/download/v0.1.35/cargo-udeps-v0.1.35-x86_64-unknown-linux-gnu.tar.gz | tar -xz
cargo-udeps-*/cargo-udeps udeps
env:
RUSTUP_TOOLCHAIN: nightly-2024-01-04
RUSTUP_TOOLCHAIN: nightly-2024-09-21

all-tests:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ jobs:
- uses: dtolnay/rust-toolchain@master
with:
components: rustfmt
toolchain: nightly-2024-01-04
toolchain: nightly-2024-09-21
- uses: Swatinem/rust-cache@v2
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
# TODO: Merge coverage reports for tests on different architectures.
# <https://github.com/taiki-e/cargo-llvm-cov?tab=readme-ov-file#merge-coverages-generated-under-different-test-conditions>
- name: Generate code coverage
run: cargo +nightly-2024-01-04 llvm-cov --codecov --output-path codecov.json
run: cargo +nightly-2024-09-21 llvm-cov --codecov --output-path codecov.json
env:
RUSTFLAGS: "-C target-feature=+avx512f"
- name: Upload coverage to Codecov
Expand Down
14 changes: 8 additions & 6 deletions crates/prover/benches/fft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn simd_ifft(c: &mut Criterion) {
|| values.clone().data,
|mut data| unsafe {
ifft(
transmute(data.as_mut_ptr()),
transmute::<*mut PackedBaseField, *mut u32>(data.as_mut_ptr()),
black_box(&twiddle_dbls_refs),
black_box(log_size as usize),
);
Expand Down Expand Up @@ -58,7 +58,7 @@ pub fn simd_ifft_parts(c: &mut Criterion) {
|| values.clone().data,
|mut values| unsafe {
ifft_vecwise_loop(
transmute(values.as_mut_ptr()),
transmute::<*mut PackedBaseField, *mut u32>(values.as_mut_ptr()),
black_box(&twiddle_dbls_refs),
black_box(9),
black_box(0),
Expand All @@ -72,7 +72,7 @@ pub fn simd_ifft_parts(c: &mut Criterion) {
|| values.clone().data,
|mut values| unsafe {
ifft3_loop(
transmute(values.as_mut_ptr()),
transmute::<*mut PackedBaseField, *mut u32>(values.as_mut_ptr()),
black_box(&twiddle_dbls_refs[3..]),
black_box(7),
black_box(4),
Expand All @@ -91,7 +91,7 @@ pub fn simd_ifft_parts(c: &mut Criterion) {
|| transpose_values.clone().data,
|mut values| unsafe {
transpose_vecs(
transmute(values.as_mut_ptr()),
transmute::<*mut PackedBaseField, *mut u32>(values.as_mut_ptr()),
black_box(TRANSPOSE_LOG_SIZE as usize - 4),
)
},
Expand All @@ -115,8 +115,10 @@ pub fn simd_rfft(c: &mut Criterion) {
target.set_len(values.data.len());

fft(
black_box(transmute(values.data.as_ptr())),
transmute(target.as_mut_ptr()),
black_box(transmute::<*const PackedBaseField, *const u32>(
values.data.as_ptr(),
)),
transmute::<*mut PackedBaseField, *mut u32>(target.as_mut_ptr()),
black_box(&twiddle_dbls_refs),
black_box(LOG_SIZE as usize),
)
Expand Down
2 changes: 1 addition & 1 deletion crates/prover/benches/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn bench_blake2s_merkle<B: MerkleOps<Blake2sMerkleHasher>>(c: &mut Criterion, id
let n_elements = 1 << (LOG_N_COLS + LOG_N_ROWS);
group.throughput(Throughput::Elements(n_elements));
group.throughput(Throughput::Bytes(N_BYTES_FELT as u64 * n_elements));
group.bench_function(&format!("{id} merkle"), |b| {
group.bench_function(format!("{id} merkle"), |b| {
b.iter_with_large_drop(|| B::commit_on_layer(LOG_N_ROWS, None, &col_refs))
});
}
Expand Down
5 changes: 3 additions & 2 deletions crates/prover/src/constraint_framework/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ impl TraceLocationAllocator {
}

/// A component defined solely in means of the constraints framework.
///
/// Implementing this trait introduces implementations for [`Component`] and [`ComponentProver`] for
/// the SIMD backend.
/// Note that the constraint framework only support components with columns of the same size.
/// the SIMD backend. Note that the constraint framework only supports components with columns of
/// the same size.
pub trait FrameworkEval {
fn log_size(&self) -> u32;

Expand Down
1 change: 1 addition & 0 deletions crates/prover/src/core/air/accumulation.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Accumulators for a random linear combination of circle polynomials.
//!
//! Given N polynomials, u_0(P), ... u_{N-1}(P), and a random alpha, the combined polynomial is
//! defined as
//! f(p) = sum_i alpha^{N-1-i} u_i(P).
Expand Down
8 changes: 4 additions & 4 deletions crates/prover/src/core/air/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ mod components;
pub mod mask;

/// Arithmetic Intermediate Representation (AIR).
/// An Air instance is assumed to already contain all the information needed to
/// evaluate the constraints.
/// For instance, all interaction elements are assumed to be present in it.
/// Therefore, an AIR is generated only after the initial trace commitment phase.
///
/// An Air instance is assumed to already contain all the information needed to evaluate the
/// constraints. For instance, all interaction elements are assumed to be present in it. Therefore,
/// an AIR is generated only after the initial trace commitment phase.
// TODO(spapini): consider renaming this struct.
pub trait Air {
fn components(&self) -> Vec<&dyn Component>;
Expand Down
13 changes: 7 additions & 6 deletions crates/prover/src/core/backend/cpu/quotients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ pub fn accumulate_row_quotients(
row_accumulator
}

/// Precompute the complex conjugate line coefficients for each column in each sample batch.
/// Specifically, for the i-th (in a sample batch) column's numerator term
/// `alpha^i * (c * F(p) - (a * p.y + b))`, we precompute and return the constants:
/// (`alpha^i * a`, `alpha^i * b`, `alpha^i * c`).
/// Precomputes the complex conjugate line coefficients for each column in each sample batch.
///
/// For the `i`-th (in a sample batch) column's numerator term `alpha^i * (c * F(p) - (a * p.y +
/// b))`, we precompute and return the constants: (`alpha^i * a`, `alpha^i * b`, `alpha^i * c`).
pub fn column_line_coeffs(
sample_batches: &[ColumnSampleBatch],
random_coeff: SecureField,
Expand All @@ -103,8 +103,9 @@ pub fn column_line_coeffs(
.collect()
}

/// Precompute the random coefficients used to linearly combine the batched quotients.
/// Specifically, for each sample batch we compute random_coeff^(number of columns in the batch),
/// Precomputes the random coefficients used to linearly combine the batched quotients.
///
/// For each sample batch we compute random_coeff^(number of columns in the batch),
/// which is used to linearly combine the batch with the next one.
pub fn batch_random_coeffs(
sample_batches: &[ColumnSampleBatch],
Expand Down
2 changes: 1 addition & 1 deletion crates/prover/src/core/backend/simd/bit_reverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ mod tests {

let res = bit_reverse16(values.data.try_into().unwrap());

assert_eq!(res.map(PackedM31::to_array).flatten(), expected);
assert_eq!(res.map(PackedM31::to_array).as_flattened(), expected);
}

#[test]
Expand Down
8 changes: 6 additions & 2 deletions crates/prover/src/core/backend/simd/blake2s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,12 @@ mod tests {

let res_vectorized: [[u32; 8]; 16] = unsafe {
transmute(untranspose_states(compress16(
transpose_states(transmute(states)),
transpose_msgs(transmute(msgs)),
transpose_states(transmute::<Aligned<A64, [[u32; 8]; 16]>, [u32x16; 8]>(
states,
)),
transpose_msgs(transmute::<Aligned<A64, [[u32; 16]; 16]>, [u32x16; 16]>(
msgs,
)),
u32x16::splat(count_low),
u32x16::splat(count_high),
u32x16::splat(lastblock),
Expand Down
11 changes: 4 additions & 7 deletions crates/prover/src/core/backend/simd/circle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ impl SimdBackend {

// Generates twiddle steps for efficiently computing the twiddles.
// steps[i] = t_i/(t_0*t_1*...*t_i-1).
fn twiddle_steps<F: Field>(mappings: &[F]) -> Vec<F>
where
F: FieldExpOps,
{
fn twiddle_steps<F: Field + FieldExpOps>(mappings: &[F]) -> Vec<F> {
let mut denominators: Vec<F> = vec![mappings[0]];

for i in 1..mappings.len() {
Expand Down Expand Up @@ -151,7 +148,7 @@ impl PolyOps for SimdBackend {
// Safe because [PackedBaseField] is aligned on 64 bytes.
unsafe {
ifft::ifft(
transmute(values.data.as_mut_ptr()),
transmute::<*mut PackedBaseField, *mut u32>(values.data.as_mut_ptr()),
&twiddles,
log_size as usize,
);
Expand Down Expand Up @@ -254,8 +251,8 @@ impl PolyOps for SimdBackend {
// FFT from the coefficients buffer to the values chunk.
unsafe {
rfft::fft(
transmute(poly.coeffs.data.as_ptr()),
transmute(
transmute::<*const PackedBaseField, *const u32>(poly.coeffs.data.as_ptr()),
transmute::<*mut PackedBaseField, *mut u32>(
values[i << (fft_log_size - LOG_N_LANES)
..(i + 1) << (fft_log_size - LOG_N_LANES)]
.as_mut_ptr(),
Expand Down
13 changes: 8 additions & 5 deletions crates/prover/src/core/backend/simd/fft/ifft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ mod tests {
let mut res = values;
unsafe {
ifft3(
transmute(res.as_mut_ptr()),
transmute::<*mut PackedBaseField, *mut u32>(res.as_mut_ptr()),
0,
LOG_N_LANES as usize,
twiddles0_dbl,
Expand Down Expand Up @@ -655,7 +655,7 @@ mod tests {
[val0.to_array(), val1.to_array()].concat()
};

assert_eq!(res, ground_truth_ifft(domain, values.flatten()));
assert_eq!(res, ground_truth_ifft(domain, values.as_flattened()));
}

#[test]
Expand All @@ -669,7 +669,7 @@ mod tests {
let mut res = values.iter().copied().collect::<BaseColumn>();
unsafe {
ifft_lower_with_vecwise(
transmute(res.data.as_mut_ptr()),
transmute::<*mut PackedBaseField, *mut u32>(res.data.as_mut_ptr()),
&twiddle_dbls.iter().map(|x| x.as_slice()).collect_vec(),
log_size as usize,
log_size as usize,
Expand All @@ -691,11 +691,14 @@ mod tests {
let mut res = values.iter().copied().collect::<BaseColumn>();
unsafe {
ifft(
transmute(res.data.as_mut_ptr()),
transmute::<*mut PackedBaseField, *mut u32>(res.data.as_mut_ptr()),
&twiddle_dbls.iter().map(|x| x.as_slice()).collect_vec(),
log_size as usize,
);
transpose_vecs(transmute(res.data.as_mut_ptr()), log_size as usize - 4);
transpose_vecs(
transmute::<*mut PackedBaseField, *mut u32>(res.data.as_mut_ptr()),
log_size as usize - 4,
);
}

assert_eq!(res.to_cpu(), ground_truth_ifft(domain, &values));
Expand Down
Loading

0 comments on commit 0fae216

Please sign in to comment.