-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compiler options and codegen split #1879
base: main
Are you sure you want to change the base?
Conversation
use crate::CompilerOptions; | ||
|
||
/// Translates a RISC-V program to POWDR ASM | ||
/// with constraints that work for a field >= the Goldilocks modulus. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file contains everything that was "removed" according to GH from the file above code_gen.rs
, and I changed the text in this line. Everything else is untouched.
MERKLE_TREE_DEPTH, NUM_PAGES_INDEX, N_LEAVES_LOG, PAGE_INPUTS_OFFSET, PAGE_NUMBER_MASK, | ||
PAGE_SIZE_BYTES, PC_INDEX, REGISTER_NAMES, SHUTDOWN_START, WORDS_PER_HASH, WORDS_PER_PAGE, | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This "new" file contains everything "removed" from file above bootloader.rs
that is specific to the 64 bits version of the constraints, unmodified.
use itertools::Itertools; | ||
|
||
use crate::code_gen::Register; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file contains everything that was "removed" from file above runtime.rs
, with all the 64-bit specific stuff, unmodified.
runtime = runtime.with_arith(); | ||
} | ||
runtime | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type, its constructor and its usage are the only changes.
#[derive(Clone)] | ||
pub struct SyscallImpl(pub Vec<FunctionStatement>); | ||
|
||
pub trait Runtime { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This trait could even go away potentially, since we don't use it as dyn or Box anymore.
/// Full path to machine (e.g, `path::to::Machine`) | ||
path: SymbolPath, | ||
pub path: SymbolPath, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: these pubs can probably go now too.
use std::{ | ||
path::{Path, PathBuf}, | ||
process::Command, | ||
}; | ||
|
||
/// Like compiler::test_util::run_pilcom_asm_string, but also runs RISCV executor. | ||
pub fn verify_riscv_asm_string<S: serde::Serialize + Send + Sync + 'static>( | ||
pub fn verify_riscv_asm_string<T: FieldElement, S: serde::Serialize + Send + Sync + 'static>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately we do need T around here because of Pipeline and inputs.
fbd7196
to
5f2bd16
Compare
5f2bd16
to
ae84d1e
Compare
let libs = coprocessors_to_options(coprocessors)?; | ||
let options = CompilerOptions::new(field, libs, continuations); | ||
powdr_riscv::compile_riscv_elf(input_file, Path::new(input_file), options, output_dir, true) | ||
.ok_or_else(|| vec!["could not translate RISC-V executable".to_string()])?; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[allow(clippy::too_many_arguments)] | ||
fn execute<F: FieldElement>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
execute already takes F
, it doesn't need the field: KnownField
parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea I kept both because they are used in different ways, so didn't want to mix them up. Fine with removing, but want to double check after explaining why. Should I still remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i'd call F::known_field
inside
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's a similar situation in another part of the code, but there I think F
can be removed, because there you match
on the known field to then pick a concrete field
let mut pipeline_bb = make_prepared_pipeline(file_name, inputs_bb, vec![]); | ||
pipeline_bb.compute_witness().unwrap(); | ||
let pipeline_bb = make_prepared_pipeline(file_name, inputs_bb, vec![]); | ||
test_plonky3_pipeline(pipeline_bb); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this go into this PR? not that I see any particular issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can remove, it just came with the same patch when I extracted
@@ -24,7 +24,7 @@ fn slice_to_vec<T: FieldElement>(arr: &[i32]) -> Vec<T> { | |||
fn sqrt_asm() { | |||
let f = "asm/sqrt.asm"; | |||
let i = [3]; | |||
regular_test(f, &i); | |||
regular_test_without_babybear(f, &i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why without_babybear
again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since I added the change in your other comment above to also make proofs with p3, some asm tests fail because they have lookups/permutations inside the machine which we don't support
@@ -216,6 +216,7 @@ pub struct DryRunResult<F: FieldElement> { | |||
/// - The number of rows after which the prover should jump to the shutdown routine. | |||
pub fn rust_continuations_dry_run<F: FieldElement>( | |||
pipeline: &mut Pipeline<F>, | |||
field: KnownField, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can get KnownField
from F
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea but I wanted to keep them decoupled on purpose, in case we manage to remove F here. But I'll remove it
} | ||
|
||
pub fn with_arith(self) -> Self { | ||
Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can do the following:
Self {
arith: true,
..self
}
and it will move all the other fields to the new object
} | ||
|
||
pub fn with_continuations(self) -> Self { | ||
Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for these
use test_log::test; | ||
|
||
fn run_instruction_test(path: &Path) { | ||
let options_32 = CompilerOptions::new_32(); | ||
run_instruction_test_with_options(path, options_32); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the extra function needed? function itself is a single statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the riscv-bb PR we also run for babybear here, then it made sense. I removed it after the extraction to keep this PR GL only
@@ -13,13 +12,12 @@ use test_log::test; | |||
|
|||
use powdr_riscv::{ | |||
continuations::{rust_continuations, rust_continuations_dry_run}, | |||
Runtime, | |||
CompilerOptions, RuntimeLibs, | |||
}; | |||
|
|||
/// Compiles and runs a rust program with continuations, runs the full | |||
/// witness generation & verifies it using Pilcom. | |||
pub fn test_continuations(case: &str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should these tests be _64
? or should we also have BB inside here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or maybe _gl
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eventually we should have bb as well, but for now only 64. Do you mean the test name?
Extracted from #1790.
This PR:
CompilerOptions
that encapsulate precompiles and common options, needed by both cli-rs and testsAfter this PR, the riscv-bb PR will simply add analogous 17-bit codegen, runtime and bootloader files.