@@ -90,8 +90,18 @@ impl<F: Field> MatrixRecordArena<F> {
90
90
}
91
91
92
92
pub fn alloc_buffer ( & mut self , num_rows : usize ) -> & mut [ u8 ] {
93
- let start = self . trace_offset ;
93
+ let start: usize = self . trace_offset ;
94
+
94
95
self . trace_offset += num_rows * self . width ;
96
+ if start >= self . trace_buffer . len ( ) {
97
+ eprintln ! ( "crates/vm/src/arch/record_arena.rs::alloc_buffer: start >= self.trace_buffer.len()" ) ;
98
+ eprintln ! ( "start = {:?}" , start) ;
99
+ eprintln ! ( "self.trace_offset = {:?}" , self . trace_offset) ;
100
+ eprintln ! ( "self.trace_buffer.len() = {:?}" , self . trace_buffer. len( ) ) ;
101
+ eprintln ! ( "self.width = {:?}" , self . width) ;
102
+ eprintln ! ( "num_rows = {:?}" , num_rows) ;
103
+ }
104
+
95
105
let row_slice = & mut self . trace_buffer [ start..self . trace_offset ] ;
96
106
let size = size_of_val ( row_slice) ;
97
107
let ptr = row_slice as * mut [ F ] as * mut u8 ;
@@ -111,6 +121,15 @@ impl<F: Field> Arena for MatrixRecordArena<F> {
111
121
fn with_capacity ( height : usize , width : usize ) -> Self {
112
122
let height = next_power_of_two_or_zero ( height) ;
113
123
let trace_buffer = F :: zero_vec ( height * width) ;
124
+ eprintln ! (
125
+ "crates/vm/src/arch/record_arena.rs::with_capacity: with capacity called, height = {:?}, width = {:?}" ,
126
+ height, width
127
+ ) ;
128
+ // height * width is wrong?
129
+ // i think bug is here? on constructor the trace buffer
130
+ // isn't allocated to be the correct size
131
+ // eprintln!("height, width = {:?}, {:?}", height, width);
132
+ // eprintln!("trace_buffer.len() = {:?}", trace_buffer.len());
114
133
Self {
115
134
trace_buffer,
116
135
width,
@@ -133,6 +152,10 @@ impl<F: Field> RowMajorMatrixArena<F> for MatrixRecordArena<F> {
133
152
fn set_capacity ( & mut self , trace_height : usize ) {
134
153
let size = trace_height * self . width ;
135
154
// PERF: use memset
155
+ // eprintln!("set_capacity called");
156
+ // eprintln!("size = {:?}", size);
157
+ // eprintln!("trace_height = {:?}", trace_height);
158
+ // eprintln!("self.width = {:?}", self.width);
136
159
self . trace_buffer . resize ( size, F :: ZERO ) ;
137
160
}
138
161
@@ -145,6 +168,7 @@ impl<F: Field> RowMajorMatrixArena<F> for MatrixRecordArena<F> {
145
168
}
146
169
147
170
fn into_matrix ( mut self ) -> RowMajorMatrix < F > {
171
+ // eprintln!("into_matrix called");
148
172
let width = self . width ( ) ;
149
173
assert_eq ! ( self . trace_offset( ) % width, 0 ) ;
150
174
let rows_used = self . trace_offset ( ) / width;
@@ -158,6 +182,7 @@ impl<F: Field> RowMajorMatrixArena<F> for MatrixRecordArena<F> {
158
182
let height = self . trace_buffer . len ( ) / width;
159
183
assert ! ( height. is_power_of_two( ) || height == 0 ) ;
160
184
}
185
+ // eprintln!("into_matrix done");
161
186
RowMajorMatrix :: new ( self . trace_buffer , self . width )
162
187
}
163
188
}
@@ -534,7 +559,12 @@ where
534
559
[ u8 ] : CustomBorrow < ' a , R , MultiRowLayout < M > > ,
535
560
{
536
561
fn alloc ( & ' a mut self , layout : MultiRowLayout < M > ) -> R {
537
- let buffer = self . alloc_buffer ( layout. metadata . get_num_rows ( ) ) ;
562
+ // alloc override of the alloc function in the trait
563
+ // eprintln!(
564
+ // "layout.metadata.get_num_rows() in alloc override = {:?}",
565
+ // layout.metadata.get_num_rows()
566
+ // );
567
+ let buffer = self . alloc_buffer ( layout. metadata . get_num_rows ( ) ) ; //allocating 2 rows
538
568
let record: R = buffer. custom_borrow ( layout) ;
539
569
record
540
570
}
0 commit comments