Skip to content

Commit 2044a35

Browse files
committed
finish
1 parent 3e1c98c commit 2044a35

File tree

5 files changed

+54
-2
lines changed

5 files changed

+54
-2
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions/native/circuit/cuda/include/native/poseidon2.cuh

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,43 @@ template <typename T> struct SimplePoseidonSpecificCols {
6262
MemoryWriteAuxCols<T, CHUNK> write_data_2;
6363
};
6464

65+
template <typename T> struct MultiObserveCols {
66+
T pc;
67+
T final_timestamp_increment;
68+
T state_ptr;
69+
T input_ptr;
70+
T init_pos;
71+
T len;
72+
T input_register_1;
73+
T input_register_2;
74+
T input_register_3;
75+
T output_register;
76+
T is_first;
77+
T is_last;
78+
T curr_len;
79+
T start_idx;
80+
T end_idx;
81+
T aux_after_start[CHUNK];
82+
T aux_before_end[CHUNK];
83+
T aux_read_enabled[CHUNK];
84+
MemoryReadAuxCols<T> read_data[CHUNK];
85+
MemoryWriteAuxCols<T, 1> write_data[CHUNK];
86+
T data[CHUNK];
87+
T should_permute;
88+
MemoryWriteAuxCols<T, CHUNK * 2> write_sponge_state;
89+
MemoryWriteAuxCols<T, 1> write_final_idx;
90+
T final_idx;
91+
};
92+
6593
template <typename T> constexpr T constexpr_max(T a, T b) { return a > b ? a : b; }
6694

6795
constexpr size_t COL_SPECIFIC_WIDTH = constexpr_max(
6896
sizeof(TopLevelSpecificCols<uint8_t>),
6997
constexpr_max(
7098
sizeof(InsideRowSpecificCols<uint8_t>),
71-
sizeof(SimplePoseidonSpecificCols<uint8_t>)
99+
constexpr_max(
100+
sizeof(SimplePoseidonSpecificCols<uint8_t>),
101+
sizeof(MultiObserveCols<uint8_t>)
102+
)
72103
)
73104
);

extensions/native/circuit/src/poseidon2/cuda.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ impl<const SBOX_REGISTERS: usize> Chip<DenseRecordArena, GpuBackend>
5353
chunk_start.push(row_idx as u32);
5454
if cols.simple.is_one() {
5555
row_idx += 1;
56+
} else if cols.multi_observe_row.is_one() {
57+
let num_rows = cols.inner.export.as_canonical_u32() as usize;
58+
row_idx += num_rows;
5659
} else {
5760
let num_non_inside_row = cols.inner.export.as_canonical_u32() as usize;
5861
let non_inside_start = start + (num_non_inside_row - 1) * width;

extensions/native/recursion/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ repository.workspace = true
88

99
[dependencies]
1010
openvm-stark-backend = { workspace = true }
11+
openvm-cuda-backend = { workspace = true, optional = true }
1112
openvm-native-circuit = { workspace = true, features = ["test-utils"] }
1213
openvm-native-compiler = { workspace = true }
1314
openvm-native-compiler-derive = { workspace = true }
@@ -58,4 +59,4 @@ parallel = ["openvm-stark-backend/parallel"]
5859
mimalloc = ["openvm-stark-backend/mimalloc"]
5960
jemalloc = ["openvm-stark-backend/jemalloc"]
6061
nightly-features = ["openvm-circuit/nightly-features"]
61-
cuda = ["openvm-circuit/cuda", "openvm-native-circuit/cuda"]
62+
cuda = ["openvm-circuit/cuda", "openvm-native-circuit/cuda", "dep:openvm-cuda-backend"]

extensions/native/recursion/tests/recursion.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use openvm_circuit::{
66
},
77
utils::{air_test_impl, TestStarkEngine},
88
};
9+
#[cfg(feature = "cuda")]
10+
use openvm_cuda_backend::engine::GpuBabyBearPoseidon2Engine;
911
use openvm_native_circuit::{
1012
execute_program_with_config, test_native_config, NativeBuilder, NativeConfig,
1113
};
@@ -211,8 +213,22 @@ fn test_multi_observe() {
211213
config.system.memory_config.max_access_adapter_n = 16;
212214

213215
let vb = NativeBuilder::default();
216+
#[cfg(not(feature = "cuda"))]
214217
air_test_impl::<BabyBearPoseidon2Engine, _>(fri_params, vb, config, program, vec![], 1, true)
215218
.unwrap();
219+
#[cfg(feature = "cuda")]
220+
{
221+
air_test_impl::<GpuBabyBearPoseidon2Engine, _>(
222+
fri_params,
223+
vb,
224+
config,
225+
program,
226+
vec![],
227+
1,
228+
true,
229+
)
230+
.unwrap();
231+
}
216232
}
217233

218234
fn build_test_program<C: Config>(builder: &mut Builder<C>) {

0 commit comments

Comments
 (0)