Skip to content

Commit

Permalink
feat(struct): Add range-cehck to field-getters
Browse files Browse the repository at this point in the history
Cf. #70.
  • Loading branch information
Sword-Smith committed Aug 30, 2024
1 parent aaf8918 commit c2f9963
Show file tree
Hide file tree
Showing 17 changed files with 514 additions and 338 deletions.
16 changes: 8 additions & 8 deletions benchmarks/fast_ntt.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
{
"name": "fast_ntt",
"benchmark_result": {
"clock_cycle_count": 61377,
"hash_table_height": 594,
"u32_table_height": 1711,
"op_stack_table_height": 54294,
"clock_cycle_count": 64961,
"hash_table_height": 642,
"u32_table_height": 2735,
"op_stack_table_height": 57878,
"ram_table_height": 4069
},
"case": "CommonCase"
},
{
"name": "fast_ntt",
"benchmark_result": {
"clock_cycle_count": 141965,
"hash_table_height": 594,
"u32_table_height": 3694,
"op_stack_table_height": 125830,
"clock_cycle_count": 150285,
"hash_table_height": 642,
"u32_table_height": 5742,
"op_stack_table_height": 134150,
"ram_table_height": 9451
},
"case": "WorstCase"
Expand Down
16 changes: 8 additions & 8 deletions benchmarks/project_euler_4_i10_to_50.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
{
"name": "project_euler_4_i10_to_50",
"benchmark_result": {
"clock_cycle_count": 295537,
"hash_table_height": 264,
"u32_table_height": 24483,
"op_stack_table_height": 226020,
"clock_cycle_count": 304385,
"hash_table_height": 270,
"u32_table_height": 24611,
"op_stack_table_height": 234868,
"ram_table_height": 14839
},
"case": "CommonCase"
},
{
"name": "project_euler_4_i10_to_50",
"benchmark_result": {
"clock_cycle_count": 295537,
"hash_table_height": 264,
"u32_table_height": 24483,
"op_stack_table_height": 226020,
"clock_cycle_count": 304385,
"hash_table_height": 270,
"u32_table_height": 24611,
"op_stack_table_height": 234868,
"ram_table_height": 14839
},
"case": "WorstCase"
Expand Down
16 changes: 8 additions & 8 deletions benchmarks/project_euler_7_i101.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
{
"name": "project_euler_7_i101",
"benchmark_result": {
"clock_cycle_count": 64854,
"hash_table_height": 186,
"u32_table_height": 15252,
"op_stack_table_height": 51568,
"clock_cycle_count": 69254,
"hash_table_height": 198,
"u32_table_height": 34004,
"op_stack_table_height": 55968,
"ram_table_height": 3527
},
"case": "CommonCase"
},
{
"name": "project_euler_7_i101",
"benchmark_result": {
"clock_cycle_count": 1060950,
"hash_table_height": 186,
"u32_table_height": 294608,
"op_stack_table_height": 849364,
"clock_cycle_count": 1141430,
"hash_table_height": 198,
"u32_table_height": 578640,
"op_stack_table_height": 929844,
"ram_table_height": 56159
},
"case": "WorstCase"
Expand Down
16 changes: 8 additions & 8 deletions benchmarks/recufier_merkle_root.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
{
"name": "recufier_merkle_root",
"benchmark_result": {
"clock_cycle_count": 2268,
"hash_table_height": 222,
"u32_table_height": 91,
"op_stack_table_height": 1768,
"clock_cycle_count": 2332,
"hash_table_height": 228,
"u32_table_height": 603,
"op_stack_table_height": 1832,
"ram_table_height": 81
},
"case": "CommonCase"
},
{
"name": "recufier_merkle_root",
"benchmark_result": {
"clock_cycle_count": 37548,
"hash_table_height": 1662,
"u32_table_height": 2113,
"op_stack_table_height": 29128,
"clock_cycle_count": 38572,
"hash_table_height": 1668,
"u32_table_height": 10305,
"op_stack_table_height": 30152,
"ram_table_height": 1281
},
"case": "WorstCase"
Expand Down
12 changes: 6 additions & 6 deletions benchmarks/simple_map_on_bfe.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
{
"name": "simple_map_on_bfe",
"benchmark_result": {
"clock_cycle_count": 611,
"clock_cycle_count": 631,
"hash_table_height": 168,
"u32_table_height": 104,
"op_stack_table_height": 460,
"u32_table_height": 264,
"op_stack_table_height": 480,
"ram_table_height": 43
},
"case": "CommonCase"
},
{
"name": "simple_map_on_bfe",
"benchmark_result": {
"clock_cycle_count": 10016,
"clock_cycle_count": 10416,
"hash_table_height": 168,
"u32_table_height": 1552,
"op_stack_table_height": 7490,
"u32_table_height": 4752,
"op_stack_table_height": 7890,
"ram_table_height": 708
},
"case": "WorstCase"
Expand Down
16 changes: 8 additions & 8 deletions benchmarks/verify_authentication_path.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
{
"name": "verify_authentication_path",
"benchmark_result": {
"clock_cycle_count": 10647,
"hash_table_height": 1044,
"u32_table_height": 3166,
"op_stack_table_height": 8332,
"clock_cycle_count": 10775,
"hash_table_height": 1050,
"u32_table_height": 4158,
"op_stack_table_height": 8460,
"ram_table_height": 568
},
"case": "CommonCase"
},
{
"name": "verify_authentication_path",
"benchmark_result": {
"clock_cycle_count": 230918,
"hash_table_height": 1158,
"u32_table_height": 37997,
"op_stack_table_height": 159856,
"clock_cycle_count": 231122,
"hash_table_height": 1164,
"u32_table_height": 39597,
"op_stack_table_height": 160060,
"ram_table_height": 4064
},
"case": "WorstCase"
Expand Down
74 changes: 37 additions & 37 deletions profiles/fast_ntt.profile
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
fast_ntt:
| Subroutine | Processor | Op Stack | RAM | Hash | U32 |
|:----------------------------------------------------------|---------------------:|---------------------:|---------------------:|---------------------:|---------------------:|
| main | 61376 (100.0%) | 54294 (100.0%) | 4069 (100.0%) | 0 ( 0.0%) | 1711 (100.0%) |
| main | 64960 (100.0%) | 57878 (100.0%) | 4069 (100.0%) | 0 ( 0.0%) | 2735 (100.0%) |
| ··tasmlib_io_read_stdin___bfe | 3 ( 0.0%) | 1 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ··tasmlib_arithmetic_u32_leadingzeros | 13 ( 0.0%) | 8 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | 7 ( 0.4%) |
| ····tasmlib_arithmetic_u32_leadingzeros_non_zero | 5 ( 0.0%) | 2 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | 7 ( 0.4%) |
| ··tasmlib_arithmetic_u32_safesub | 24 ( 0.0%) | 18 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | 8 ( 0.5%) |
| ··xfe_ntt | 28542 ( 46.5%) | 25143 ( 46.3%) | 1793 ( 44.1%) | 0 ( 0.0%) | 1564 ( 91.4%) |
| ····_binop_Neq__LboolR_bool_30_while_loop | 13042 ( 21.2%) | 10312 ( 19.0%) | 192 ( 4.7%) | 0 ( 0.0%) | 1372 ( 80.2%) |
| ······bitreverse | 11264 ( 18.4%) | 8672 ( 16.0%) | 0 ( 0.0%) | 0 ( 0.0%) | 1114 ( 65.1%) |
| ········_binop_Lt__LboolR_bool_9_while_loop | 11008 ( 17.9%) | 8512 ( 15.7%) | 0 ( 0.0%) | 0 ( 0.0%) | 1114 ( 65.1%) |
| ··········tasmlib_arithmetic_u32_shiftleft | 1920 ( 3.1%) | 1440 ( 2.7%) | 0 ( 0.0%) | 0 ( 0.0%) | 78 ( 4.6%) |
| ··········tasmlib_arithmetic_u32_or | 1280 ( 2.1%) | 800 ( 1.5%) | 0 ( 0.0%) | 0 ( 0.0%) | 257 ( 15.0%) |
| ··········tasmlib_arithmetic_u32_shiftright | 2400 ( 3.9%) | 2080 ( 3.8%) | 0 ( 0.0%) | 0 ( 0.0%) | 598 ( 35.0%) |
| ··········tasmlib_arithmetic_u32_safeadd | 6759 ( 11.0%) | 5257 ( 9.7%) | 0 ( 0.0%) | 0 ( 0.0%) | 12 ( 0.7%) |
| ··tasmlib_arithmetic_u32_leadingzeros | 13 ( 0.0%) | 8 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | 7 ( 0.3%) |
| ····tasmlib_arithmetic_u32_leadingzeros_non_zero | 5 ( 0.0%) | 2 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | 7 ( 0.3%) |
| ··tasmlib_arithmetic_u32_safesub | 24 ( 0.0%) | 18 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | 8 ( 0.3%) |
| ··xfe_ntt | 30014 ( 46.2%) | 26615 ( 46.0%) | 1793 ( 44.1%) | 0 ( 0.0%) | 2588 ( 94.6%) |
| ····_binop_Neq__LboolR_bool_30_while_loop | 13234 ( 20.4%) | 10504 ( 18.1%) | 192 ( 4.7%) | 0 ( 0.0%) | 2140 ( 78.2%) |
| ······bitreverse | 11264 ( 17.3%) | 8672 ( 15.0%) | 0 ( 0.0%) | 0 ( 0.0%) | 1114 ( 40.7%) |
| ········_binop_Lt__LboolR_bool_9_while_loop | 11008 ( 16.9%) | 8512 ( 14.7%) | 0 ( 0.0%) | 0 ( 0.0%) | 1114 ( 40.7%) |
| ··········tasmlib_arithmetic_u32_shiftleft | 1920 ( 3.0%) | 1440 ( 2.5%) | 0 ( 0.0%) | 0 ( 0.0%) | 78 ( 2.9%) |
| ··········tasmlib_arithmetic_u32_or | 1280 ( 2.0%) | 800 ( 1.4%) | 0 ( 0.0%) | 0 ( 0.0%) | 257 ( 9.4%) |
| ··········tasmlib_arithmetic_u32_shiftright | 2400 ( 3.7%) | 2080 ( 3.6%) | 0 ( 0.0%) | 0 ( 0.0%) | 598 ( 21.9%) |
| ··········tasmlib_arithmetic_u32_safeadd | 6759 ( 10.4%) | 5257 ( 9.1%) | 0 ( 0.0%) | 0 ( 0.0%) | 12 ( 0.4%) |
| ······_binop_Lt__LboolR_bool_36_else | 40 ( 0.1%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ······tasmlib_arithmetic_u32_safeadd | 621 ( 1.0%) | 483 ( 0.9%) | 0 ( 0.0%) | 0 ( 0.0%) | 79 ( 4.6%) |
| ······_binop_Lt__LboolR_bool_36_then | 672 ( 1.1%) | 768 ( 1.4%) | 192 ( 4.7%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ····_binop_Neq__LboolR_bool_59_while_loop | 15479 ( 25.2%) | 14808 ( 27.3%) | 1597 ( 39.2%) | 0 ( 0.0%) | 192 ( 11.2%) |
| ······tasmlib_arithmetic_u32_safeadd | 621 ( 1.0%) | 483 ( 0.8%) | 0 ( 0.0%) | 0 ( 0.0%) | 79 ( 2.9%) |
| ······_binop_Lt__LboolR_bool_36_then | 864 ( 1.3%) | 960 ( 1.7%) | 192 ( 4.7%) | 0 ( 0.0%) | 768 ( 28.1%) |
| ····_binop_Neq__LboolR_bool_59_while_loop | 16759 ( 25.8%) | 16088 ( 27.8%) | 1597 ( 39.2%) | 0 ( 0.0%) | 448 ( 16.4%) |
| ······tasmlib_arithmetic_u32_safemul | 90 ( 0.1%) | 70 ( 0.1%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ······_binop_Lt__LboolR_bool_70_while_loop | 15164 ( 24.7%) | 14550 ( 26.8%) | 1582 ( 38.9%) | 0 ( 0.0%) | 119 ( 7.0%) |
| ········_binop_Neq__LboolR_bool_75_while_loop | 13972 ( 22.8%) | 13590 ( 25.0%) | 1551 ( 38.1%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ······_binop_Lt__LboolR_bool_70_while_loop | 16444 ( 25.3%) | 15830 ( 27.4%) | 1582 ( 38.9%) | 0 ( 0.0%) | 375 ( 13.7%) |
| ········_binop_Neq__LboolR_bool_75_while_loop | 15252 ( 23.5%) | 14870 ( 25.7%) | 1551 ( 38.1%) | 0 ( 0.0%) | 256 ( 9.4%) |
| ········tasmlib_arithmetic_u32_safemul | 369 ( 0.6%) | 287 ( 0.5%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ········tasmlib_arithmetic_u32_safeadd | 612 ( 1.0%) | 476 ( 0.9%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ··_binop_Lt__LboolR_bool_190_while_loop | 1129 ( 1.8%) | 1030 ( 1.9%) | 96 ( 2.4%) | 0 ( 0.0%) | 105 ( 6.1%) |
| ····tasmlib_io_write_to_stdout___xfe | 96 ( 0.2%) | 96 ( 0.2%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ········tasmlib_arithmetic_u32_safeadd | 612 ( 0.9%) | 476 ( 0.8%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ··_binop_Lt__LboolR_bool_190_while_loop | 1257 ( 1.9%) | 1158 ( 2.0%) | 96 ( 2.4%) | 0 ( 0.0%) | 105 ( 3.8%) |
| ····tasmlib_io_write_to_stdout___xfe | 96 ( 0.1%) | 96 ( 0.2%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ····tasmlib_arithmetic_u32_safeadd | 576 ( 0.9%) | 448 ( 0.8%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ··xfe_intt | 29960 ( 48.8%) | 26521 ( 48.8%) | 1987 ( 48.8%) | 0 ( 0.0%) | 20 ( 1.2%) |
| ····xfe_ntt | 28542 ( 46.5%) | 25143 ( 46.3%) | 1793 ( 44.1%) | 0 ( 0.0%) | 20 ( 1.2%) |
| ······_binop_Neq__LboolR_bool_30_while_loop | 13042 ( 21.2%) | 10312 ( 19.0%) | 192 ( 4.7%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ········bitreverse | 11264 ( 18.4%) | 8672 ( 16.0%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ··········_binop_Lt__LboolR_bool_9_while_loop | 11008 ( 17.9%) | 8512 ( 15.7%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ············tasmlib_arithmetic_u32_shiftleft | 1920 ( 3.1%) | 1440 ( 2.7%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ············tasmlib_arithmetic_u32_or | 1280 ( 2.1%) | 800 ( 1.5%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ············tasmlib_arithmetic_u32_shiftright | 2400 ( 3.9%) | 2080 ( 3.8%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ············tasmlib_arithmetic_u32_safeadd | 6480 ( 10.6%) | 5040 ( 9.3%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ··xfe_intt | 31688 ( 48.8%) | 28249 ( 48.8%) | 1987 ( 48.8%) | 0 ( 0.0%) | 20 ( 0.7%) |
| ····xfe_ntt | 30014 ( 46.2%) | 26615 ( 46.0%) | 1793 ( 44.1%) | 0 ( 0.0%) | 20 ( 0.7%) |
| ······_binop_Neq__LboolR_bool_30_while_loop | 13234 ( 20.4%) | 10504 ( 18.1%) | 192 ( 4.7%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ········bitreverse | 11264 ( 17.3%) | 8672 ( 15.0%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ··········_binop_Lt__LboolR_bool_9_while_loop | 11008 ( 16.9%) | 8512 ( 14.7%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ············tasmlib_arithmetic_u32_shiftleft | 1920 ( 3.0%) | 1440 ( 2.5%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ············tasmlib_arithmetic_u32_or | 1280 ( 2.0%) | 800 ( 1.4%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ············tasmlib_arithmetic_u32_shiftright | 2400 ( 3.7%) | 2080 ( 3.6%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ············tasmlib_arithmetic_u32_safeadd | 6480 ( 10.0%) | 5040 ( 8.7%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ········_binop_Lt__LboolR_bool_36_else | 40 ( 0.1%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ········_binop_Lt__LboolR_bool_36_then | 672 ( 1.1%) | 768 ( 1.4%) | 192 ( 4.7%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ······_binop_Neq__LboolR_bool_59_while_loop | 15479 ( 25.2%) | 14808 ( 27.3%) | 1597 ( 39.2%) | 0 ( 0.0%) | 20 ( 1.2%) |
| ········_binop_Lt__LboolR_bool_70_while_loop | 15164 ( 24.7%) | 14550 ( 26.8%) | 1582 ( 38.9%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ··········_binop_Neq__LboolR_bool_75_while_loop | 13972 ( 22.8%) | 13590 ( 25.0%) | 1551 ( 38.1%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ··········tasmlib_arithmetic_u32_safemul | 279 ( 0.5%) | 217 ( 0.4%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ········_binop_Lt__LboolR_bool_36_then | 864 ( 1.3%) | 960 ( 1.7%) | 192 ( 4.7%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ······_binop_Neq__LboolR_bool_59_while_loop | 16759 ( 25.8%) | 16088 ( 27.8%) | 1597 ( 39.2%) | 0 ( 0.0%) | 20 ( 0.7%) |
| ········_binop_Lt__LboolR_bool_70_while_loop | 16444 ( 25.3%) | 15830 ( 27.4%) | 1582 ( 38.9%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ··········_binop_Neq__LboolR_bool_75_while_loop | 15252 ( 23.5%) | 14870 ( 25.7%) | 1551 ( 38.1%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ··········tasmlib_arithmetic_u32_safemul | 279 ( 0.4%) | 217 ( 0.4%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ····bfe_new_from_u64 | 6 ( 0.0%) | 3 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ····_binop_Lt__LboolR_bool_152_while_loop | 1385 ( 2.3%) | 1350 ( 2.5%) | 192 ( 4.7%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ··_binop_Lt__LboolR_bool_206_while_loop | 1673 ( 2.7%) | 1542 ( 2.8%) | 192 ( 4.7%) | 0 ( 0.0%) | 0 ( 0.0%) |
| Total | 61377 (100.0%) | 54294 (100.0%) | 4069 (100.0%) | 594 (100.0%) | 1711 (100.0%) |
| ····_binop_Lt__LboolR_bool_152_while_loop | 1641 ( 2.5%) | 1606 ( 2.8%) | 192 ( 4.7%) | 0 ( 0.0%) | 0 ( 0.0%) |
| ··_binop_Lt__LboolR_bool_206_while_loop | 1929 ( 3.0%) | 1798 ( 3.1%) | 192 ( 4.7%) | 0 ( 0.0%) | 0 ( 0.0%) |
| Total | 64961 (100.0%) | 57878 (100.0%) | 4069 (100.0%) | 642 (100.0%) | 2735 (100.0%) |
Loading

0 comments on commit c2f9963

Please sign in to comment.