@@ -36,50 +36,59 @@ struct AluNativeAdapter {
3636 __device__ AluNativeAdapter (VariableRangeChecker rc, uint32_t timestamp_max_bits)
3737 : mem_helper(rc, timestamp_max_bits) {}
3838
39- __device__ void fill_trace_row (RowSlice row, AluNativeAdapterRecord const &rec) {
40- COL_WRITE_VALUE (row, AluNativeAdapterCols, from_state.pc , Fp (rec.from_pc ));
41- COL_WRITE_VALUE (row, AluNativeAdapterCols, from_state.timestamp , Fp (rec.from_timestamp ));
42- COL_WRITE_VALUE (row, AluNativeAdapterCols, a_pointer, Fp::fromRaw (rec.a_ptr ));
43- COL_WRITE_VALUE (row, AluNativeAdapterCols, b_pointer, Fp::fromRaw (rec.b ));
44- COL_WRITE_VALUE (row, AluNativeAdapterCols, c_pointer, Fp::fromRaw (rec.c ));
45-
46- // Fill read auxiliary columns for two operands (b and c)
47- const Fp native_as = Fp (AS_NATIVE);
48- for (int i = 0 ; i < 2 ; i++) {
49- const uint32_t prev_timestamp = rec.reads_aux [i].prev_timestamp ;
50- const uint32_t current_timestamp = rec.from_timestamp + i;
51- RowSlice aux_slice = row.slice_from (COL_INDEX (AluNativeAdapterCols, reads_aux[i]));
52-
53- if (prev_timestamp == UINT32_MAX) {
54- // Immediate
55- mem_helper.fill (aux_slice, 0 , current_timestamp);
56- COL_WRITE_VALUE (row, AluNativeAdapterCols, reads_aux[i].is_zero_aux , Fp::zero ());
57- COL_WRITE_VALUE (row, AluNativeAdapterCols, reads_aux[i].is_immediate , Fp::one ());
58- if (i == 0 ) {
59- COL_WRITE_VALUE (row, AluNativeAdapterCols, e_as, Fp (AS_IMMEDIATE));
39+ __device__ void fill_trace_row (RowSlice row, AluNativeAdapterRecord const &rec, RowSlice apc_row, uint32_t *sub, uint32_t offset) {
40+ if !apc_row.is_null () {
41+ COL_WRITE_VALUE_APC (apc_row, AluNativeAdapterCols, from_state.timestamp , Fp (rec.from_timestamp ), sub, offset);
42+ COL_WRITE_VALUE_APC (row, AluNativeAdapterCols, a_pointer, Fp::fromRaw (rec.a_ptr ), sub, offset);
43+ COL_WRITE_VALUE_APC (row, AluNativeAdapterCols, b_pointer, Fp::fromRaw (rec.b ), sub, offset);
44+ COL_WRITE_VALUE_APC (row, AluNativeAdapterCols, c_pointer, Fp::fromRaw (rec.c ), sub, offset);
45+
46+ // TODO: adapt the rest similar to above
47+ } else {
48+ COL_WRITE_VALUE (row, AluNativeAdapterCols, from_state.timestamp , Fp (rec.from_timestamp ));
49+ COL_WRITE_VALUE (row, AluNativeAdapterCols, a_pointer, Fp::fromRaw (rec.a_ptr ));
50+ COL_WRITE_VALUE (row, AluNativeAdapterCols, b_pointer, Fp::fromRaw (rec.b ));
51+ COL_WRITE_VALUE (row, AluNativeAdapterCols, c_pointer, Fp::fromRaw (rec.c ));
52+
53+ // Fill read auxiliary columns for two operands (b and c)
54+ const Fp native_as = Fp (AS_NATIVE);
55+ for (int i = 0 ; i < 2 ; i++) {
56+ const uint32_t prev_timestamp = rec.reads_aux [i].prev_timestamp ;
57+ const uint32_t current_timestamp = rec.from_timestamp + i;
58+ RowSlice aux_slice = row.slice_from (COL_INDEX (AluNativeAdapterCols, reads_aux[i]));
59+
60+ if (prev_timestamp == UINT32_MAX) {
61+ // Immediate
62+ mem_helper.fill (aux_slice, 0 , current_timestamp);
63+ COL_WRITE_VALUE (row, AluNativeAdapterCols, reads_aux[i].is_zero_aux , Fp::zero ());
64+ COL_WRITE_VALUE (row, AluNativeAdapterCols, reads_aux[i].is_immediate , Fp::one ());
65+ if (i == 0 ) {
66+ COL_WRITE_VALUE (row, AluNativeAdapterCols, e_as, Fp (AS_IMMEDIATE));
67+ } else {
68+ COL_WRITE_VALUE (row, AluNativeAdapterCols, f_as, Fp (AS_IMMEDIATE));
69+ }
6070 } else {
61- COL_WRITE_VALUE (row, AluNativeAdapterCols, f_as, Fp (AS_IMMEDIATE));
62- }
63- } else {
64- // Memory
65- mem_helper.fill (aux_slice, prev_timestamp, current_timestamp);
66- COL_WRITE_VALUE (
67- row, AluNativeAdapterCols, reads_aux[i].is_zero_aux , inv (native_as)
68- );
69- COL_WRITE_VALUE (row, AluNativeAdapterCols, reads_aux[i].is_immediate , Fp::zero ());
70- if (i == 0 ) {
71- COL_WRITE_VALUE (row, AluNativeAdapterCols, e_as, native_as);
72- } else {
73- COL_WRITE_VALUE (row, AluNativeAdapterCols, f_as, native_as);
71+ // Memory
72+ mem_helper.fill (aux_slice, prev_timestamp, current_timestamp);
73+ COL_WRITE_VALUE (
74+ row, AluNativeAdapterCols, reads_aux[i].is_zero_aux , inv (native_as)
75+ );
76+ COL_WRITE_VALUE (row, AluNativeAdapterCols, reads_aux[i].is_immediate , Fp::zero ());
77+ if (i == 0 ) {
78+ COL_WRITE_VALUE (row, AluNativeAdapterCols, e_as, native_as);
79+ } else {
80+ COL_WRITE_VALUE (row, AluNativeAdapterCols, f_as, native_as);
81+ }
7482 }
7583 }
84+
85+ COL_WRITE_ARRAY (row, AluNativeAdapterCols, write_aux.prev_data , rec.write_aux .prev_data );
86+ mem_helper.fill (
87+ row.slice_from (COL_INDEX (AluNativeAdapterCols, write_aux)),
88+ rec.write_aux .prev_timestamp ,
89+ rec.from_timestamp + 2
90+ );
7691 }
77-
78- COL_WRITE_ARRAY (row, AluNativeAdapterCols, write_aux.prev_data , rec.write_aux .prev_data );
79- mem_helper.fill (
80- row.slice_from (COL_INDEX (AluNativeAdapterCols, write_aux)),
81- rec.write_aux .prev_timestamp ,
82- rec.from_timestamp + 2
83- );
92+
8493 }
8594};
0 commit comments