@@ -105,7 +105,7 @@ impl<AB: InteractionBuilder> Air<AB> for MemcpyIterAir {
105
105
timestamp + timestamp_delta. clone ( ) - timestamp_increase_value. clone ( )
106
106
} ;
107
107
108
- let shift = local. shift [ 0 ] * AB :: Expr :: TWO + local. shift [ 1 ] ;
108
+ let shift = local. shift [ 1 ] * AB :: Expr :: TWO + local. shift [ 0 ] ;
109
109
let is_shift_zero = not :: < AB :: Expr > ( local. is_shift_non_zero ) ;
110
110
let is_shift_one = and :: < AB :: Expr > ( local. shift [ 0 ] , not :: < AB :: Expr > ( local. shift [ 1 ] ) ) ;
111
111
let is_shift_two = and :: < AB :: Expr > ( not :: < AB :: Expr > ( local. shift [ 0 ] ) , local. shift [ 1 ] ) ;
@@ -236,16 +236,16 @@ impl<AB: InteractionBuilder> Air<AB> for MemcpyIterAir {
236
236
237
237
// Read data from memory
238
238
let read_data = [
239
- ( local. data_1 , local . read_aux [ 0 ] ) ,
240
- ( local. data_2 , local . read_aux [ 1 ] ) ,
241
- ( local. data_3 , local . read_aux [ 2 ] ) ,
242
- ( local. data_4 , local . read_aux [ 3 ] ) ,
239
+ local. data_1 ,
240
+ local. data_2 ,
241
+ local. data_3 ,
242
+ local. data_4 ,
243
243
] ;
244
244
245
245
read_data
246
246
. iter ( )
247
247
. enumerate ( )
248
- . for_each ( |( idx, ( data, read_aux ) ) | {
248
+ . for_each ( |( idx, data) | {
249
249
let is_valid_read = if idx == 3 {
250
250
or :: < AB :: Expr > ( local. is_shift_non_zero , local. is_valid_not_start )
251
251
} else {
@@ -260,7 +260,7 @@ impl<AB: InteractionBuilder> Air<AB> for MemcpyIterAir {
260
260
) ,
261
261
* data,
262
262
timestamp_pp ( is_valid_read. clone ( ) ) ,
263
- read_aux,
263
+ & local . read_aux [ idx ] ,
264
264
)
265
265
. eval ( builder, is_valid_read. clone ( ) ) ;
266
266
} ) ;
@@ -468,7 +468,7 @@ where
468
468
} else if i > 0 {
469
469
record. var [ idx] . data [ i - 1 ] [ j - ( 4 - shift as usize ) ]
470
470
} else {
471
- record. var [ idx - 1 ] . data [ i ] [ j - ( 4 - shift as usize ) ]
471
+ record. var [ idx - 1 ] . data [ 3 ] [ j - ( 4 - shift as usize ) ]
472
472
}
473
473
} ) ;
474
474
write_data
@@ -573,7 +573,7 @@ impl<F: PrimeField32> TraceFiller<F> for MemcpyIterFiller {
573
573
num_loops += 1 ;
574
574
num_iters += num_rows;
575
575
}
576
- tracing:: info!( "num_loops: {:?}, num_iters: {:?}" , num_loops, num_iters) ;
576
+ // tracing::info!("num_loops: {:?}, num_iters: {:?}", num_loops, num_iters);
577
577
578
578
chunks
579
579
. par_iter_mut ( )
@@ -715,75 +715,127 @@ impl<F: PrimeField32> TraceFiller<F> for MemcpyIterFiller {
715
715
source -= 16 ;
716
716
len += 16 ;
717
717
718
- if row_idx == 0 && is_start {
719
- tracing:: info!( "first_roooooow, timestamp: {:?}, dest: {:?}, source: {:?}, len_0: {:?}, len_1: {:?}, shift: {:?}, is_valid: {:?}, is_valid_not_start: {:?}, is_shift_non_zero: {:?}, is_boundary: {:?}, data_1: {:?}, data_2: {:?}, data_3: {:?}, data_4: {:?}, read_aux: {:?}, read_aux_lt: {:?}" ,
720
- cols. timestamp. as_canonical_u32( ) ,
721
- cols. dest. as_canonical_u32( ) ,
722
- cols. source. as_canonical_u32( ) ,
723
- cols. len[ 0 ] . as_canonical_u32( ) ,
724
- cols. len[ 1 ] . as_canonical_u32( ) ,
725
- cols. shift[ 1 ] . as_canonical_u32( ) * 2 + cols. shift[ 0 ] . as_canonical_u32( ) ,
726
- cols. is_valid. as_canonical_u32( ) ,
727
- cols. is_valid_not_start. as_canonical_u32( ) ,
728
- cols. is_shift_non_zero. as_canonical_u32( ) ,
729
- cols. is_boundary. as_canonical_u32( ) ,
730
- cols. data_1. map( |x| x. as_canonical_u32( ) ) . to_vec( ) ,
731
- cols. data_2. map( |x| x. as_canonical_u32( ) ) . to_vec( ) ,
732
- cols. data_3. map( |x| x. as_canonical_u32( ) ) . to_vec( ) ,
733
- cols. data_4. map( |x| x. as_canonical_u32( ) ) . to_vec( ) ,
734
- cols. read_aux. map( |x| x. get_base( ) . prev_timestamp. as_canonical_u32( ) ) . to_vec( ) ,
735
- cols. read_aux. map( |x| x. get_base( ) . timestamp_lt_aux. lower_decomp. iter( ) . map( |x| x. as_canonical_u32( ) ) . collect:: <Vec <_>>( ) ) . to_vec( ) ) ;
736
- }
718
+ // if row_idx == 0 && is_start {
719
+ // tracing::info!("first_roooooow, timestamp: {:?}, dest: {:?}, source: {:?}, len_0: {:?}, len_1: {:?}, shift: {:?}, is_valid: {:?}, is_valid_not_start: {:?}, is_shift_non_zero: {:?}, is_boundary: {:?}, data_1: {:?}, data_2: {:?}, data_3: {:?}, data_4: {:?}, read_aux: {:?}, read_aux_lt: {:?}",
720
+ // cols.timestamp.as_canonical_u32(),
721
+ // cols.dest.as_canonical_u32(),
722
+ // cols.source.as_canonical_u32(),
723
+ // cols.len[0].as_canonical_u32(),
724
+ // cols.len[1].as_canonical_u32(),
725
+ // cols.shift[1].as_canonical_u32() * 2 + cols.shift[0].as_canonical_u32(),
726
+ // cols.is_valid.as_canonical_u32(),
727
+ // cols.is_valid_not_start.as_canonical_u32(),
728
+ // cols.is_shift_non_zero.as_canonical_u32(),
729
+ // cols.is_boundary.as_canonical_u32(),
730
+ // cols.data_1.map(|x| x.as_canonical_u32()).to_vec(),
731
+ // cols.data_2.map(|x| x.as_canonical_u32()).to_vec(),
732
+ // cols.data_3.map(|x| x.as_canonical_u32()).to_vec(),
733
+ // cols.data_4.map(|x| x.as_canonical_u32()).to_vec(),
734
+ // cols.read_aux.map(|x| x.get_base().prev_timestamp.as_canonical_u32()).to_vec(),
735
+ // cols.read_aux.map(|x| x.get_base().timestamp_lt_aux.lower_decomp.iter().map(|x| x.as_canonical_u32()).collect::<Vec<_>>()).to_vec());
736
+ // }
737
737
} ) ;
738
738
} ) ;
739
- chunks. iter ( ) . enumerate ( ) . map ( |( row_idx, chunk) | {
740
- chunk. chunks_exact ( width)
741
- . enumerate ( )
742
- . for_each ( |( idx, row) | {
743
- let cols: & MemcpyIterCols < F > = row. borrow ( ) ;
744
- let is_valid_not_start = cols. is_valid_not_start . as_canonical_u32 ( ) != 0 ;
745
- let is_shift_non_zero = cols. is_shift_non_zero . as_canonical_u32 ( ) != 0 ;
746
- let mut bad_col = false ;
747
- cols. read_aux . iter ( ) . enumerate ( ) . for_each ( |( idx, aux) | {
748
- if is_valid_not_start || ( is_shift_non_zero && idx == 3 ) {
749
- let prev_t = aux. get_base ( ) . prev_timestamp . as_canonical_u32 ( ) ;
750
- let curr_t = cols. timestamp . as_canonical_u32 ( ) ;
751
- let ts_lt = aux. get_base ( ) . timestamp_lt_aux . lower_decomp . iter ( )
752
- . enumerate ( )
753
- . fold ( F :: ZERO , |acc, ( i, & val) | {
754
- acc + val * F :: from_canonical_usize ( 1 << ( i * 17 ) )
755
- } ) . as_canonical_u32 ( ) ;
756
- if curr_t + idx as u32 != ts_lt + prev_t + 1 {
757
- bad_col = true ;
758
- }
759
- }
760
- } ) ;
761
- if bad_col {
762
- tracing:: info!( "row_idx: {:?}, idx: {:?}, timestamp: {:?}, dest: {:?}, source: {:?}, len_0: {:?}, len_1: {:?}, shift_0: {:?}, shift_1: {:?}, is_valid: {:?}, is_valid_not_start: {:?}, is_shift_non_zero: {:?}, is_boundary: {:?}, data_1: {:?}, data_2: {:?}, data_3: {:?}, data_4: {:?}, read_aux: {:?}, read_aux_lt: {:?}" ,
763
- row_idx,
764
- idx,
765
- cols. timestamp. as_canonical_u32( ) ,
766
- cols. dest. as_canonical_u32( ) ,
767
- cols. source. as_canonical_u32( ) ,
768
- cols. len[ 0 ] . as_canonical_u32( ) ,
769
- cols. len[ 1 ] . as_canonical_u32( ) ,
770
- cols. shift[ 0 ] . as_canonical_u32( ) ,
771
- cols. shift[ 1 ] . as_canonical_u32( ) ,
772
- cols. is_valid. as_canonical_u32( ) ,
773
- cols. is_valid_not_start. as_canonical_u32( ) ,
774
- cols. is_shift_non_zero. as_canonical_u32( ) ,
775
- cols. is_boundary. as_canonical_u32( ) ,
776
- cols. data_1. map( |x| x. as_canonical_u32( ) ) . to_vec( ) ,
777
- cols. data_2. map( |x| x. as_canonical_u32( ) ) . to_vec( ) ,
778
- cols. data_3. map( |x| x. as_canonical_u32( ) ) . to_vec( ) ,
779
- cols. data_4. map( |x| x. as_canonical_u32( ) ) . to_vec( ) ,
780
- cols. read_aux. map( |x| x. get_base( ) . prev_timestamp. as_canonical_u32( ) ) . to_vec( ) ,
781
- cols. read_aux. map( |x| x. get_base( ) . timestamp_lt_aux. lower_decomp. iter( ) . map( |x| x. as_canonical_u32( ) ) . collect:: <Vec <_>>( ) ) . to_vec( ) ) ;
782
- // cols.write_aux.map(|x| x.get_base().prev_timestamp.as_canonical_u32()).to_vec(),
783
- // cols.write_aux.map(|x| x.prev_data.map(|x| x.as_canonical_u32()).to_vec()).to_vec());
784
- }
785
- } ) ;
786
- } ) ;
739
+
740
+ // chunks.iter().enumerate().for_each(|(row_idx, chunk)| {
741
+ // let mut prv_data = [0; 4];
742
+ // tracing::info!("row_idx: {:?}", row_idx);
743
+
744
+ // chunk.chunks_exact(width)
745
+ // .enumerate()
746
+ // .for_each(|(idx, row)| {
747
+ // let cols: &MemcpyIterCols<F> = row.borrow();
748
+ // let is_valid_not_start = cols.is_valid_not_start.as_canonical_u32() != 0;
749
+ // let is_shift_non_zero = cols.is_shift_non_zero.as_canonical_u32() != 0;
750
+ // let source = cols.source.as_canonical_u32();
751
+ // let dest = cols.dest.as_canonical_u32();
752
+ // let mut bad_col = false;
753
+ // tracing::info!("source: {:?}, dest: {:?}", source, dest);
754
+ // cols.read_aux.iter().enumerate().for_each(|(idx, aux)| {
755
+ // if is_valid_not_start || (is_shift_non_zero && idx == 3) {
756
+ // let prev_t = aux.get_base().prev_timestamp.as_canonical_u32();
757
+ // let curr_t = cols.timestamp.as_canonical_u32();
758
+ // let ts_lt = aux.get_base().timestamp_lt_aux.lower_decomp.iter()
759
+ // .enumerate()
760
+ // .fold(F::ZERO, |acc, (i, &val)| {
761
+ // acc + val * F::from_canonical_usize(1 << (i * 17))
762
+ // }).as_canonical_u32();
763
+ // if curr_t + idx as u32 != ts_lt + prev_t + 1 {
764
+ // bad_col = true;
765
+ // }
766
+ // }
767
+ // if dest + 4 * idx as u32 == 2097216 || dest - 4 * (idx + 1) as u32 == 2097216 || dest + 4 * idx as u32 == 2097280 || dest - 4 * (idx + 1) as u32 == 2097280 {
768
+ // bad_col = true;
769
+ // }
770
+ // });
771
+ // if bad_col {
772
+ // let write_data_pairs = [
773
+ // (prv_data, cols.data_1.map(|x| x.as_canonical_u32())),
774
+ // (cols.data_1.map(|x| x.as_canonical_u32()), cols.data_2.map(|x| x.as_canonical_u32())),
775
+ // (cols.data_2.map(|x| x.as_canonical_u32()), cols.data_3.map(|x| x.as_canonical_u32())),
776
+ // (cols.data_3.map(|x| x.as_canonical_u32()), cols.data_4.map(|x| x.as_canonical_u32())),
777
+ // ];
778
+
779
+ // let shift = cols.shift[1].as_canonical_u32() * 2 + cols.shift[0].as_canonical_u32();
780
+ // let write_data = write_data_pairs
781
+ // .iter()
782
+ // .map(|(prev_data, next_data)| {
783
+ // array::from_fn::<_, MEMCPY_LOOP_NUM_LIMBS, _>(|i| {
784
+ // (shift == 0) as u32 * (next_data[i])
785
+ // + (shift == 1) as u32
786
+ // * (if i < 3 {
787
+ // next_data[i + 1]
788
+ // } else {
789
+ // prev_data[i - 3]
790
+ // })
791
+ // + (shift == 2) as u32
792
+ // * (if i < 2 {
793
+ // next_data[i + 2]
794
+ // } else {
795
+ // prev_data[i - 2]
796
+ // })
797
+ // + (shift == 3) as u32
798
+ // * (if i < 1 {
799
+ // next_data[i + 3]
800
+ // } else {
801
+ // prev_data[i - 1]
802
+ // })
803
+ // })
804
+ // })
805
+ // .collect::<Vec<_>>();
806
+
807
+
808
+
809
+
810
+ // tracing::info!("row_idx: {:?}, idx: {:?}, timestamp: {:?}, dest: {:?}, source: {:?}, len_0: {:?}, len_1: {:?}, shift_0: {:?}, shift_1: {:?}, is_valid: {:?}, is_valid_not_start: {:?}, is_shift_non_zero: {:?}, is_boundary: {:?}, write_data: {:?}, prv_data: {:?}, data_1: {:?}, data_2: {:?}, data_3: {:?}, data_4: {:?}, read_aux: {:?}, read_aux_lt: {:?}, write_aux: {:?}, write_aux_lt: {:?}, write_aux_prev_data: {:?}",
811
+ // row_idx,
812
+ // idx,
813
+ // cols.timestamp.as_canonical_u32(),
814
+ // cols.dest.as_canonical_u32(),
815
+ // cols.source.as_canonical_u32(),
816
+ // cols.len[0].as_canonical_u32(),
817
+ // cols.len[1].as_canonical_u32(),
818
+ // cols.shift[0].as_canonical_u32(),
819
+ // cols.shift[1].as_canonical_u32(),
820
+ // cols.is_valid.as_canonical_u32(),
821
+ // cols.is_valid_not_start.as_canonical_u32(),
822
+ // cols.is_shift_non_zero.as_canonical_u32(),
823
+ // cols.is_boundary.as_canonical_u32(),
824
+ // write_data,
825
+ // prv_data,
826
+ // cols.data_1.map(|x| x.as_canonical_u32()).to_vec(),
827
+ // cols.data_2.map(|x| x.as_canonical_u32()).to_vec(),
828
+ // cols.data_3.map(|x| x.as_canonical_u32()).to_vec(),
829
+ // cols.data_4.map(|x| x.as_canonical_u32()).to_vec(),
830
+ // cols.read_aux.map(|x| x.get_base().prev_timestamp.as_canonical_u32()).to_vec(),
831
+ // cols.read_aux.map(|x| x.get_base().timestamp_lt_aux.lower_decomp.iter().map(|x| x.as_canonical_u32()).collect::<Vec<_>>()).to_vec(),
832
+ // cols.write_aux.map(|x| x.get_base().prev_timestamp.as_canonical_u32()).to_vec(),
833
+ // cols.write_aux.map(|x| x.get_base().timestamp_lt_aux.lower_decomp.iter().map(|x| x.as_canonical_u32()).collect::<Vec<_>>()).to_vec(),
834
+ // cols.write_aux.map(|x| x.prev_data.map(|x| x.as_canonical_u32()).to_vec()).to_vec());
835
+ // }
836
+ // prv_data = cols.data_4.map(|x| x.as_canonical_u32());
837
+ // });
838
+ // });
787
839
// assert!(false);
788
840
}
789
841
}
0 commit comments