From 89969ad1f5cb822f611862518f7648dbc090d9ea Mon Sep 17 00:00:00 2001 From: Leo Date: Fri, 29 Nov 2024 19:21:03 +0100 Subject: [PATCH] Fix some tests (#2178) --- riscv/src/large_field/runtime.rs | 2 +- riscv/src/small_field/code_gen.rs | 4 ++-- riscv/src/small_field/runtime.rs | 4 ++-- riscv/tests/common/mod.rs | 24 ++++++++++++------------ riscv/tests/riscv.rs | 8 ++++---- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/riscv/src/large_field/runtime.rs b/riscv/src/large_field/runtime.rs index d2c6bff75a..6124ce851b 100644 --- a/riscv/src/large_field/runtime.rs +++ b/riscv/src/large_field/runtime.rs @@ -331,7 +331,7 @@ impl Runtime { "std::machines::large_field::arith::Arith", None, "arith", - vec![], + vec!["MIN_DEGREE", "MAIN_MAX_DEGREE"], [ format!( "instr affine_256 link ~> {};", diff --git a/riscv/src/small_field/code_gen.rs b/riscv/src/small_field/code_gen.rs index 48aefa7edc..4506a54401 100644 --- a/riscv/src/small_field/code_gen.rs +++ b/riscv/src/small_field/code_gen.rs @@ -376,7 +376,7 @@ fn preamble(field: KnownField, runtime: &Runtime, with_bootloader: bool) -> Stri // Jump to the address in register XL and store the return program counter in register WL. instr jump_dyn XL, WL link ~> (tmp1_h, tmp1_l) = regs.mload(0, XL, STEP) - link ~> regs.mstore(0, WL, STEP, tmp2_h, tmp2_l) + link ~> regs.mstore(0, WL, STEP + 3, tmp2_h, tmp2_l) // pc is capped at 24 bits, so for this instruction // we restrict the higher limbs to 1 byte link => byte.check(tmp1_h) @@ -568,7 +568,7 @@ fn preamble(field: KnownField, runtime: &Runtime, with_bootloader: bool) -> Stri // Stores 1 in register WL if val(XL) == val(YL), otherwise stores 0. instr is_not_equal XL, YL, WL link ~> (tmp1_h, tmp1_l) = regs.mload(0, XL, STEP) - link ~> (tmp2_h, tmp2_l) = regs.mload(0, YL, STEP) + link ~> (tmp2_h, tmp2_l) = regs.mload(0, YL, STEP + 1) link ~> (tmp3_h, tmp3_l) = add_sub.sub(tmp1_h, tmp1_l, tmp2_h, tmp2_l) link ~> regs.mstore(0, WL, STEP + 2, 0, 1 - XXIsZero) { diff --git a/riscv/src/small_field/runtime.rs b/riscv/src/small_field/runtime.rs index a67c3ecd83..809f6fa979 100644 --- a/riscv/src/small_field/runtime.rs +++ b/riscv/src/small_field/runtime.rs @@ -76,14 +76,14 @@ impl Runtime { [ r#"instr shl XL, YL, ZH, ZL, WL link ~> (tmp1_h, tmp1_l) = regs.mload(0, XL, STEP) - link ~> (tmp2_h, tmp2_l) = regs.mload(0, YL, STEP) + link ~> (tmp2_h, tmp2_l) = regs.mload(0, YL, STEP + 1) link ~> (tmp3_h, tmp3_l) = add_sub.add(tmp2_h, tmp2_l, ZH, ZL) link ~> (tmp4_l, tmp4_h) = shift.shl(tmp1_l, tmp1_h, tmp3_l) link ~> regs.mstore(0, WL, STEP + 3, tmp4_h, tmp4_l); "#, r#"instr shr XL, YL, ZH, ZL, WL link ~> (tmp1_h, tmp1_l) = regs.mload(0, XL, STEP) - link ~> (tmp2_h, tmp2_l) = regs.mload(0, YL, STEP) + link ~> (tmp2_h, tmp2_l) = regs.mload(0, YL, STEP + 1) link ~> (tmp3_h, tmp3_l) = add_sub.add(tmp2_h, tmp2_l, ZH, ZL) link ~> (tmp4_l, tmp4_h) = shift.shr(tmp1_l, tmp1_h, tmp3_l) link ~> regs.mstore(0, WL, STEP + 3, tmp4_h, tmp4_l); diff --git a/riscv/tests/common/mod.rs b/riscv/tests/common/mod.rs index ba33dac17b..be4f32bfa7 100644 --- a/riscv/tests/common/mod.rs +++ b/riscv/tests/common/mod.rs @@ -31,18 +31,6 @@ pub fn verify_riscv_asm_string = - unsafe { std::mem::transmute(pipeline.clone()) }; - run_pilcom_with_backend_variant(pipeline_gl, BackendVariant::Composite).unwrap(); - } - // Test with the fast RISCV executor. // TODO remove the guard once the executor is implemented for BB if T::known_field().unwrap() == KnownField::GoldilocksField { @@ -56,6 +44,18 @@ pub fn verify_riscv_asm_string = + unsafe { std::mem::transmute(pipeline.clone()) }; + run_pilcom_with_backend_variant(pipeline_gl, BackendVariant::Composite).unwrap(); + } + test_plonky3_pipeline::(pipeline.clone()); // verify executor generated witness diff --git a/riscv/tests/riscv.rs b/riscv/tests/riscv.rs index 7582ccc137..4b1dd216a9 100644 --- a/riscv/tests/riscv.rs +++ b/riscv/tests/riscv.rs @@ -495,7 +495,7 @@ fn features_with_options(options: CompilerOptions) { &from_elf, &[expected.into()], None, - true, + false, ); // "add_two" @@ -513,7 +513,7 @@ fn features_with_options(options: CompilerOptions) { &from_elf, &[expected.into()], None, - true, + false, ); // "add_two" and "add_three" @@ -531,7 +531,7 @@ fn features_with_options(options: CompilerOptions) { &from_elf, &[expected.into()], None, - true, + false, ); } @@ -615,12 +615,12 @@ fn many_chunks_memory() { } fn verify_riscv_crate(case: &str, inputs: &[u64], executor_witgen: bool) { - verify_riscv_crate_bb(case, inputs.iter().map(|&x| x.into()).collect()); verify_riscv_crate_gl( case, inputs.iter().map(|&x| x.into()).collect(), executor_witgen, ); + verify_riscv_crate_bb(case, inputs.iter().map(|&x| x.into()).collect()); } fn verify_riscv_crate_bb(case: &str, inputs: Vec) {