1#![allow(clippy::type_complexity)]
10#![allow(unused_variables)]
11
12use super::helpers::*;
13use crate::dag::{DagArmSeed, DagBuilder};
14use crate::pipeline::PipelineBuilder;
15use crate::{IntoHandler, World};
16
17#[inline(never)]
22pub fn batch_pipe_linear_3(world: &mut World) {
23 let reg = world.registry();
24 let mut bp = PipelineBuilder::<u64>::new()
25 .then(add_one, ®)
26 .then(double, ®)
27 .then(add_three, ®)
28 .then(consume_val, ®)
29 .build_batch(64);
30 bp.input_mut().extend(0..64);
31 bp.run(world);
32}
33
34#[inline(never)]
35pub fn batch_pipe_linear_10(world: &mut World) {
36 let reg = world.registry();
37 let mut bp = PipelineBuilder::<u64>::new()
38 .then(add_one, ®)
39 .then(double, ®)
40 .then(add_three, ®)
41 .then(square, ®)
42 .then(sub_ten, ®)
43 .then(shr_one, ®)
44 .then(xor_mask, ®)
45 .then(add_seven, ®)
46 .then(triple, ®)
47 .then(add_forty_two, ®)
48 .then(consume_val, ®)
49 .build_batch(64);
50 bp.input_mut().extend(0..64);
51 bp.run(world);
52}
53
54#[inline(never)]
55pub fn batch_pipe_guard(world: &mut World) {
56 let reg = world.registry();
57 let mut bp = PipelineBuilder::<u64>::new()
58 .then(add_one, ®)
59 .guard(|x: &u64| *x > 10, ®)
60 .unwrap_or(0)
61 .then(consume_val, ®)
62 .build_batch(64);
63 bp.input_mut().extend(0..64);
64 bp.run(world);
65}
66
67#[inline(never)]
68pub fn batch_pipe_option_chain(world: &mut World) {
69 let reg = world.registry();
70 let mut bp = PipelineBuilder::<u64>::new()
71 .then(maybe_positive, ®)
72 .map(double, ®)
73 .filter(|x: &u64| *x < 1000, ®)
74 .unwrap_or(0)
75 .then(consume_val, ®)
76 .build_batch(64);
77 bp.input_mut().extend(0..64);
78 bp.run(world);
79}
80
81#[inline(never)]
82pub fn batch_pipe_result_chain(world: &mut World) {
83 let reg = world.registry();
84 let mut bp = PipelineBuilder::<u64>::new()
85 .then(try_parse, ®)
86 .map(double, ®)
87 .unwrap_or(0)
88 .then(consume_val, ®)
89 .build_batch(64);
90 bp.input_mut().extend(0..64);
91 bp.run(world);
92}
93
94#[inline(never)]
95pub fn batch_pipe_mixed_arity(world: &mut World) {
96 let reg = world.registry();
97 let mut bp = PipelineBuilder::<u64>::new()
98 .then(add_one, ®)
99 .then(add_res_a, ®)
100 .then(write_res_a, ®)
101 .then(add_both, ®)
102 .then(consume_val, ®)
103 .build_batch(64);
104 bp.input_mut().extend(0..64);
105 bp.run(world);
106}
107
108#[inline(never)]
109pub fn batch_pipe_splat(world: &mut World) {
110 let reg = world.registry();
111 let mut bp = PipelineBuilder::<u64>::new()
112 .then(split_u64, ®)
113 .splat()
114 .then(splat_add, ®)
115 .then(consume_val, ®)
116 .build_batch(64);
117 bp.input_mut().extend(0..64);
118 bp.run(world);
119}
120
121#[inline(never)]
122pub fn batch_pipe_route(world: &mut World) {
123 let reg = world.registry();
124
125 let on_true = PipelineBuilder::<u64>::new().then(double, ®);
126 let on_false = PipelineBuilder::<u64>::new().then(add_one, ®);
127
128 let mut bp = PipelineBuilder::<u64>::new()
129 .then(add_one, ®)
130 .route(|x: &u64| *x > 32, ®, on_true, on_false)
131 .then(consume_val, ®)
132 .build_batch(64);
133 bp.input_mut().extend(0..64);
134 bp.run(world);
135}
136
137#[inline(never)]
138pub fn batch_pipe_large(world: &mut World) {
139 let reg = world.registry();
140 let mut bp = PipelineBuilder::<u64>::new()
141 .then(add_one, ®)
142 .then(double, ®)
143 .then(add_three, ®)
144 .then(square, ®)
145 .then(sub_ten, ®)
146 .then(shr_one, ®)
147 .then(xor_mask, ®)
148 .then(add_seven, ®)
149 .then(triple, ®)
150 .then(add_forty_two, ®)
151 .then(consume_val, ®)
152 .build_batch(256);
153 bp.input_mut().extend(0..256);
154 bp.run(world);
155}
156
157#[inline(never)]
160pub fn batch_pipe_guard_skip_10(world: &mut World) {
161 let reg = world.registry();
162 let mut bp = PipelineBuilder::<u64>::new()
166 .then(|x: u64| x, ®)
167 .guard(|x: &u64| *x > 32, ®)
168 .map(add_one, ®)
169 .map(double, ®)
170 .map(add_three, ®)
171 .map(square, ®)
172 .map(sub_ten, ®)
173 .map(shr_one, ®)
174 .map(xor_mask, ®)
175 .map(add_seven, ®)
176 .map(triple, ®)
177 .map(add_forty_two, ®)
178 .unwrap_or(0)
179 .then(consume_val, ®)
180 .build_batch(64);
181 bp.input_mut().extend(0..64);
183 bp.run(world);
184}
185
186#[inline(never)]
187pub fn batch_pipe_res_skip_10(world: &mut World) {
188 let reg = world.registry();
189 let mut bp = PipelineBuilder::<u64>::new()
192 .then(try_parse, ®)
193 .map(add_one, ®)
194 .map(double, ®)
195 .map(add_three, ®)
196 .map(square, ®)
197 .map(sub_ten, ®)
198 .map(shr_one, ®)
199 .map(xor_mask, ®)
200 .map(add_seven, ®)
201 .map(triple, ®)
202 .map(add_forty_two, ®)
203 .unwrap_or(0)
204 .then(consume_val, ®)
205 .build_batch(64);
206 bp.input_mut().extend(0..64);
207 bp.run(world);
208}
209
210#[inline(never)]
215pub fn batch_dag_linear_3(world: &mut World) {
216 let reg = world.registry();
217 let mut bd = DagBuilder::<u64>::new()
218 .root(add_one, ®)
219 .then(ref_double, ®)
220 .then(ref_add_three, ®)
221 .then(ref_consume, ®)
222 .build_batch(64);
223 bd.input_mut().extend(0..64);
224 bd.run(world);
225}
226
227#[inline(never)]
228pub fn batch_dag_linear_10(world: &mut World) {
229 let reg = world.registry();
230 let mut bd = DagBuilder::<u64>::new()
231 .root(add_one, ®)
232 .then(ref_double, ®)
233 .then(ref_add_three, ®)
234 .then(ref_square, ®)
235 .then(ref_sub_ten, ®)
236 .then(ref_shr_one, ®)
237 .then(ref_xor_mask, ®)
238 .then(ref_add_seven, ®)
239 .then(ref_triple, ®)
240 .then(ref_add_forty_two, ®)
241 .then(ref_consume, ®)
242 .build_batch(64);
243 bd.input_mut().extend(0..64);
244 bd.run(world);
245}
246
247#[inline(never)]
248pub fn batch_dag_fork_merge(world: &mut World) {
249 let reg = world.registry();
250 let mut bd = DagBuilder::<u64>::new()
251 .root(add_one, ®)
252 .fork()
253 .arm(|a| a.then(ref_double, ®))
254 .arm(|a| a.then(ref_triple, ®))
255 .merge(merge_add, ®)
256 .then(ref_consume, ®)
257 .build_batch(64);
258 bd.input_mut().extend(0..64);
259 bd.run(world);
260}
261
262#[inline(never)]
263pub fn batch_dag_guard(world: &mut World) {
264 let reg = world.registry();
265 let mut bd = DagBuilder::<u64>::new()
266 .root(add_one, ®)
267 .guard(|x: &u64| *x > 10, ®)
268 .unwrap_or(0)
269 .then(ref_consume, ®)
270 .build_batch(64);
271 bd.input_mut().extend(0..64);
272 bd.run(world);
273}
274
275#[inline(never)]
276pub fn batch_dag_mixed_arity(world: &mut World) {
277 let reg = world.registry();
278 let mut bd = DagBuilder::<u64>::new()
279 .root(add_one, ®)
280 .then(ref_add_res_a, ®)
281 .then(ref_write_res_a, ®)
282 .then(ref_add_both, ®)
283 .then(ref_consume, ®)
284 .build_batch(64);
285 bd.input_mut().extend(0..64);
286 bd.run(world);
287}
288
289#[inline(never)]
290pub fn batch_dag_diamond(world: &mut World) {
291 let reg = world.registry();
292 let mut bd = DagBuilder::<u64>::new()
293 .root(add_one, ®)
294 .fork()
295 .arm(|a| a.then(ref_double, ®))
296 .arm(|a| a.then(ref_triple, ®))
297 .merge(merge_add, ®)
298 .fork()
299 .arm(|a| a.then(ref_square, ®))
300 .arm(|a| a.then(ref_shr_one, ®))
301 .merge(merge_mul, ®)
302 .then(ref_consume, ®)
303 .build_batch(64);
304 bd.input_mut().extend(0..64);
305 bd.run(world);
306}
307
308#[inline(never)]
309pub fn batch_dag_large(world: &mut World) {
310 let reg = world.registry();
311 let mut bd = DagBuilder::<u64>::new()
312 .root(add_one, ®)
313 .then(ref_double, ®)
314 .then(ref_add_three, ®)
315 .then(ref_square, ®)
316 .then(ref_sub_ten, ®)
317 .then(ref_shr_one, ®)
318 .then(ref_xor_mask, ®)
319 .then(ref_add_seven, ®)
320 .then(ref_triple, ®)
321 .then(ref_add_forty_two, ®)
322 .then(ref_consume, ®)
323 .build_batch(256);
324 bd.input_mut().extend(0..256);
325 bd.run(world);
326}
327
328#[inline(never)]
335pub fn batch_pipe_guard_filter(world: &mut World) {
336 let reg = world.registry();
337 let mut bp = PipelineBuilder::<u64>::new()
338 .then(add_one, ®)
339 .guard(|x: &u64| *x > 10, ®)
340 .filter(|x: &u64| *x < 1000, ®)
341 .unwrap_or(0)
342 .then(consume_val, ®)
343 .build_batch(64);
344 bp.input_mut().extend(0..64);
345 bp.run(world);
346}
347
348#[inline(never)]
351pub fn batch_pipe_transition(world: &mut World) {
352 let reg = world.registry();
353
354 fn log_error(_err: u32) {}
355
356 let mut bp = PipelineBuilder::<u64>::new()
357 .then(|x: u64| x, ®)
358 .guard(|x: &u64| *x > 0, ®)
359 .ok_or(0u32)
360 .catch(log_error, ®)
361 .unwrap_or(0)
362 .then(consume_val, ®)
363 .build_batch(64);
364 bp.input_mut().extend(0..64);
365 bp.run(world);
366}
367
368#[inline(never)]
371pub fn batch_pipe_switch(world: &mut World) {
372 let reg = world.registry();
373 let mut bp = PipelineBuilder::<u64>::new()
374 .then(
375 |x: u64| match x % 3 {
376 0 => x.wrapping_mul(2),
377 1 => x.wrapping_add(10),
378 _ => x.wrapping_sub(5),
379 },
380 ®,
381 )
382 .then(consume_val, ®)
383 .build_batch(64);
384 bp.input_mut().extend(0..64);
385 bp.run(world);
386}
387
388#[inline(never)]
391pub fn batch_pipe_dispatch(world: &mut World) {
392 let reg = world.registry();
393 let handler = consume_val.into_handler(®);
394 let mut bp = PipelineBuilder::<u64>::new()
395 .then(add_one, ®)
396 .dispatch(handler)
397 .build_batch(64);
398 bp.input_mut().extend(0..64);
399 bp.run(world);
400}
401
402#[inline(never)]
405pub fn batch_pipe_buffer_reuse(world: &mut World) {
406 let reg = world.registry();
407 let mut bp = PipelineBuilder::<u64>::new()
408 .then(add_one, ®)
409 .then(double, ®)
410 .then(consume_val, ®)
411 .build_batch(64);
412 bp.input_mut().extend(0..64);
414 bp.run(world);
415 bp.input_mut().extend(0..64);
417 bp.run(world);
418}
419
420#[inline(never)]
423pub fn batch_pipe_empty(world: &mut World) {
424 let reg = world.registry();
425 let mut bp = PipelineBuilder::<u64>::new()
426 .then(add_one, ®)
427 .then(double, ®)
428 .then(add_three, ®)
429 .then(consume_val, ®)
430 .build_batch(64);
431 bp.run(world);
433}
434
435#[inline(never)]
438pub fn batch_pipe_single_item(world: &mut World) {
439 let reg = world.registry();
440 let mut bp = PipelineBuilder::<u64>::new()
441 .then(add_one, ®)
442 .then(double, ®)
443 .then(consume_val, ®)
444 .build_batch(64);
445 bp.input_mut().push(42);
446 bp.run(world);
447}
448
449#[inline(never)]
452pub fn batch_pipe_drain_codegen(world: &mut World) {
453 let reg = world.registry();
454 let mut bp = PipelineBuilder::<u64>::new()
455 .then(|x: u64| x, ®)
456 .then(consume_val, ®)
457 .build_batch(64);
458 bp.input_mut().extend(0..64);
459 bp.run(world);
460}
461
462#[inline(never)]
469pub fn batch_dag_fork4(world: &mut World) {
470 let reg = world.registry();
471 let mut bd = DagBuilder::<u64>::new()
472 .root(add_one, ®)
473 .fork()
474 .arm(|a| a.then(ref_double, ®))
475 .arm(|a| a.then(ref_triple, ®))
476 .arm(|a| a.then(ref_add_seven, ®))
477 .arm(|a| a.then(ref_xor_mask, ®))
478 .merge(merge_4, ®)
479 .then(ref_consume, ®)
480 .build_batch(64);
481 bd.input_mut().extend(0..64);
482 bd.run(world);
483}
484
485#[inline(never)]
488pub fn batch_dag_nested_fork(world: &mut World) {
489 let reg = world.registry();
490 let mut bd = DagBuilder::<u64>::new()
491 .root(add_one, ®)
492 .fork()
493 .arm(|a| {
494 a.then(ref_double, ®)
495 .fork()
496 .arm(|b| b.then(ref_add_one, ®))
497 .arm(|b| b.then(ref_triple, ®))
498 .merge(merge_add, ®)
499 })
500 .arm(|a| a.then(ref_add_seven, ®))
501 .merge(merge_add, ®)
502 .then(ref_consume, ®)
503 .build_batch(64);
504 bd.input_mut().extend(0..64);
505 bd.run(world);
506}
507
508#[inline(never)]
511pub fn batch_dag_option_chain(world: &mut World) {
512 let reg = world.registry();
513 let mut bd = DagBuilder::<u64>::new()
514 .root(maybe_positive, ®)
515 .map(ref_double, ®)
516 .filter(|x: &u64| *x < 1000, ®)
517 .unwrap_or(0)
518 .then(ref_consume, ®)
519 .build_batch(64);
520 bd.input_mut().extend(0..64);
521 bd.run(world);
522}
523
524#[inline(never)]
527pub fn batch_dag_result_chain(world: &mut World) {
528 let reg = world.registry();
529 let mut bd = DagBuilder::<u64>::new()
530 .root(try_parse, ®)
531 .map(ref_double, ®)
532 .unwrap_or(0)
533 .then(ref_consume, ®)
534 .build_batch(64);
535 bd.input_mut().extend(0..64);
536 bd.run(world);
537}
538
539#[inline(never)]
542pub fn batch_dag_route(world: &mut World) {
543 let reg = world.registry();
544
545 let on_true = DagArmSeed::<u64>::new().then(ref_double, ®);
546 let on_false = DagArmSeed::<u64>::new().then(ref_add_one, ®);
547
548 let mut bd = DagBuilder::<u64>::new()
549 .root(add_one, ®)
550 .route(|x: &u64| *x > 32, ®, on_true, on_false)
551 .then(ref_consume, ®)
552 .build_batch(64);
553 bd.input_mut().extend(0..64);
554 bd.run(world);
555}
556
557#[inline(never)]
560pub fn batch_dag_splat(world: &mut World) {
561 let reg = world.registry();
562 let mut bd = DagBuilder::<u64>::new()
563 .root(split_u64, ®)
564 .splat()
565 .then(ref_splat_add, ®)
566 .then(ref_consume, ®)
567 .build_batch(64);
568 bd.input_mut().extend(0..64);
569 bd.run(world);
570}
571
572#[inline(never)]
575pub fn batch_dag_heavy(world: &mut World) {
576 let reg = world.registry();
577 let mut bd = DagBuilder::<u64>::new()
578 .root(add_one, ®)
579 .fork()
580 .arm(|a| {
581 a.then(ref_double, ®)
582 .then(ref_add_three, ®)
583 .then(ref_square, ®)
584 .then(ref_sub_ten, ®)
585 .then(ref_shr_one, ®)
586 })
587 .arm(|a| {
588 a.then(ref_add_one, ®)
589 .then(ref_triple, ®)
590 .then(ref_xor_mask, ®)
591 .then(ref_add_seven, ®)
592 .then(ref_add_forty_two, ®)
593 })
594 .arm(|a| {
595 a.then(ref_triple, ®)
596 .then(ref_add_three, ®)
597 .then(ref_double, ®)
598 .then(ref_square, ®)
599 .then(ref_add_one, ®)
600 })
601 .arm(|a| {
602 a.then(ref_xor_mask, ®)
603 .then(ref_shr_one, ®)
604 .then(ref_add_seven, ®)
605 .then(ref_triple, ®)
606 .then(ref_sub_ten, ®)
607 })
608 .merge(merge_4, ®)
609 .then(ref_consume, ®)
610 .build_batch(64);
611 bd.input_mut().extend(0..64);
612 bd.run(world);
613}
614
615#[inline(never)]
618pub fn batch_dag_dispatch(world: &mut World) {
619 let reg = world.registry();
620 let handler = consume_val.into_handler(®);
621 let mut bd = DagBuilder::<u64>::new()
622 .root(add_one, ®)
623 .then(ref_double, ®)
624 .dispatch(handler)
625 .build_batch(64);
626 bd.input_mut().extend(0..64);
627 bd.run(world);
628}