Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
data_copy_impl.hpp
Go to the documentation of this file.
1// AUTOGENERATED FILE
2#pragma once
3
6
7namespace bb::avm2 {
8
9template <typename FF_>
10template <typename ContainerOverSubrelations, typename AllEntities>
11void data_copyImpl<FF_>::accumulate(ContainerOverSubrelations& evals,
12 const AllEntities& in,
13 [[maybe_unused]] const RelationParameters<FF_>&,
14 [[maybe_unused]] const FF_& scaling_factor)
15{
16 using C = ColumnAndShifts;
17
18 const auto constants_AVM_MEMORY_SIZE = FF(4294967296UL);
19 const auto data_copy_LATCH_CONDITION = in.get(C::data_copy_end) + in.get(C::precomputed_first_row);
20 const auto data_copy_READ_INDEX_UPPER_BOUND =
21 (in.get(C::data_copy_src_data_size) - in.get(C::data_copy_offset_plus_size)) *
22 in.get(C::data_copy_offset_plus_size_is_gt) +
23 in.get(C::data_copy_offset_plus_size);
24 const auto data_copy_SEL_PERFORM_COPY =
25 in.get(C::data_copy_start_no_err) * (FF(1) - in.get(C::data_copy_sel_write_count_is_zero)) +
26 in.get(C::data_copy_sel) * (FF(1) - in.get(C::data_copy_start));
27 const auto data_copy_WRITE_COUNT_MINUS_ONE = (in.get(C::data_copy_copy_size) - FF(1));
28
29 {
30 using View = typename std::tuple_element_t<0, ContainerOverSubrelations>::View;
31 auto tmp = static_cast<View>(in.get(C::data_copy_sel)) * (FF(1) - static_cast<View>(in.get(C::data_copy_sel)));
32 std::get<0>(evals) += (tmp * scaling_factor);
33 }
34 {
35 using View = typename std::tuple_element_t<1, ContainerOverSubrelations>::View;
36 auto tmp = static_cast<View>(in.get(C::data_copy_sel_cd_copy)) *
37 (FF(1) - static_cast<View>(in.get(C::data_copy_sel_cd_copy)));
38 std::get<1>(evals) += (tmp * scaling_factor);
39 }
40 {
41 using View = typename std::tuple_element_t<2, ContainerOverSubrelations>::View;
42 auto tmp =
43 static_cast<View>(in.get(C::data_copy_start)) * (FF(1) - static_cast<View>(in.get(C::data_copy_start)));
44 std::get<2>(evals) += (tmp * scaling_factor);
45 }
46 {
47 using View = typename std::tuple_element_t<3, ContainerOverSubrelations>::View;
48 auto tmp = static_cast<View>(in.get(C::data_copy_end)) * (FF(1) - static_cast<View>(in.get(C::data_copy_end)));
49 std::get<3>(evals) += (tmp * scaling_factor);
50 }
51 { // SEL_ON_START_OR_END
52 using View = typename std::tuple_element_t<4, ContainerOverSubrelations>::View;
53 auto tmp = (static_cast<View>(in.get(C::data_copy_start)) + static_cast<View>(in.get(C::data_copy_end))) *
54 (FF(1) - static_cast<View>(in.get(C::data_copy_sel)));
55 std::get<4>(evals) += (tmp * scaling_factor);
56 }
57 { // TRACE_CONTINUITY
58 using View = typename std::tuple_element_t<5, ContainerOverSubrelations>::View;
59 auto tmp = (FF(1) - CView(data_copy_LATCH_CONDITION)) *
60 (static_cast<View>(in.get(C::data_copy_sel)) - static_cast<View>(in.get(C::data_copy_sel_shift)));
61 std::get<5>(evals) += (tmp * scaling_factor);
62 }
63 { // START_AFTER_LATCH
64 using View = typename std::tuple_element_t<6, ContainerOverSubrelations>::View;
65 auto tmp = static_cast<View>(in.get(C::data_copy_sel_shift)) *
66 (static_cast<View>(in.get(C::data_copy_start_shift)) - CView(data_copy_LATCH_CONDITION));
67 std::get<6>(evals) += (tmp * scaling_factor);
68 }
69 {
70 using View = typename std::tuple_element_t<7, ContainerOverSubrelations>::View;
71 auto tmp =
72 (static_cast<View>(in.get(C::data_copy_sel_cd_copy_start)) -
73 static_cast<View>(in.get(C::data_copy_start)) * static_cast<View>(in.get(C::data_copy_sel_cd_copy)));
74 std::get<7>(evals) += (tmp * scaling_factor);
75 }
76 {
77 using View = typename std::tuple_element_t<8, ContainerOverSubrelations>::View;
78 auto tmp = (static_cast<View>(in.get(C::data_copy_sel_rd_copy_start)) -
79 static_cast<View>(in.get(C::data_copy_start)) *
80 (FF(1) - static_cast<View>(in.get(C::data_copy_sel_cd_copy))));
81 std::get<8>(evals) += (tmp * scaling_factor);
82 }
83 {
84 using View = typename std::tuple_element_t<9, ContainerOverSubrelations>::View;
85 auto tmp =
86 (static_cast<View>(in.get(C::data_copy_offset_plus_size)) -
87 static_cast<View>(in.get(C::data_copy_start)) *
88 (static_cast<View>(in.get(C::data_copy_offset)) + static_cast<View>(in.get(C::data_copy_copy_size))));
89 std::get<9>(evals) += (tmp * scaling_factor);
90 }
91 {
92 using View = typename std::tuple_element_t<10, ContainerOverSubrelations>::View;
93 auto tmp = static_cast<View>(in.get(C::data_copy_start)) *
94 (static_cast<View>(in.get(C::data_copy_mem_size)) - CView(constants_AVM_MEMORY_SIZE));
95 std::get<10>(evals) += (tmp * scaling_factor);
96 }
97 {
98 using View = typename std::tuple_element_t<11, ContainerOverSubrelations>::View;
99 auto tmp = (static_cast<View>(in.get(C::data_copy_read_addr_upper_bound)) -
100 static_cast<View>(in.get(C::data_copy_start)) *
101 (static_cast<View>(in.get(C::data_copy_src_addr)) + CView(data_copy_READ_INDEX_UPPER_BOUND)));
102 std::get<11>(evals) += (tmp * scaling_factor);
103 }
104 {
105 using View = typename std::tuple_element_t<12, ContainerOverSubrelations>::View;
106 auto tmp = (static_cast<View>(in.get(C::data_copy_clamped_read_index_upper_bound)) -
107 static_cast<View>(in.get(C::data_copy_start)) *
108 (CView(data_copy_READ_INDEX_UPPER_BOUND) *
109 (FF(1) - static_cast<View>(in.get(C::data_copy_src_reads_exceed_mem))) +
110 (static_cast<View>(in.get(C::data_copy_mem_size)) -
111 static_cast<View>(in.get(C::data_copy_src_addr))) *
112 static_cast<View>(in.get(C::data_copy_src_reads_exceed_mem))));
113 std::get<12>(evals) += (tmp * scaling_factor);
114 }
115 {
116 using View = typename std::tuple_element_t<13, ContainerOverSubrelations>::View;
117 auto tmp =
118 (static_cast<View>(in.get(C::data_copy_write_addr_upper_bound)) -
119 static_cast<View>(in.get(C::data_copy_start)) * (static_cast<View>(in.get(C::data_copy_dst_addr)) +
120 static_cast<View>(in.get(C::data_copy_copy_size))));
121 std::get<13>(evals) += (tmp * scaling_factor);
122 }
123 {
124 using View = typename std::tuple_element_t<14, ContainerOverSubrelations>::View;
125 auto tmp = (static_cast<View>(in.get(C::data_copy_start_no_err)) -
126 static_cast<View>(in.get(C::data_copy_start)) *
127 (FF(1) - static_cast<View>(in.get(C::data_copy_dst_out_of_range_err))));
128 std::get<14>(evals) += (tmp * scaling_factor);
129 }
130 {
131 using View = typename std::tuple_element_t<15, ContainerOverSubrelations>::View;
132 auto tmp = static_cast<View>(in.get(C::data_copy_sel_write_count_is_zero)) *
133 (FF(1) - static_cast<View>(in.get(C::data_copy_sel_write_count_is_zero)));
134 std::get<15>(evals) += (tmp * scaling_factor);
135 }
136 { // ZERO_SIZED_WRITE
137 using View = typename std::tuple_element_t<16, ContainerOverSubrelations>::View;
138 auto tmp = static_cast<View>(in.get(C::data_copy_start_no_err)) *
139 ((static_cast<View>(in.get(C::data_copy_copy_size)) *
140 (static_cast<View>(in.get(C::data_copy_sel_write_count_is_zero)) *
141 (FF(1) - static_cast<View>(in.get(C::data_copy_write_count_zero_inv))) +
142 static_cast<View>(in.get(C::data_copy_write_count_zero_inv))) -
143 FF(1)) +
144 static_cast<View>(in.get(C::data_copy_sel_write_count_is_zero)));
145 std::get<16>(evals) += (tmp * scaling_factor);
146 }
147 { // END_IF_WRITE_IS_ZERO
148 using View = typename std::tuple_element_t<17, ContainerOverSubrelations>::View;
149 auto tmp = static_cast<View>(in.get(C::data_copy_start_no_err)) *
150 static_cast<View>(in.get(C::data_copy_sel_write_count_is_zero)) *
151 (static_cast<View>(in.get(C::data_copy_end)) - FF(1));
152 std::get<17>(evals) += (tmp * scaling_factor);
153 }
154 { // END_WRITE_CONDITION
155 using View = typename std::tuple_element_t<18, ContainerOverSubrelations>::View;
156 auto tmp = CView(data_copy_SEL_PERFORM_COPY) *
157 ((CView(data_copy_WRITE_COUNT_MINUS_ONE) *
158 (static_cast<View>(in.get(C::data_copy_end)) *
159 (FF(1) - static_cast<View>(in.get(C::data_copy_write_count_minus_one_inv))) +
160 static_cast<View>(in.get(C::data_copy_write_count_minus_one_inv))) -
161 FF(1)) +
162 static_cast<View>(in.get(C::data_copy_end)));
163 std::get<18>(evals) += (tmp * scaling_factor);
164 }
165 { // END_ON_ERR
166 using View = typename std::tuple_element_t<19, ContainerOverSubrelations>::View;
167 auto tmp = static_cast<View>(in.get(C::data_copy_start)) *
168 static_cast<View>(in.get(C::data_copy_dst_out_of_range_err)) *
169 (static_cast<View>(in.get(C::data_copy_end)) - FF(1));
170 std::get<19>(evals) += (tmp * scaling_factor);
171 }
172 { // INIT_READS_LEFT
173 using View = typename std::tuple_element_t<20, ContainerOverSubrelations>::View;
174 auto tmp = static_cast<View>(in.get(C::data_copy_start_no_err)) *
175 (FF(1) - static_cast<View>(in.get(C::data_copy_sel_write_count_is_zero))) *
176 (static_cast<View>(in.get(C::data_copy_reads_left)) -
177 (static_cast<View>(in.get(C::data_copy_clamped_read_index_upper_bound)) -
178 static_cast<View>(in.get(C::data_copy_offset))) *
179 static_cast<View>(in.get(C::data_copy_sel_has_reads)));
180 std::get<20>(evals) += (tmp * scaling_factor);
181 }
182 {
183 using View = typename std::tuple_element_t<21, ContainerOverSubrelations>::View;
184 auto tmp = (static_cast<View>(in.get(C::data_copy_sel_mem_write)) - CView(data_copy_SEL_PERFORM_COPY));
185 std::get<21>(evals) += (tmp * scaling_factor);
186 }
187 { // DECR_COPY_SIZE
188 using View = typename std::tuple_element_t<22, ContainerOverSubrelations>::View;
189 auto tmp = static_cast<View>(in.get(C::data_copy_sel)) * (FF(1) - static_cast<View>(in.get(C::data_copy_end))) *
190 ((static_cast<View>(in.get(C::data_copy_copy_size_shift)) -
191 static_cast<View>(in.get(C::data_copy_copy_size))) +
192 FF(1));
193 std::get<22>(evals) += (tmp * scaling_factor);
194 }
195 { // INCR_WRITE_ADDR
196 using View = typename std::tuple_element_t<23, ContainerOverSubrelations>::View;
197 auto tmp = static_cast<View>(in.get(C::data_copy_sel)) * (FF(1) - static_cast<View>(in.get(C::data_copy_end))) *
198 ((static_cast<View>(in.get(C::data_copy_dst_addr_shift)) -
199 static_cast<View>(in.get(C::data_copy_dst_addr))) -
200 FF(1));
201 std::get<23>(evals) += (tmp * scaling_factor);
202 }
203 { // SRC_CONTEXT_ID_PROPAGATION
204 using View = typename std::tuple_element_t<24, ContainerOverSubrelations>::View;
205 auto tmp =
206 (FF(1) - CView(data_copy_LATCH_CONDITION)) * (static_cast<View>(in.get(C::data_copy_src_context_id_shift)) -
207 static_cast<View>(in.get(C::data_copy_src_context_id)));
208 std::get<24>(evals) += (tmp * scaling_factor);
209 }
210 { // DST_CONTEXT_ID_PROPAGATION
211 using View = typename std::tuple_element_t<25, ContainerOverSubrelations>::View;
212 auto tmp =
213 (FF(1) - CView(data_copy_LATCH_CONDITION)) * (static_cast<View>(in.get(C::data_copy_dst_context_id_shift)) -
214 static_cast<View>(in.get(C::data_copy_dst_context_id)));
215 std::get<25>(evals) += (tmp * scaling_factor);
216 }
217 { // CLK_PROPAGATION
218 using View = typename std::tuple_element_t<26, ContainerOverSubrelations>::View;
219 auto tmp = (FF(1) - CView(data_copy_LATCH_CONDITION)) *
220 (static_cast<View>(in.get(C::data_copy_clk_shift)) - static_cast<View>(in.get(C::data_copy_clk)));
221 std::get<26>(evals) += (tmp * scaling_factor);
222 }
223 { // SEL_CD_COPY_PROPAGATION
224 using View = typename std::tuple_element_t<27, ContainerOverSubrelations>::View;
225 auto tmp =
226 (FF(1) - CView(data_copy_LATCH_CONDITION)) * (static_cast<View>(in.get(C::data_copy_sel_cd_copy_shift)) -
227 static_cast<View>(in.get(C::data_copy_sel_cd_copy)));
228 std::get<27>(evals) += (tmp * scaling_factor);
229 }
230 { // INIT_READ_ADDR
231 using View = typename std::tuple_element_t<28, ContainerOverSubrelations>::View;
232 auto tmp =
233 static_cast<View>(in.get(C::data_copy_start_no_err)) *
234 (FF(1) - static_cast<View>(in.get(C::data_copy_sel_write_count_is_zero))) *
235 ((static_cast<View>(in.get(C::data_copy_read_addr)) - static_cast<View>(in.get(C::data_copy_src_addr))) -
236 static_cast<View>(in.get(C::data_copy_offset)));
237 std::get<28>(evals) += (tmp * scaling_factor);
238 }
239 { // INCR_READ_ADDR
240 using View = typename std::tuple_element_t<29, ContainerOverSubrelations>::View;
241 auto tmp = static_cast<View>(in.get(C::data_copy_sel)) *
242 (FF(1) - static_cast<View>(in.get(C::data_copy_padding))) *
243 (FF(1) - static_cast<View>(in.get(C::data_copy_end))) *
244 ((static_cast<View>(in.get(C::data_copy_read_addr_shift)) -
245 static_cast<View>(in.get(C::data_copy_read_addr))) -
246 FF(1));
247 std::get<29>(evals) += (tmp * scaling_factor);
248 }
249 { // DECR_READ_COUNT
250 using View = typename std::tuple_element_t<30, ContainerOverSubrelations>::View;
251 auto tmp = static_cast<View>(in.get(C::data_copy_sel)) *
252 (FF(1) - static_cast<View>(in.get(C::data_copy_padding))) *
253 (FF(1) - static_cast<View>(in.get(C::data_copy_end))) *
254 ((static_cast<View>(in.get(C::data_copy_reads_left_shift)) -
255 static_cast<View>(in.get(C::data_copy_reads_left))) +
256 FF(1));
257 std::get<30>(evals) += (tmp * scaling_factor);
258 }
259 {
260 using View = typename std::tuple_element_t<31, ContainerOverSubrelations>::View;
261 auto tmp =
262 static_cast<View>(in.get(C::data_copy_padding)) * (FF(1) - static_cast<View>(in.get(C::data_copy_padding)));
263 std::get<31>(evals) += (tmp * scaling_factor);
264 }
265 { // PADDING_CONDITION
266 using View = typename std::tuple_element_t<32, ContainerOverSubrelations>::View;
267 auto tmp = CView(data_copy_SEL_PERFORM_COPY) *
268 ((static_cast<View>(in.get(C::data_copy_reads_left)) *
269 (static_cast<View>(in.get(C::data_copy_padding)) *
270 (FF(1) - static_cast<View>(in.get(C::data_copy_reads_left_inv))) +
271 static_cast<View>(in.get(C::data_copy_reads_left_inv))) -
272 FF(1)) +
273 static_cast<View>(in.get(C::data_copy_padding)));
274 std::get<32>(evals) += (tmp * scaling_factor);
275 }
276 { // PADDING_PROPAGATION
277 using View = typename std::tuple_element_t<33, ContainerOverSubrelations>::View;
278 auto tmp = (FF(1) - static_cast<View>(in.get(C::data_copy_end))) *
279 static_cast<View>(in.get(C::data_copy_padding)) *
280 (FF(1) - static_cast<View>(in.get(C::data_copy_padding_shift)));
281 std::get<33>(evals) += (tmp * scaling_factor);
282 }
283 {
284 using View = typename std::tuple_element_t<34, ContainerOverSubrelations>::View;
285 auto tmp = static_cast<View>(in.get(C::data_copy_is_top_level)) *
286 (FF(1) - static_cast<View>(in.get(C::data_copy_is_top_level)));
287 std::get<34>(evals) += (tmp * scaling_factor);
288 }
289 { // TOP_LEVEL_COND
290 using View = typename std::tuple_element_t<35, ContainerOverSubrelations>::View;
291 auto tmp = static_cast<View>(in.get(C::data_copy_sel_cd_copy)) *
292 ((static_cast<View>(in.get(C::data_copy_src_context_id)) *
293 (static_cast<View>(in.get(C::data_copy_is_top_level)) *
294 (FF(1) - static_cast<View>(in.get(C::data_copy_parent_id_inv))) +
295 static_cast<View>(in.get(C::data_copy_parent_id_inv))) -
296 FF(1)) +
297 static_cast<View>(in.get(C::data_copy_is_top_level)));
298 std::get<35>(evals) += (tmp * scaling_factor);
299 }
300 {
301 using View = typename std::tuple_element_t<36, ContainerOverSubrelations>::View;
302 auto tmp = (static_cast<View>(in.get(C::data_copy_sel_mem_read)) -
303 CView(data_copy_SEL_PERFORM_COPY) *
304 (FF(1) - static_cast<View>(in.get(C::data_copy_is_top_level)) *
305 static_cast<View>(in.get(C::data_copy_sel_cd_copy))) *
306 (FF(1) - static_cast<View>(in.get(C::data_copy_padding))));
307 std::get<36>(evals) += (tmp * scaling_factor);
308 }
309 { // PAD_VALUE
310 using View = typename std::tuple_element_t<37, ContainerOverSubrelations>::View;
311 auto tmp = static_cast<View>(in.get(C::data_copy_padding)) * static_cast<View>(in.get(C::data_copy_value));
312 std::get<37>(evals) += (tmp * scaling_factor);
313 }
314 { // CD_COPY_COLUMN
315 using View = typename std::tuple_element_t<38, ContainerOverSubrelations>::View;
316 auto tmp = (static_cast<View>(in.get(C::data_copy_cd_copy_col_read)) -
317 CView(data_copy_SEL_PERFORM_COPY) * (FF(1) - static_cast<View>(in.get(C::data_copy_padding))) *
318 static_cast<View>(in.get(C::data_copy_is_top_level)) *
319 static_cast<View>(in.get(C::data_copy_sel_cd_copy)));
320 std::get<38>(evals) += (tmp * scaling_factor);
321 }
322 {
323 using View = typename std::tuple_element_t<39, ContainerOverSubrelations>::View;
324 auto tmp = (static_cast<View>(in.get(C::data_copy_read_addr_plus_one)) -
325 static_cast<View>(in.get(C::data_copy_cd_copy_col_read)) *
326 (static_cast<View>(in.get(C::data_copy_read_addr)) + FF(1)));
327 std::get<39>(evals) += (tmp * scaling_factor);
328 }
329}
330
331} // namespace bb::avm2
static void accumulate(ContainerOverSubrelations &evals, const AllEntities &in, const RelationParameters< FF > &, const FF &scaling_factor)
AvmFlavorSettings::FF FF
Definition field.hpp:10
ColumnAndShifts
Definition columns.hpp:34
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
#define CView(v)
Container for parameters used by the grand product (permutation, lookup) Honk relations.