Skip to content

Commit

Permalink
feat(map): Allow chaining lists before mapping
Browse files Browse the repository at this point in the history
Previously, the higher-order assembly function `map` took all elements
of an input list, mapped them according to some supplied function, and
generated an output list. Equivalently, written in rust, this
was:`list.into_iter().map(f).collect_vec()`.

Now, `map` is generalized over the number of input lists, enabling
chaining multiple input lists while still producing only one output
list. As rust: `list_0.into_iter().chain(list_1).map(f).collect_vec()`.

Between 0 and 15 (both inclusive) input lists are supported.

Note: the ABI for map has changed. Before, an inner function could
access runtime parameters on the stack at a distance of 3. Now, this
distance has increased to (3 + num_input_lists). For a “traditional”
map, this is now 4.
  • Loading branch information
jan-ferdinand committed Sep 20, 2024
1 parent 8d5ffc9 commit 031927a
Show file tree
Hide file tree
Showing 11 changed files with 575 additions and 444 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
{
"name": "tasmlib_list_higher_order_u32_map_test_hash_xfield_element",
"benchmark_result": {
"clock_cycle_count": 2870,
"hash_table_height": 822,
"clock_cycle_count": 506,
"hash_table_height": 250,
"u32_table_height": 33,
"op_stack_table_height": 3290,
"ram_table_height": 437
"op_stack_table_height": 584,
"ram_table_height": 86
},
"case": "CommonCase"
},
{
"name": "tasmlib_list_higher_order_u32_map_test_hash_xfield_element",
"benchmark_result": {
"clock_cycle_count": 3182,
"hash_table_height": 900,
"clock_cycle_count": 4466,
"hash_table_height": 1420,
"u32_table_height": 33,
"op_stack_table_height": 3650,
"ram_table_height": 485
"op_stack_table_height": 5444,
"ram_table_height": 806
},
"case": "WorstCase"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
{
"name": "tasmlib_neptune_mutator_get_swbf_indices_1048576_45",
"benchmark_result": {
"clock_cycle_count": 4618,
"clock_cycle_count": 4397,
"hash_table_height": 481,
"u32_table_height": 4633,
"op_stack_table_height": 3464,
"ram_table_height": 469
"op_stack_table_height": 3188,
"ram_table_height": 470
},
"case": "CommonCase"
},
{
"name": "tasmlib_neptune_mutator_get_swbf_indices_1048576_45",
"benchmark_result": {
"clock_cycle_count": 4618,
"clock_cycle_count": 4397,
"hash_table_height": 481,
"u32_table_height": 4507,
"op_stack_table_height": 3464,
"ram_table_height": 469
"op_stack_table_height": 3188,
"ram_table_height": 470
},
"case": "WorstCase"
}
Expand Down
12 changes: 6 additions & 6 deletions tasm-lib/benchmarks/tasmlib_verifier_fri_verify.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
{
"name": "tasmlib_verifier_fri_verify",
"benchmark_result": {
"clock_cycle_count": 45534,
"clock_cycle_count": 44905,
"hash_table_height": 14646,
"u32_table_height": 17928,
"op_stack_table_height": 43861,
"ram_table_height": 17532
"op_stack_table_height": 42893,
"ram_table_height": 17534
},
"case": "CommonCase"
},
{
"name": "tasmlib_verifier_fri_verify",
"benchmark_result": {
"clock_cycle_count": 45534,
"clock_cycle_count": 44905,
"hash_table_height": 14646,
"u32_table_height": 17324,
"op_stack_table_height": 43861,
"ram_table_height": 17532
"op_stack_table_height": 42893,
"ram_table_height": 17534
},
"case": "WorstCase"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
{
"name": "tasmlib_verifier_stark_verify_dynamic_inner_padded_height_256_fri_exp_4",
"benchmark_result": {
"clock_cycle_count": 195488,
"hash_table_height": 142843,
"u32_table_height": 25110,
"op_stack_table_height": 177960,
"ram_table_height": 289180
"clock_cycle_count": 194859,
"hash_table_height": 142849,
"u32_table_height": 25541,
"op_stack_table_height": 176992,
"ram_table_height": 289182
},
"case": "CommonCase"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
{
"name": "tasmlib_verifier_stark_verify_dynamic_inner_padded_height_512_fri_exp_4",
"benchmark_result": {
"clock_cycle_count": 203513,
"hash_table_height": 150535,
"u32_table_height": 34005,
"op_stack_table_height": 183116,
"ram_table_height": 290358
"clock_cycle_count": 202884,
"hash_table_height": 150541,
"u32_table_height": 34793,
"op_stack_table_height": 182148,
"ram_table_height": 290360
},
"case": "CommonCase"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
{
"name": "tasmlib_verifier_stark_verify_static_inner_padded_height_256_fri_exp_4",
"benchmark_result": {
"clock_cycle_count": 183785,
"hash_table_height": 128797,
"u32_table_height": 25976,
"op_stack_table_height": 170154,
"ram_table_height": 285281
"clock_cycle_count": 183156,
"hash_table_height": 128803,
"u32_table_height": 25891,
"op_stack_table_height": 169186,
"ram_table_height": 285283
},
"case": "CommonCase"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
{
"name": "tasmlib_verifier_stark_verify_static_inner_padded_height_512_fri_exp_4",
"benchmark_result": {
"clock_cycle_count": 191810,
"hash_table_height": 136489,
"u32_table_height": 33693,
"op_stack_table_height": 175310,
"ram_table_height": 286459
"clock_cycle_count": 191181,
"hash_table_height": 136495,
"u32_table_height": 34185,
"op_stack_table_height": 174342,
"ram_table_height": 286461
},
"case": "CommonCase"
}
Expand Down
Loading

0 comments on commit 031927a

Please sign in to comment.