Skip to content

Commit 44d3efe

Browse files
876polclaude
andcommitted
feat: update cuda tracegen for boundary chip
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3d5b7c6 commit 44d3efe

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

crates/vm/src/system/cuda/memory.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::sync::Arc;
22

33
use openvm_circuit::{
4-
arch::{AddressSpaceHostLayout, DenseRecordArena, MemoryConfig, ADDR_SPACE_OFFSET},
4+
arch::{AddressSpaceHostLayout, CONST_BLOCK_SIZE, DenseRecordArena, MemoryConfig, ADDR_SPACE_OFFSET},
55
system::{
66
memory::{online::LinearMemory, AddressMap, TimestampedValues},
77
TouchedMemory,
@@ -151,15 +151,15 @@ impl MemoryInventoryGPU {
151151
mem.tracing_info("boundary finalize");
152152
let (touched_memory, empty) = if partition.is_empty() {
153153
let leftmost_values = 'left: {
154-
let mut res = [F::ZERO; DIGEST_WIDTH];
154+
let mut res = [F::ZERO; CONST_BLOCK_SIZE];
155155
if persistent.initial_memory[ADDR_SPACE_OFFSET as usize].is_empty() {
156156
break 'left res;
157157
}
158158
let layout = &persistent.merkle_tree.mem_config().addr_spaces
159159
[ADDR_SPACE_OFFSET as usize]
160160
.layout;
161161
let one_cell_size = layout.size();
162-
let values = vec![0u8; one_cell_size * DIGEST_WIDTH];
162+
let values = vec![0u8; one_cell_size * CONST_BLOCK_SIZE];
163163
unsafe {
164164
cuda_memcpy::<true, false>(
165165
values.as_ptr() as *mut std::ffi::c_void,
@@ -168,7 +168,7 @@ impl MemoryInventoryGPU {
168168
values.len(),
169169
)
170170
.unwrap();
171-
for i in 0..DIGEST_WIDTH {
171+
for i in 0..CONST_BLOCK_SIZE {
172172
res[i] = layout.to_field::<F>(&values[i * one_cell_size..]);
173173
}
174174
}

crates/vm/src/system/cuda/merkle_tree/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{ffi::c_void, sync::Arc};
22

33
use openvm_circuit::{
4-
arch::{MemoryConfig, ADDR_SPACE_OFFSET},
4+
arch::{MemoryConfig, ADDR_SPACE_OFFSET, CONST_BLOCK_SIZE},
55
system::memory::{merkle::MemoryMerkleCols, TimestampedEquipartition},
66
utils::next_power_of_two_or_zero,
77
};
@@ -26,7 +26,9 @@ pub mod cuda;
2626
use cuda::merkle_tree::*;
2727

2828
type H = [F; DIGEST_WIDTH];
29-
pub const TIMESTAMPED_BLOCK_WIDTH: usize = 11;
29+
/// Width of `((u32, u32), TimestampedValues<F, CONST_BLOCK_SIZE>)` in u32 units.
30+
/// = 2 (key) + 1 (timestamp) + CONST_BLOCK_SIZE (values)
31+
pub const TIMESTAMPED_BLOCK_WIDTH: usize = 3 + CONST_BLOCK_SIZE;
3032

3133
/// A Merkle subtree stored in a single flat buffer, combining a vertical path and a heap-ordered
3234
/// binary tree.
@@ -393,7 +395,7 @@ impl MemoryMerkleTree {
393395
/// An auxiliary function to calculate the required number of rows for the merkle trace.
394396
pub fn calculate_unpadded_height(
395397
&self,
396-
touched_memory: &TimestampedEquipartition<F, DIGEST_WIDTH>,
398+
touched_memory: &TimestampedEquipartition<F, CONST_BLOCK_SIZE>,
397399
) -> usize {
398400
let md = self.mem_config.memory_dimensions();
399401
let tree_height = md.overall_height();

0 commit comments

Comments
 (0)