# Changeset 25404c7

Ignore:
Timestamp:
Jul 5, 2022, 9:36:59 AM (3 months ago)
Branches:
Children:
d4b37ab
Parents:
06bdba4 (diff), 9c6443e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Files:
13 edited

Unmodified
Removed
• ## doc/theses/thierry_delisle_PhD/thesis/Makefile

 r06bdba4 base \ base_avg \ base_ts2 \ cache-share \ cache-noshare \
• ## doc/theses/thierry_delisle_PhD/thesis/fig/base.fig

 r06bdba4 1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6975 4200 20 20 6975 4200 6995 4200 -6 6 6375 5100 6675 5250 1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6450 5175 20 20 6450 5175 6470 5175 1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6525 5175 20 20 6525 5175 6545 5175 1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6600 5175 20 20 6600 5175 6620 5175 6 6450 5025 6750 5175 1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6525 5100 20 20 6525 5100 6545 5100 1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6600 5100 20 20 6600 5100 6620 5100 1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6675 5100 20 20 6675 5100 6695 5100 -6 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 3900 2400 300 300 3900 2400 4200 2400 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 2400 2475 3000 2475 2 3 0 1 0 7 50 -1 -1 0.000 0 0 0 0 0 7 3300 5210 3150 4950 2850 4950 2700 5210 2850 5470 3150 5470 3300 5210 2 3 0 1 0 7 50 -1 -1 0.000 0 0 0 0 0 7 4500 5210 4350 4950 4050 4950 3900 5210 4050 5470 4350 5470 4500 5210 2 3 0 1 0 7 50 -1 -1 0.000 0 0 0 0 0 7 5700 5210 5550 4950 5250 4950 5100 5210 5250 5470 5550 5470 5700 5210 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 3600 5700 3600 1200 3600 5400 3600 1200 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 4800 5700 4800 1200 4800 5400 4800 1200 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 6000 5700 6000 1200 4 2 -1 50 -1 0 12 0.0000 2 135 630 2100 3075 Threads\001 4 2 -1 50 -1 0 12 0.0000 2 165 450 2100 2850 Ready\001 4 1 -1 50 -1 0 11 0.0000 2 135 180 2700 4450 TS\001 4 2 -1 50 -1 0 12 0.0000 2 165 720 2100 4200 Array of\001 4 2 -1 50 -1 0 12 0.0000 2 150 540 2100 4425 Queues\001 4 1 -1 50 -1 0 11 0.0000 2 135 180 2700 3550 TS\001 4 1 -1 50 -1 0 11 0.0000 2 135 180 2700 2650 TS\001 4 2 -1 50 -1 0 12 0.0000 2 135 900 2100 5175 Processors\001 6000 5400 6000 1200 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 2700 4800 3300 4800 3300 5400 2700 5400 2700 4800 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 3900 4800 4500 4800 4500 5400 3900 5400 3900 4800 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 5100 4800 5700 4800 5700 5400 5100 5400 5100 4800 4 2 -1 50 -1 0 12 0.0000 2 135 645 2100 3075 Threads\001 4 2 -1 50 -1 0 12 0.0000 2 180 525 2100 2850 Ready\001 4 1 -1 50 -1 0 11 0.0000 2 120 210 2700 4450 TS\001 4 2 -1 50 -1 0 12 0.0000 2 180 660 2100 4200 Array of\001 4 2 -1 50 -1 0 12 0.0000 2 165 600 2100 4425 Queues\001 4 1 -1 50 -1 0 11 0.0000 2 120 210 2700 3550 TS\001 4 2 -1 50 -1 0 12 0.0000 2 135 840 2100 5175 Processors\001
• ## doc/theses/thierry_delisle_PhD/thesis/fig/base_avg.fig

 r06bdba4 1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6975 4200 20 20 6975 4200 6995 4200 -6 6 6375 5100 6675 5250 1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6450 5175 20 20 6450 5175 6470 5175 1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6525 5175 20 20 6525 5175 6545 5175 1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6600 5175 20 20 6600 5175 6620 5175 6 6450 5025 6750 5175 1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6525 5100 20 20 6525 5100 6545 5100 1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6600 5100 20 20 6600 5100 6620 5100 1 3 0 1 0 0 50 -1 20 0.000 1 0.0000 6675 5100 20 20 6675 5100 6695 5100 -6 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 3900 2400 300 300 3900 2400 4200 2400 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 1 1 1.00 45.00 90.00 3900 3975 3900 3600 3900 4200 3900 3600 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 1 1 1.00 45.00 90.00 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 1 1 1.00 45.00 90.00 5100 3975 5100 3600 5100 4200 5100 3600 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 1 1 1.00 45.00 90.00 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 1 1 1.00 45.00 90.00 6300 3975 6300 3600 6300 4200 6300 3600 2 1 0 1 -1 7 50 -1 -1 0.000 0 0 -1 1 0 2 1 1 1.00 45.00 90.00 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 1 1 1.00 45.00 90.00 4500 3975 4500 3600 4500 4200 4500 3600 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 2400 3375 3000 3375 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 2400 2475 3000 2475 2 3 0 1 0 7 50 -1 -1 0.000 0 0 0 0 0 7 3300 5210 3150 4950 2850 4950 2700 5210 2850 5470 3150 5470 3300 5210 2 3 0 1 0 7 50 -1 -1 0.000 0 0 0 0 0 7 4500 5210 4350 4950 4050 4950 3900 5210 4050 5470 4350 5470 4500 5210 2 3 0 1 0 7 50 -1 -1 0.000 0 0 0 0 0 7 5700 5210 5550 4950 5250 4950 5100 5210 5250 5470 5550 5470 5700 5210 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 3600 5700 3600 1200 3600 5400 3600 1200 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 4800 5700 4800 1200 4800 5400 4800 1200 2 1 1 1 0 7 50 -1 -1 4.000 0 0 -1 0 0 2 6000 5700 6000 1200 6000 5400 6000 1200 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 2700 4800 3300 4800 3300 5400 2700 5400 2700 4800 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 3900 4800 4500 4800 4500 5400 3900 5400 3900 4800 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 5100 4800 5700 4800 5700 5400 5100 5400 5100 4800 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 2400 4050 3000 4050 4 2 -1 50 -1 0 12 0.0000 2 135 630 2100 3075 Threads\001 4 2 -1 50 -1 0 12 0.0000 2 165 450 2100 2850 Ready\001 4 1 -1 50 -1 0 11 0.0000 2 135 180 2700 4450 MA\001 4 2 -1 50 -1 0 12 0.0000 2 165 720 2100 4200 Array of\001 4 2 -1 50 -1 0 12 0.0000 2 150 540 2100 4425 Queues\001 4 1 -1 50 -1 0 11 0.0000 2 135 180 2700 3550 TS\001 4 1 -1 50 -1 0 11 0.0000 2 135 180 2700 2650 TS\001 4 2 -1 50 -1 0 12 0.0000 2 135 900 2100 5175 Processors\001 4 1 -1 50 -1 0 11 0.0000 2 135 180 2700 4200 TS\001 4 2 -1 50 -1 0 12 0.0000 2 135 645 2100 3075 Threads\001 4 2 -1 50 -1 0 12 0.0000 2 180 525 2100 2850 Ready\001 4 1 -1 50 -1 0 11 0.0000 2 120 300 2700 4450 MA\001 4 2 -1 50 -1 0 12 0.0000 2 180 660 2100 4200 Array of\001 4 2 -1 50 -1 0 12 0.0000 2 165 600 2100 4425 Queues\001 4 1 -1 50 -1 0 11 0.0000 2 120 210 2700 3550 TS\001 4 2 -1 50 -1 0 12 0.0000 2 135 840 2100 5175 Processors\001 4 1 -1 50 -1 0 11 0.0000 2 120 210 2700 4225 TS\001
• ## doc/theses/thierry_delisle_PhD/thesis/fig/cache-noshare.fig

 r06bdba4 -2 1200 2 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 2550 2550 456 456 2550 2550 2100 2475 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 3750 2550 456 456 3750 2550 3300 2475 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 4950 2550 456 456 4950 2550 4500 2475 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 6150 2550 456 456 6150 2550 5700 2475 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 1650 1650 456 456 1650 1650 1200 1575 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 2850 1650 456 456 2850 1650 2400 1575 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 4050 1650 456 456 4050 1650 3600 1575 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 5250 1650 456 456 5250 1650 4800 1575 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 2100 3300 3000 3300 3000 3600 2100 3600 2100 3300 1200 2400 2100 2400 2100 2700 1200 2700 1200 2400 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 2100 3900 3000 3900 3000 4500 2100 4500 2100 3900 1200 3000 2100 3000 2100 3600 1200 3600 1200 3000 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 3300 3300 4200 3300 4200 3600 3300 3600 3300 3300 2400 2400 3300 2400 3300 2700 2400 2700 2400 2400 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 3300 3900 4200 3900 4200 4500 3300 4500 3300 3900 2400 3000 3300 3000 3300 3600 2400 3600 2400 3000 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 4500 3300 5400 3300 5400 3600 4500 3600 4500 3300 3600 2400 4500 2400 4500 2700 3600 2700 3600 2400 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 4500 3900 5400 3900 5400 4500 4500 4500 4500 3900 3600 3000 4500 3000 4500 3600 3600 3600 3600 3000 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 5700 3300 6600 3300 6600 3600 5700 3600 5700 3300 4800 2400 5700 2400 5700 2700 4800 2700 4800 2400 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 5700 3900 6600 3900 6600 4500 5700 4500 5700 3900 4800 3000 5700 3000 5700 3600 4800 3600 4800 3000 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 2100 4800 4200 4800 4200 5700 2100 5700 2100 4800 1200 3900 3300 3900 3300 4800 1200 4800 1200 3900 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 4500 4800 6600 4800 6600 5700 4500 5700 4500 4800 3600 3900 5700 3900 5700 4800 3600 4800 3600 3900 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 2550 3000 2550 3300 1650 2100 1650 2400 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 6150 3000 6150 3300 5250 2100 5250 2400 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 6150 3600 6150 3900 5250 2700 5250 3000 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 3750 3000 3750 3300 2850 2100 2850 2400 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 4950 3000 4950 3300 4050 2100 4050 2400 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 4950 3600 4950 3900 4050 2700 4050 3000 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 3750 3600 3750 3900 1650 2700 1650 3000 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 2550 3600 2550 3900 1650 3600 1650 3900 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 2550 4500 2550 4800 2850 3600 2850 3900 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 3750 4500 3750 4800 4050 3600 4050 3900 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 4950 4500 4950 4800 5250 3600 5250 3900 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 6150 4500 6150 4800 3300 4350 3600 4350 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 4200 5250 4500 5250 4 0 0 50 -1 0 11 0.0000 2 135 360 4725 2625 CPU2\001 4 0 0 50 -1 0 11 0.0000 2 135 360 2325 2625 CPU0\001 4 0 0 50 -1 0 11 0.0000 2 135 360 5925 2625 CPU3\001 4 0 0 50 -1 0 11 0.0000 2 135 360 3525 2625 CPU1\001 4 0 0 50 -1 0 11 0.0000 2 135 180 2475 3525 L1\001 4 0 0 50 -1 0 11 0.0000 2 135 180 4875 3525 L1\001 4 0 0 50 -1 0 11 0.0000 2 135 180 6075 3525 L1\001 4 0 0 50 -1 0 11 0.0000 2 135 180 2400 4275 L2\001 4 0 0 50 -1 0 11 0.0000 2 135 180 4875 4275 L2\001 4 0 0 50 -1 0 11 0.0000 2 135 180 3675 4275 L2\001 4 0 0 50 -1 0 11 0.0000 2 135 180 6075 4275 L2\001 4 0 0 50 -1 0 11 0.0000 2 135 180 3675 3525 L1\001 4 0 0 50 -1 0 11 0.0000 2 135 180 3000 5250 L3\001 4 0 0 50 -1 0 11 0.0000 2 135 180 5475 5250 L3\001 2850 2700 2850 3000 4 1 0 50 -1 0 12 0.0000 2 165 945 1650 1725 CORE$_0$\001 4 1 0 50 -1 0 12 0.0000 2 135 225 2250 4425 L3\001 4 1 0 50 -1 0 12 0.0000 2 135 225 4650 4425 L3\001 4 1 0 50 -1 0 12 0.0000 2 135 225 5250 3375 L2\001 4 1 0 50 -1 0 12 0.0000 2 135 225 4050 3375 L2\001 4 1 0 50 -1 0 12 0.0000 2 135 225 2850 3375 L2\001 4 1 0 50 -1 0 12 0.0000 2 135 225 1650 3375 L2\001 4 1 0 50 -1 0 12 0.0000 2 135 225 1650 2625 L1\001 4 1 0 50 -1 0 12 0.0000 2 135 225 2850 2625 L1\001 4 1 0 50 -1 0 12 0.0000 2 135 225 4050 2625 L1\001 4 1 0 50 -1 0 12 0.0000 2 135 225 5250 2625 L1\001 4 1 0 50 -1 0 12 0.0000 2 165 945 2850 1725 CORE$_1$\001 4 1 0 50 -1 0 12 0.0000 2 165 945 4050 1725 CORE$_2$\001 4 1 0 50 -1 0 12 0.0000 2 165 945 5250 1725 CORE$_3$\001
• ## doc/theses/thierry_delisle_PhD/thesis/fig/cache-share.fig

 r06bdba4 -2 1200 2 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 2550 2550 456 456 2550 2550 2100 2475 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 3750 2550 456 456 3750 2550 3300 2475 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 4950 2550 456 456 4950 2550 4500 2475 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 6150 2550 456 456 6150 2550 5700 2475 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 1650 1650 456 456 1650 1650 1200 1575 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 4050 1650 456 456 4050 1650 3600 1575 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 5250 1650 456 456 5250 1650 4800 1575 1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 2850 1650 456 456 2850 1650 2400 1575 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 2100 3300 3000 3300 3000 3600 2100 3600 2100 3300 1200 2400 2100 2400 2100 2700 1200 2700 1200 2400 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 2100 3900 3000 3900 3000 4500 2100 4500 2100 3900 1200 3000 2100 3000 2100 3600 1200 3600 1200 3000 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 3300 3300 4200 3300 4200 3600 3300 3600 3300 3300 2400 2400 3300 2400 3300 2700 2400 2700 2400 2400 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 3300 3900 4200 3900 4200 4500 3300 4500 3300 3900 2400 3000 3300 3000 3300 3600 2400 3600 2400 3000 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 4500 3300 5400 3300 5400 3600 4500 3600 4500 3300 3600 2400 4500 2400 4500 2700 3600 2700 3600 2400 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 4500 3900 5400 3900 5400 4500 4500 4500 4500 3900 3600 3000 4500 3000 4500 3600 3600 3600 3600 3000 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 5700 3300 6600 3300 6600 3600 5700 3600 5700 3300 4800 2400 5700 2400 5700 2700 4800 2700 4800 2400 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 5700 3900 6600 3900 6600 4500 5700 4500 5700 3900 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 2100 4800 6600 4800 6600 5775 2100 5775 2100 4800 4800 3000 5700 3000 5700 3600 4800 3600 4800 3000 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 2550 3000 2550 3300 1650 2100 1650 2400 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 3750 3000 3750 3300 2850 2100 2850 2400 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 4950 3000 4950 3300 4050 2100 4050 2400 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 6150 3000 6150 3300 5250 2100 5250 2400 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 6150 3600 6150 3900 5250 2700 5250 3000 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 4950 3600 4950 3900 4050 2700 4050 3000 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 3750 3600 3750 3900 2850 2700 2850 3000 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 2550 3600 2550 3900 1650 2700 1650 3000 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 2550 4500 2550 4800 1650 3600 1650 3900 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 3750 4500 3750 4800 2850 3600 2850 3900 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 4950 4500 4950 4800 4050 3600 4050 3900 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 1 2 1 1 1.00 60.00 45.00 1 1 1.00 60.00 45.00 6150 4500 6150 4800 4 0 0 50 -1 0 11 0.0000 2 135 360 4725 2625 CPU2\001 4 0 0 50 -1 0 11 0.0000 2 135 360 2325 2625 CPU0\001 4 0 0 50 -1 0 11 0.0000 2 135 360 5925 2625 CPU3\001 4 0 0 50 -1 0 11 0.0000 2 135 360 3525 2625 CPU1\001 4 0 0 50 -1 0 11 0.0000 2 135 180 2475 3525 L1\001 4 0 0 50 -1 0 11 0.0000 2 135 180 4875 3525 L1\001 4 0 0 50 -1 0 11 0.0000 2 135 180 6075 3525 L1\001 4 0 0 50 -1 0 11 0.0000 2 135 180 2400 4275 L2\001 4 0 0 50 -1 0 11 0.0000 2 135 180 4875 4275 L2\001 4 0 0 50 -1 0 11 0.0000 2 135 180 3675 4275 L2\001 4 0 0 50 -1 0 11 0.0000 2 135 180 6075 4275 L2\001 4 0 0 50 -1 0 11 0.0000 2 135 180 3675 3525 L1\001 4 0 0 50 -1 0 11 0.0000 2 135 180 4275 5325 L3\001 5250 3600 5250 3900 2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5 1200 3900 5700 3900 5700 4800 1200 4800 1200 3900 4 1 0 50 -1 0 12 0.0000 2 135 225 3450 4425 L3\001 4 1 0 50 -1 0 12 0.0000 2 135 225 1650 3375 L2\001 4 1 0 50 -1 0 12 0.0000 2 135 225 2850 3375 L2\001 4 1 0 50 -1 0 12 0.0000 2 135 225 4050 3375 L2\001 4 1 0 50 -1 0 12 0.0000 2 135 225 5250 3375 L2\001 4 1 0 50 -1 0 12 0.0000 2 135 225 5250 2625 L1\001 4 1 0 50 -1 0 12 0.0000 2 135 225 4050 2625 L1\001 4 1 0 50 -1 0 12 0.0000 2 135 225 2850 2625 L1\001 4 1 0 50 -1 0 12 0.0000 2 135 225 1650 2625 L1\001 4 1 0 50 -1 0 12 0.0000 2 165 945 1650 1725 CORE$_0$\001 4 1 0 50 -1 0 12 0.0000 2 165 945 2850 1725 CORE$_1$\001 4 1 0 50 -1 0 12 0.0000 2 165 945 4050 1725 CORE$_2$\001 4 1 0 50 -1 0 12 0.0000 2 165 945 5250 1725 CORE$_3$\001
• ## doc/theses/thierry_delisle_PhD/thesis/text/core.tex

 r06bdba4 \chapter{Scheduling Core}\label{core} Before discussing scheduling in general, where it is important to address systems that are changing states, this document discusses scheduling in a somewhat ideal scenario, where the system has reached a steady state. For this purpose, a steady state is loosely defined as a state where there are always \glspl{thrd} ready to run and the system has the resources necessary to accomplish the work, \eg, enough workers. In short, the system is neither overloaded nor underloaded. It is important to discuss the steady state first because it is the easiest case to handle and, relatedly, the case in which the best performance is to be expected. As such, when the system is either overloaded or underloaded, a common approach is to try to adapt the system to this new load and return to the steady state, \eg, by adding or removing workers. Therefore, flaws in scheduling the steady state tend to be pervasive in all states. Before discussing scheduling in general, where it is important to address systems that are changing states, this document discusses scheduling in a somewhat ideal scenario, where the system has reached a steady state. For this purpose, a steady state is loosely defined as a state where there are always \glspl{thrd} ready to run and the system has the resources necessary to accomplish the work, \eg, enough workers. In short, the system is neither overloaded nor underloaded. It is important to discuss the steady state first because it is the easiest case to handle and, relatedly, the case in which the best performance is to be expected. As such, when the system is either overloaded or underloaded, a common approach is to try to adapt the system to this new load and return to the steady state, \eg, by adding or removing workers. Therefore, flaws in scheduling the steady state tend to be pervasive in all states. \section{Design Goals} As with most of the design decisions behind \CFA, an important goal is to match the expectation of the programmer according to their execution mental-model. To match expectations, the design must offer the programmer sufficient guarantees so that, as long as they respect the execution mental-model, the system also respects this model. As with most of the design decisions behind \CFA, an important goal is to match the expectation of the programmer according to their execution mental-model. To match expectations, the design must offer the programmer sufficient guarantees so that, as long as they respect the execution mental-model, the system also respects this model. For threading, a simple and common execution mental-model is the Ideal multi-tasking CPU'' : Applied to threads, this model states that every ready \gls{thrd} immediately runs in parallel with all other ready \glspl{thrd}. While a strict implementation of this model is not feasible, programmers still have expectations about scheduling that come from this model. In general, the expectation at the center of this model is that ready \glspl{thrd} do not interfere with each other but simply share the hardware. This assumption makes it easier to reason about threading because ready \glspl{thrd} can be thought of in isolation and the effect of the scheduler can be virtually ignored. This expectation of \gls{thrd} independence means the scheduler is expected to offer two guarantees: In general, the expectation at the center of this model is that ready \glspl{thrd} do not interfere with each other but simply share the hardware. This assumption makes it easier to reason about threading because ready \glspl{thrd} can be thought of in isolation and the effect of the scheduler can be virtually ignored. This expectation of \gls{thrd} independence means the scheduler is expected to offer two guarantees: \begin{enumerate} \item A fairness guarantee: a \gls{thrd} that is ready to run is not prevented by another thread. \end{enumerate} It is important to note that these guarantees are expected only up to a point. \Glspl{thrd} that are ready to run should not be prevented to do so, but they still share the limited hardware resources. Therefore, the guarantee is considered respected if a \gls{thrd} gets access to a \emph{fair share} of the hardware resources, even if that share is very small. Similarly the performance guarantee, the lack of interference among threads, is only relevant up to a point. Ideally, the cost of running and blocking should be constant regardless of contention, but the guarantee is considered satisfied if the cost is not \emph{too high} with or without contention. How much is an acceptable cost is obviously highly variable. For this document, the performance experimentation attempts to show the cost of scheduling is at worst equivalent to existing algorithms used in popular languages. This demonstration can be made by comparing applications built in \CFA to applications built with other languages or other models. Recall programmer expectation is that the impact of the scheduler can be ignored. Therefore, if the cost of scheduling is compatitive to other popular languages, the guarantee will be consider achieved. It is important to note that these guarantees are expected only up to a point. \Glspl{thrd} that are ready to run should not be prevented to do so, but they still share the limited hardware resources. Therefore, the guarantee is considered respected if a \gls{thrd} gets access to a \emph{fair share} of the hardware resources, even if that share is very small. Similar to the performance guarantee, the lack of interference among threads is only relevant up to a point. Ideally, the cost of running and blocking should be constant regardless of contention, but the guarantee is considered satisfied if the cost is not \emph{too high} with or without contention. How much is an acceptable cost is obviously highly variable. For this document, the performance experimentation attempts to show the cost of scheduling is at worst equivalent to existing algorithms used in popular languages. This demonstration can be made by comparing applications built in \CFA to applications built with other languages or other models. Recall programmer expectation is that the impact of the scheduler can be ignored. Therefore, if the cost of scheduling is competitive to other popular languages, the guarantee is consider achieved. More precisely the scheduler should be: \begin{itemize} \subsection{Fairness Goals} For this work fairness will be considered as having two strongly related requirements: true starvation freedom and fast'' load balancing. \paragraph{True starvation freedom} is more easily defined: As long as at least one \proc continues to dequeue \ats, all read \ats should be able to run eventually. In any running system, \procs can stop dequeing \ats if they start running a \at that will simply never park. Traditional workstealing schedulers do not have starvation freedom in these cases. For this work, fairness is considered to have two strongly related requirements: true starvation freedom and fast'' load balancing. \paragraph{True starvation freedom} means as long as at least one \proc continues to dequeue \ats, all ready \ats should be able to run eventually, \ie, eventual progress. In any running system, a \proc can stop dequeuing \ats if it starts running a \at that never blocks. Without preemption, traditional work-stealing schedulers do not have starvation freedom in this case. Now this requirement begs the question, what about preemption? Generally speaking preemption happens on the timescale of several milliseconds, which brings us to the next requirement: fast'' load balancing. \paragraph{Fast load balancing} means that load balancing should happen faster than preemption would normally allow. For interactive applications that need to run at 60, 90, 120 frames per second, \ats having to wait for several millseconds to run are effectively starved. For interactive applications that need to run at 60, 90, 120 frames per second, \ats having to wait for several milliseconds to run are effectively starved. Therefore load-balancing should be done at a faster pace, one that can detect starvation at the microsecond scale. With that said, this is a much fuzzier requirement since it depends on the number of \procs, the number of \ats and the general load of the system. \subsection{Fairness vs Scheduler Locality} \label{fairnessvlocal} An important performance factor in modern architectures is cache locality. Waiting for data at lower levels or not present in the cache can have a major impact on performance. Having multiple \glspl{hthrd} writing to the same cache lines also leads to cache lines that must be waited on. It is therefore preferable to divide data among each \gls{hthrd}\footnote{This partitioning can be an explicit division up front or using data structures where different \glspl{hthrd} are naturally routed to different cache lines.}. For a scheduler, having good locality\footnote{This section discusses \emph{internal locality}, \ie, the locality of the data used by the scheduler versus \emph{external locality}, \ie, how the data used by the application is affected by scheduling. External locality is a much more complicated subject and is discussed in the next section.}, \ie, having the data local to each \gls{hthrd}, generally conflicts with fairness. Indeed, good locality often requires avoiding the movement of cache lines, while fairness requires dynamically moving a \gls{thrd}, and as consequence cache lines, to a \gls{hthrd} that is currently available. However, I claim that in practice it is possible to strike a balance between fairness and performance because these goals do not necessarily overlap temporally, where Figure~\ref{fig:fair} shows a visual representation of this behaviour. As mentioned, some unfairness is acceptable; therefore it is desirable to have an algorithm that prioritizes cache locality as long as thread delay does not exceed the execution mental-model. An important performance factor in modern architectures is cache locality. Waiting for data at lower levels or not present in the cache can have a major impact on performance. Having multiple \glspl{hthrd} writing to the same cache lines also leads to cache lines that must be waited on. It is therefore preferable to divide data among each \gls{hthrd}\footnote{This partitioning can be an explicit division up front or using data structures where different \glspl{hthrd} are naturally routed to different cache lines.}. For a scheduler, having good locality, \ie, having the data local to each \gls{hthrd}, generally conflicts with fairness. Indeed, good locality often requires avoiding the movement of cache lines, while fairness requires dynamically moving a \gls{thrd}, and as consequence cache lines, to a \gls{hthrd} that is currently available. Note that this section discusses \emph{internal locality}, \ie, the locality of the data used by the scheduler versus \emph{external locality}, \ie, how the data used by the application is affected by scheduling. External locality is a much more complicated subject and is discussed in the next section. However, I claim that in practice it is possible to strike a balance between fairness and performance because these goals do not necessarily overlap temporally. Figure~\ref{fig:fair} shows a visual representation of this behaviour. As mentioned, some unfairness is acceptable; therefore it is desirable to have an algorithm that prioritizes cache locality as long as thread delay does not exceed the execution mental-model. \begin{figure} \input{fairness.pstex_t} \vspace*{-10pt} \caption[Fairness vs Locality graph]{Rule of thumb Fairness vs Locality graph \smallskip\newline The importance of Fairness and Locality while a ready \gls{thrd} awaits running is shown as the time the ready \gls{thrd} waits increases, Ready Time, the chances that its data is still in cache, Locality, decreases. At the same time, the need for fairness increases since other \glspl{thrd} may have the chance to run many times, breaking the fairness model. Since the actual values and curves of this graph can be highly variable, the graph is an idealized representation of the two opposing goals.} \caption[Fairness vs Locality graph]{Rule of thumb Fairness vs Locality graph \smallskip\newline The importance of Fairness and Locality while a ready \gls{thrd} awaits running is shown as the time the ready \gls{thrd} waits increases, Ready Time, the chances that its data is still in cache decreases, Locality. At the same time, the need for fairness increases since other \glspl{thrd} may have the chance to run many times, breaking the fairness model. Since the actual values and curves of this graph can be highly variable, the graph is an idealized representation of the two opposing goals.} \label{fig:fair} \end{figure} \subsection{Performance Challenges}\label{pref:challenge} While there exists a multitude of potential scheduling algorithms, they generally always have to contend with the same performance challenges. Since these challenges are recurring themes in the design of a scheduler it is relevant to describe the central ones here before looking at the design. While there exists a multitude of potential scheduling algorithms, they generally always have to contend with the same performance challenges. Since these challenges are recurring themes in the design of a scheduler it is relevant to describe the central ones here before looking at the design. \subsubsection{Scalability} Given a large number of \procs and an even larger number of \ats, scalability measures how fast \procs can enqueue and dequeues \ats. One could expect that doubling the number of \procs would double the rate at which \ats are dequeued, but contention on the internal data structure of the scheduler can lead to worst improvements. While the ready-queue itself can be sharded to alleviate the main source of contention, auxillary scheduling features, \eg counting ready \ats, can also be sources of contention. While the ready-queue itself can be sharded to alleviate the main source of contention, auxiliary scheduling features, \eg counting ready \ats, can also be sources of contention. \subsubsection{Migration Cost} Another important source of latency in scheduling is migration. An \at is said to have migrated if it is executed by two different \proc consecutively, which is the process discussed in \ref{fairnessvlocal}. Migrations can have many different causes, but it certain programs it can be all but impossible to limit migrations. Chapter~\ref{microbench} for example, has a benchmark where any \at can potentially unblock any other \at, which can leat to \ats migrating more often than not. Because of this it is important to design the internal data structures of the scheduler to limit the latency penalty from migrations. Another important source of scheduling latency is migration. A \at migrates if it executes on two different \procs consecutively, which is the process discussed in \ref{fairnessvlocal}. Migrations can have many different causes, but in certain programs, it can be impossible to limit migration. Chapter~\ref{microbench} has a benchmark where any \at can potentially unblock any other \at, which can lead to \ats migrating frequently. Hence, it is important to design the internal data structures of the scheduler to limit any latency penalty from migrations. \section{Inspirations} In general, a na\"{i}ve \glsxtrshort{fifo} ready-queue does not scale with increased parallelism from \glspl{hthrd}, resulting in decreased performance. The problem is adding/removing \glspl{thrd} is a single point of contention. As shown in the evaluation sections, most production schedulers do scale when adding \glspl{hthrd}. The solution to this problem is to shard the ready-queue : create multiple sub-ready-queues that multiple \glspl{hthrd} can access and modify without interfering. Before going into the design of \CFA's scheduler proper, it is relevant to discuss two sharding solutions which served as the inspiration scheduler in this thesis. In general, a na\"{i}ve \glsxtrshort{fifo} ready-queue does not scale with increased parallelism from \glspl{hthrd}, resulting in decreased performance. The problem is a single point of contention when adding/removing \ats. As shown in the evaluation sections, most production schedulers do scale when adding \glspl{hthrd}. The solution to this problem is to shard the ready-queue: create multiple \emph{subqueues} forming the logical ready-queue and the subqueues are accessed by multiple \glspl{hthrd} without interfering. Before going into the design of \CFA's scheduler, it is relevant to discuss two sharding solutions that served as the inspiration scheduler in this thesis. \subsection{Work-Stealing} As mentioned in \ref{existing:workstealing}, a popular pattern shard the ready-queue is work-stealing. In this pattern each \gls{proc} has its own local ready-queue and \glspl{proc} only access each other's ready-queue if they run out of work on their local ready-queue. The interesting aspect of workstealing happen in easier scheduling cases, \ie enough work for everyone but no more and no load balancing needed. In these cases, work-stealing is close to optimal scheduling: it can achieve perfect locality and have no contention. As mentioned in \ref{existing:workstealing}, a popular sharding approach for the ready-queue is work-stealing. In this approach, each \gls{proc} has its own local subqueue and \glspl{proc} only access each other's subqueue if they run out of work on their local ready-queue. The interesting aspect of work stealing happens in the steady-state scheduling case, \ie all \glspl{proc} have work and no load balancing is needed. In this case, work stealing is close to optimal scheduling: it can achieve perfect locality and have no contention. On the other hand, work-stealing schedulers only attempt to do load-balancing when a \gls{proc} runs out of work. This means that the scheduler never balances unfair loads unless they result in a \gls{proc} running out of work. Chapter~\ref{microbench} shows that in pathological cases this problem can lead to indefinite starvation. Based on these observation, the conclusion is that a \emph{perfect} scheduler should behave very similarly to work-stealing in the easy cases, but should have more proactive load-balancing if the need arises. \subsection{Relaxed-Fifo} An entirely different scheme is to create a relaxed-FIFO'' queue as in \todo{cite Trevor's paper}. This approach forgos any ownership between \gls{proc} and ready-queue, and simply creates a pool of ready-queues from which the \glspl{proc} can pick from. \Glspl{proc} choose ready-queus at random, but timestamps are added to all elements of the queue and dequeues are done by picking two queues and dequeing the oldest element. All subqueues are protected by TryLocks and \procs simply pick a different subqueue if they fail to acquire the TryLock. The result is a queue that has both decent scalability and sufficient fairness. The lack of ownership means that as long as one \gls{proc} is still able to repeatedly dequeue elements, it is unlikely that any element will stay on the queue for much longer than any other element. This contrasts with work-stealing, where \emph{any} \gls{proc} busy for an extended period of time results in all the elements on its local queue to have to wait. Unless another \gls{proc} runs out of work. Chapter~\ref{microbench} shows that pathological cases work stealing can lead to indefinite starvation. Based on these observation, the conclusion is that a \emph{perfect} scheduler should behave similar to work-stealing in the steady-state case, but load balance proactively when the need arises. \subsection{Relaxed-FIFO} A different scheduling approach is to create a relaxed-FIFO'' queue, as in \todo{cite Trevor's paper}. This approach forgoes any ownership between \gls{proc} and subqueue, and simply creates a pool of ready-queues from which \glspl{proc} pick. Scheduling is performed as follows: \begin{itemize} \item All subqueues are protected by TryLocks. \item Timestamps are added to each element of a subqueue. \item A \gls{proc} randomly tests ready queues until it has acquired one or two queues. \item If two queues are acquired, the older of the two \ats at the front the acquired queues is dequeued. \item Otherwise the \ats from the single queue is dequeued. \end{itemize} The result is a queue that has both good scalability and sufficient fairness. The lack of ownership ensures that as long as one \gls{proc} is still able to repeatedly dequeue elements, it is unlikely any element will delay longer than any other element. This guarantee contrasts with work-stealing, where a \gls{proc} with a long subqueue results in unfairness for its \ats in comparison to a \gls{proc} with a short subqueue. This unfairness persists until a \gls{proc} runs out of work and steals. An important aspects of this scheme's fairness approach is that the timestamps make it possible to evaluate how long elements have been on the queue. However, another major aspect is that \glspl{proc} will eagerly search for these older elements instead of focusing on specific queues. While the fairness, of this scheme is good, it does suffer in terms of performance. It requires very wide sharding, \eg at least 4 queues per \gls{hthrd}, and finding non-empty queues can be difficult if there are too few ready \ats. However, \glspl{proc} eagerly search for these older elements instead of focusing on specific queues, which negatively affects locality. While this scheme has good fairness, its performance suffers. It requires wide sharding, \eg at least 4 queues per \gls{hthrd}, and finding non-empty queues is difficult when there are few ready \ats. \section{Relaxed-FIFO++} Since it has inherent fairness quelities and decent performance in the presence of many \ats, the relaxed-FIFO queue appears as a good candidate to form the basis of a scheduler. The most obvious problems is for workloads where the number of \ats is barely greater than the number of \procs. In these situations, the wide sharding means most of the sub-queues from which the relaxed queue is formed will be empty. The consequence is that when a dequeue operations attempts to pick a sub-queue at random, it is likely that it picks an empty sub-queue and will have to pick again. This problem can repeat an unbounded number of times. The inherent fairness and good performance with many \ats, makes the relaxed-FIFO queue a good candidate to form the basis of a new scheduler. The problem case is workloads where the number of \ats is barely greater than the number of \procs. In these situations, the wide sharding of the ready queue means most of its subqueues are empty. Furthermore, the non-empty subqueues are unlikely to hold more than one item. The consequence is that a random dequeue operation is likely to pick an empty subqueue, resulting in an unbounded number of selections. This state is generally unstable: each subqueue is likely to frequently toggle between being empty and nonempty. Indeed, when the number of \ats is \emph{equal} to the number of \procs, every pop operation is expected to empty a subqueue and every push is expected to add to an empty subqueue. In the worst case, a check of the subqueues sees all are empty or full. As this is the most obvious challenge, it is worth addressing first. The obvious solution is to supplement each subqueue with some sharded data structure that keeps track of which subqueues are empty. This data structure can take many forms, for example simple bitmask or a binary tree that tracks which branch are empty. Following a binary tree on each pick has fairly good Big O complexity and many modern architectures have powerful bitmask manipulation instructions. However, precisely tracking which sub-queues are empty is actually fundamentally problematic. The reason is that each subqueues are already a form of sharding and the sharding width has presumably already chosen to avoid contention. However, tracking which ready queue is empty is only useful if the tracking mechanism uses denser sharding than the sub queues, then it will invariably create a new source of contention. But if the tracking mechanism is not denser than the sub-queues, then it will generally not provide useful because reading this new data structure risks being as costly as simply picking a sub-queue at random. Early experiments with this approach have shown that even with low success rates, randomly picking a sub-queue can be faster than a simple tree walk. The obvious solution is to supplement each sharded subqueue with data that indicates if the queue is empty/nonempty to simplify finding nonempty queues, \ie ready \glspl{at}. This sharded data can be organized in different forms, \eg a bitmask or a binary tree that tracks the nonempty subqueues. Specifically, many modern architectures have powerful bitmask manipulation instructions or searching a binary tree has good Big-O complexity. However, precisely tracking nonempty subqueues is problematic. The reason is that the subqueues are initially sharded with a width presumably chosen to avoid contention. However, tracking which ready queue is nonempty is only useful if the tracking data is dense, \ie denser than the sharded subqueues. Otherwise, it does not provide useful information because reading this new data structure risks being as costly as simply picking a subqueue at random. But if the tracking mechanism \emph{is} denser than the shared subqueues, than constant updates invariably create a new source of contention. Early experiments with this approach showed that randomly picking, even with low success rates, is often faster than bit manipulations or tree walks. The exception to this rule is using local tracking. If each \proc keeps track locally of which sub-queue is empty, then this can be done with a very dense data structure without introducing a new source of contention. The consequence of local tracking however, is that the information is not complete. Each \proc is only aware of the last state it saw each subqueues but does not have any information about freshness. Even on systems with low \gls{hthrd} count, \eg 4 or 8, this can quickly lead to the local information being no better than the random pick. This is due in part to the cost of this maintaining this information and its poor quality. However, using a very low cost approach to local tracking may actually be beneficial. If the local tracking is no more costly than the random pick, than \emph{any} improvement to the succes rate, however low it is, would lead to a performance benefits. This leads to the following approach: If each \proc locally keeps track of empty subqueues, than this can be done with a very dense data structure without introducing a new source of contention. However, the consequence of local tracking is that the information is incomplete. Each \proc is only aware of the last state it saw about each subqueue so this information quickly becomes stale. Even on systems with low \gls{hthrd} count, \eg 4 or 8, this approach can quickly lead to the local information being no better than the random pick. This result is due in part to the cost of maintaining information and its poor quality. However, using a very low cost but inaccurate approach for local tracking can actually be beneficial. If the local tracking is no more costly than a random pick, than \emph{any} improvement to the success rate, however low it is, leads to a performance benefits. This suggests to the following approach: \subsection{Dynamic Entropy}\cit{https://xkcd.com/2318/} The Relaxed-FIFO approach can be made to handle the case of mostly empty sub-queues by tweaking the \glsxtrlong{prng}. The \glsxtrshort{prng} state can be seen as containing a list of all the future sub-queues that will be accessed. While this is not particularly useful on its own, the consequence is that if the \glsxtrshort{prng} algorithm can be run \emph{backwards}, then the state also contains a list of all the subqueues that were accessed. Luckily, bidirectional \glsxtrshort{prng} algorithms do exist, for example some Linear Congruential Generators\cit{https://en.wikipedia.org/wiki/Linear\_congruential\_generator} support running the algorithm backwards while offering good quality and performance. The Relaxed-FIFO approach can be made to handle the case of mostly empty subqueues by tweaking the \glsxtrlong{prng}. The \glsxtrshort{prng} state can be seen as containing a list of all the future subqueues that will be accessed. While this concept is not particularly useful on its own, the consequence is that if the \glsxtrshort{prng} algorithm can be run \emph{backwards}, then the state also contains a list of all the subqueues that were accessed. Luckily, bidirectional \glsxtrshort{prng} algorithms do exist, \eg some Linear Congruential Generators\cit{https://en.wikipedia.org/wiki/Linear\_congruential\_generator} support running the algorithm backwards while offering good quality and performance. This particular \glsxtrshort{prng} can be used as follows: Each \proc maintains two \glsxtrshort{prng} states, which whill be refered to as \texttt{F} and \texttt{B}. When a \proc attempts to dequeue a \at, it picks the subqueues by running the \texttt{B} backwards. When a \proc attempts to enqueue a \at, it runs \texttt{F} forward to pick to subqueue to enqueue to. If the enqueue is successful, the state \texttt{B} is overwritten with the content of \texttt{F}. The result is that each \proc will tend to dequeue \ats that it has itself enqueued. When most sub-queues are empty, this technique increases the odds of finding \ats at very low cost, while also offering an improvement on locality in many cases. However, while this approach does notably improve performance in many cases, this algorithm is still not competitive with work-stealing algorithms. \begin{itemize} \item Each \proc maintains two \glsxtrshort{prng} states, refereed to as $F$ and $B$. \item When a \proc attempts to dequeue a \at, it picks a subqueue by running $B$ backwards. \item When a \proc attempts to enqueue a \at, it runs $F$ forward picking a subqueue to enqueue to. If the enqueue is successful, the state $B$ is overwritten with the content of $F$. \end{itemize} The result is that each \proc tends to dequeue \ats that it has itself enqueued. When most subqueues are empty, this technique increases the odds of finding \ats at very low cost, while also offering an improvement on locality in many cases. Tests showed this approach performs better than relaxed-FIFO in many cases. However, it is still not competitive with work-stealing algorithms. The fundamental problem is that the constant randomness limits how much locality the scheduler offers. This becomes problematic both because the scheduler is likely to get cache misses on internal data-structures and because migration become very frequent. Therefore since the approach of modifying to relaxed-FIFO algorithm to behave more like work stealing does not seem to pan out, the alternative is to do it the other way around. This becomes problematic both because the scheduler is likely to get cache misses on internal data-structures and because migrations become frequent. Therefore, the attempt to modify the relaxed-FIFO algorithm to behave more like work stealing did not pan out. The alternative is to do it the other way around. \section{Work Stealing++} To add stronger fairness guarantees to workstealing a few changes. To add stronger fairness guarantees to work stealing a few changes are needed. First, the relaxed-FIFO algorithm has fundamentally better fairness because each \proc always monitors all subqueues. Therefore the workstealing algorithm must be prepended with some monitoring. Before attempting to dequeue from a \proc's local queue, the \proc must make some effort to make sure remote queues are not being neglected. To make this possible, \procs must be able to determie which \at has been on the ready-queue the longest. Which is the second aspect that much be added. The relaxed-FIFO approach uses timestamps for each \at and this is also what is done here. Therefore, the work-stealing algorithm must be prepended with some monitoring. Before attempting to dequeue from a \proc's subqueue, the \proc must make some effort to ensure other subqueues are not being neglected. To make this possible, \procs must be able to determine which \at has been on the ready queue the longest. Second, the relaxed-FIFO approach needs timestamps for each \at to make this possible. \begin{figure} \centering \input{base.pstex_t} \caption[Base \CFA design]{Base \CFA design \smallskip\newline A Pool of sub-ready queues offers the sharding, two per \glspl{proc}. Each \gls{proc} have local subqueues, however \glspl{proc} can access any of the sub-queues. Each \at is timestamped when enqueued.} \caption[Base \CFA design]{Base \CFA design \smallskip\newline A pool of subqueues offers the sharding, two per \glspl{proc}. Each \gls{proc} can access all of the subqueues. Each \at is timestamped when enqueued.} \label{fig:base} \end{figure} The algorithm is structure as shown in Figure~\ref{fig:base}. This is very similar to classic workstealing except the local queues are placed in an array so \procs can access eachother's queue in constant time. Sharding width can be adjusted based on need. When a \proc attempts to dequeue a \at, it first picks a random remote queue and compares its timestamp to the timestamps of the local queue(s), dequeue from the remote queue if needed. Implemented as as naively state above, this approach has some obvious performance problems. Figure~\ref{fig:base} shows the algorithm structure. This structure is similar to classic work-stealing except the subqueues are placed in an array so \procs can access them in constant time. Sharding width can be adjusted based on contention. Note, as an optimization, the TS of a \at is stored in the \at in front of it, so the first TS is in the array and the last \at has no TS. This organization keeps the highly accessed front TSs directly in the array. When a \proc attempts to dequeue a \at, it first picks a random remote subqueue and compares its timestamp to the timestamps of its local subqueue(s). The oldest waiting \at is dequeued to provide global fairness. However, this na\"ive implemented has performance problems. First, it is necessary to have some damping effect on helping. Random effects like cache misses and preemption can add spurious but short bursts of latency for which helping is not helpful, pun intended. The effect of these bursts would be to cause more migrations than needed and make this workstealing approach slowdown to the match the relaxed-FIFO approach. Random effects like cache misses and preemption can add spurious but short bursts of latency negating the attempt to help. These bursts can cause increased migrations and make this work stealing approach slowdown to the level of relaxed-FIFO. \begin{figure} \end{figure} A simple solution to this problem is to compare an exponential moving average\cit{https://en.wikipedia.org/wiki/Moving\_average\#Exponential\_moving\_average} instead if the raw timestamps, shown in Figure~\ref{fig:base-ma}. Note that this is slightly more complex than it sounds because since the \at at the head of a subqueue is still waiting, its wait time has not ended. Therefore the exponential moving average is actually an exponential moving average of how long each already dequeued \at have waited. To compare subqueues, the timestamp at the head must be compared to the current time, yielding the bestcase wait time for the \at at the head of the queue. A simple solution to this problem is to use an exponential moving average\cit{https://en.wikipedia.org/wiki/Moving\_average\#Exponential\_moving\_average} (MA) instead of a raw timestamps, shown in Figure~\ref{fig:base-ma}. Note, this is more complex because the \at at the head of a subqueue is still waiting, so its wait time has not ended. Therefore, the exponential moving average is actually an exponential moving average of how long each dequeued \at has waited. To compare subqueues, the timestamp at the head must be compared to the current time, yielding the best-case wait-time for the \at at the head of the queue. This new waiting is averaged with the stored average. To limit even more the amount of unnecessary migration, a bias can be added to the local queue, where a remote queue is helped only if its moving average is more than \emph{X} times the local queue's average. None of the experimentation that I have run with these scheduler seem to indicate that the choice of the weight for the moving average or the choice of bis is particularly important. Weigths and biases of similar \emph{magnitudes} have similar effects. With these additions to workstealing, scheduling can be made as fair as the relaxed-FIFO approach, well avoiding the majority of unnecessary migrations. Unfortunately, the performance of this approach does suffer in the cases with no risks of starvation. The problem is that the constant polling of remote subqueues generally entail a cache miss. To make things worst, remote subqueues that are very active, \ie \ats are frequently enqueued and dequeued from them, the higher the chances are that polling will incurr a cache-miss. Conversly, the active subqueues do not benefit much from helping since starvation is already a non-issue. This puts this algorithm in an akward situation where it is paying for a cost, but the cost itself suggests the operation was unnecessary. To further limit migration, a bias can be added to a local subqueue, where a remote subqueue is helped only if its moving average is more than $X$ times the local subqueue's average. Tests for this approach indicate the choice of the weight for the moving average or the bias is not important, \ie weights and biases of similar \emph{magnitudes} have similar effects. With these additions to work stealing, scheduling can be made as fair as the relaxed-FIFO approach, avoiding the majority of unnecessary migrations. Unfortunately, the work to achieve fairness has a performance cost, especially when the workload is inherently fair, and hence, there is only short-term or no starvation. The problem is that the constant polling, \ie reads, of remote subqueues generally entail a cache miss because the TSs are constantly being updated, \ie, writes. To make things worst, remote subqueues that are very active, \ie \ats are frequently enqueued and dequeued from them, lead to higher chances that polling will incur a cache-miss. Conversely, the active subqueues do not benefit much from helping since starvation is already a non-issue. This puts this algorithm in the awkward situation of paying for a cost that is largely unnecessary. The good news is that this problem can be mitigated \subsection{Redundant Timestamps} The problem with polling remote queues is due to a tension between the consistency requirement on the subqueue. For the subqueues, correctness is critical. There must be a consensus among \procs on which subqueues hold which \ats. Since the timestamps are use for fairness, it is alco important to have consensus and which \at is the oldest. However, when deciding if a remote subqueue is worth polling, correctness is much less of a problem. Since the only need is that a subqueue will eventually be polled, some data staleness can be acceptable. This leads to a tension where stale timestamps are only problematic in some cases. Furthermore, stale timestamps can be somewhat desirable since lower freshness requirements means less tension on the cache coherence protocol. \begin{figure} \centering % \input{base_ts2.pstex_t} \caption[\CFA design with Redundant Timestamps]{\CFA design with Redundant Timestamps \smallskip\newline A array is added containing a copy of the timestamps. These timestamps are written to with relaxed atomics, without fencing, leading to fewer cache invalidations.} \label{fig:base-ts2} \end{figure} A solution to this is to create a second array containing a copy of the timestamps and average. The problem with polling remote subqueues is that correctness is critical. There must be a consensus among \procs on which subqueues hold which \ats, as the \ats are in constant motion. Furthermore, since timestamps are use for fairness, it is critical to have consensus on which \at is the oldest. However, when deciding if a remote subqueue is worth polling, correctness is less of a problem. Since the only requirement is that a subqueue is eventually polled, some data staleness is acceptable. This leads to a situation where stale timestamps are only problematic in some cases. Furthermore, stale timestamps can be desirable since lower freshness requirements mean less cache invalidations. Figure~\ref{fig:base-ts2} shows a solution with a second array containing a copy of the timestamps and average. This copy is updated \emph{after} the subqueue's critical sections using relaxed atomics. \Glspl{proc} now check if polling is needed by comparing the copy of the remote timestamp instead of the actual timestamp. The result is that since there is no fencing, the writes can be buffered and cause fewer cache invalidations. The correctness argument here is somewhat subtle. The result is that since there is no fencing, the writes can be buffered in the hardware and cause fewer cache invalidations. \begin{figure} \centering \input{base_ts2.pstex_t} \caption[\CFA design with Redundant Timestamps]{\CFA design with Redundant Timestamps \smallskip\newline An array is added containing a copy of the timestamps. These timestamps are written to with relaxed atomics, so there is no order among concurrent memory accesses, leading to fewer cache invalidations.} \label{fig:base-ts2} \end{figure} The correctness argument is somewhat subtle. The data used for deciding whether or not to poll a queue can be stale as long as it does not cause starvation. Therefore, it is acceptable if stale data make queues appear older than they really are but not fresher. For the timestamps, this means that missing writes to the timestamp is acceptable since they will make the head \at look older. For the moving average, as long as the operation are RW-safe, the average is guaranteed to yield a value that is between the oldest and newest values written. Therefore this unprotected read of the timestamp and average satisfy the limited correctness that is required. Therefore, it is acceptable if stale data makes queues appear older than they really are but appearing fresher can be a problem. For the timestamps, this means missing writes to the timestamp is acceptable since they make the head \at look older. For the moving average, as long as the operations are just atomic reads/writes, the average is guaranteed to yield a value that is between the oldest and newest values written. Therefore, this unprotected read of the timestamp and average satisfy the limited correctness that is required. With redundant timestamps, this scheduling algorithm achieves both the fairness and performance requirements on most machines. The problem is that the cost of polling and helping is not necessarily consistent across each \gls{hthrd}. For example, on machines with a CPU containing multiple hyperthreads and cores and multiple CPU sockets, cache misses can be satisfied from the caches on same (local) CPU, or by a CPU on a different (remote) socket. Cache misses satisfied by a remote CPU have significantly higher latency than from the local CPU. However, these delays are not specific to systems with multiple CPUs. Depending on the cache structure, cache misses can have different latency on the same CPU, \eg the AMD EPYC 7662 CPUs used in Chapter~\ref{microbench}. \begin{figure} \centering \input{cache-share.pstex_t} \caption[CPU design with wide L3 sharing]{CPU design with wide L3 sharing \smallskip\newline A very simple CPU with 4 \glspl{hthrd}. L1 and L2 are private to each \gls{hthrd} but the L3 is shared across to entire core.} \caption[CPU design with wide L3 sharing]{CPU design with wide L3 sharing \smallskip\newline A CPU with 4 cores, where caches L1 and L2 are private to each core, and the L3 cache is shared across all cores.} \label{fig:cache-share} \end{figure} \begin{figure} \centering \vspace{25pt} \input{cache-noshare.pstex_t} \caption[CPU design with a narrower L3 sharing]{CPU design with a narrower L3 sharing \smallskip\newline A different CPU design, still with 4 \glspl{hthrd}. L1 and L2 are still private to each \gls{hthrd} but the L3 is shared some of the CPU but there is still two distinct L3 instances.} \caption[CPU design with a narrower L3 sharing]{CPU design with a narrow L3 sharing \smallskip\newline A CPU with 4 cores, where caches L1 and L2 are private to each core, and the L3 cache is shared across a pair of cores.} \label{fig:cache-noshare} \end{figure} With redundant tiemstamps this scheduling algorithm achieves both the fairness and performance requirements, on some machines. The problem is that the cost of polling and helping is not necessarily consistent across each \gls{hthrd}. For example, on machines where the motherboard holds multiple CPU, cache misses can be satisfied from a cache that belongs to the CPU that missed, the \emph{local} CPU, or by a different CPU, a \emph{remote} one. Cache misses that are satisfied by a remote CPU will have higher latency than if it is satisfied by the local CPU. However, this is not specific to systems with multiple CPUs. Depending on the cache structure, cache-misses can have different latency for the same CPU. The AMD EPYC 7662 CPUs that is described in Chapter~\ref{microbench} is an example of that. Figure~\ref{fig:cache-share} and Figure~\ref{fig:cache-noshare} show two different cache topologies with highlight this difference. In Figure~\ref{fig:cache-share}, all cache instances are either private to a \gls{hthrd} or shared to the entire system, this means latency due to cache-misses are likely fairly consistent. By comparison, in Figure~\ref{fig:cache-noshare} misses in the L2 cache can be satisfied by a hit in either instance of the L3. However, the memory access latency to the remote L3 instance will be notably higher than the memory access latency to the local L3. The impact of these different design on this algorithm is that scheduling will scale very well on architectures similar to Figure~\ref{fig:cache-share}, both will have notably worst scalling with many narrower L3 instances. This is simply because as the number of L3 instances grow, so two does the chances that the random helping will cause significant latency. The solution is to have the scheduler be aware of the cache topology. Figures~\ref{fig:cache-share} and~\ref{fig:cache-noshare} show two different cache topologies that highlight this difference. In Figure~\ref{fig:cache-share}, all cache misses are either private to a CPU or shared with another CPU. This means latency due to cache misses is fairly consistent. In contrast, in Figure~\ref{fig:cache-noshare} misses in the L2 cache can be satisfied by either instance of L3 cache. However, the memory-access latency to the remote L3 is higher than the memory-access latency to the local L3. The impact of these different designs on this algorithm is that scheduling only scales well on architectures with a wide L3 cache, similar to Figure~\ref{fig:cache-share}, and less well on architectures with many narrower L3 cache instances, similar to Figure~\ref{fig:cache-noshare}. Hence, as the number of L3 instances grow, so too does the chance that the random helping causes significant cache latency. The solution is for the scheduler be aware of the cache topology. \subsection{Per CPU Sharding} Building a scheduler that is aware of cache topology poses two main challenges: discovering cache topology and matching \procs to cache instance. Sadly, there is no standard portable way to discover cache topology in C. Therefore, while this is a significant portability challenge, it is outside the scope of this thesis to design a cross-platform cache discovery mechanisms. The rest of this work assumes discovering the cache topology based on Linux's \texttt{/sys/devices/system/cpu} directory. This leaves the challenge of matching \procs to cache instance, or more precisely identifying which subqueues of the ready queue are local to which cache instance. Once this matching is available, the helping algorithm can be changed to add bias so that \procs more often help subqueues local to the same cache instance \footnote{Note that like other biases mentioned in this section, the actual bias value does not appear to need precise tuinng.}. The obvious approach to mapping cache instances to subqueues is to statically tie subqueues to CPUs. Instead of having each subqueue local to a specific \proc, the system is initialized with subqueues for each \glspl{hthrd} up front. Then \procs dequeue and enqueue by first asking which CPU id they are local to, in order to identify which subqueues are the local ones. Building a scheduler that is cache aware poses two main challenges: discovering the cache topology and matching \procs to this cache structure. Unfortunately, there is no portable way to discover cache topology, and it is outside the scope of this thesis to solve this problem. This work uses the cache topology information from Linux's \texttt{/sys/devices/system/cpu} directory. This leaves the challenge of matching \procs to cache structure, or more precisely identifying which subqueues of the ready queue are local to which subcomponents of the cache structure. Once a matching is generated, the helping algorithm is changed to add bias so that \procs more often help subqueues local to the same cache substructure.\footnote{ Note that like other biases mentioned in this section, the actual bias value does not appear to need precise tuning.} The simplest approach for mapping subqueues to cache structure is to statically tie subqueues to CPUs. Instead of having each subqueue local to a specific \proc, the system is initialized with subqueues for each hardware hyperthread/core up front. Then \procs dequeue and enqueue by first asking which CPU id they are executing on, in order to identify which subqueues are the local ones. \Glspl{proc} can get the CPU id from \texttt{sched\_getcpu} or \texttt{librseq}. This approach solves the performance problems on systems with topologies similar to Figure~\ref{fig:cache-noshare}. However, it actually causes some subtle fairness problems in some systems, specifically systems with few \procs and many \glspl{hthrd}. In these cases, the large number of subqueues and the bias agains subqueues tied to different cache instances make it so it is very unlikely any single subqueue is picked. To make things worst, the small number of \procs mean that few helping attempts will be made. This combination of few attempts and low chances make it so a \at stranded on a subqueue that is not actively dequeued from may wait very long before it gets randomly helped. This approach solves the performance problems on systems with topologies with narrow L3 caches, similar to Figure \ref{fig:cache-noshare}. However, it can still cause some subtle fairness problems in systems with few \procs and many \glspl{hthrd}. In this case, the large number of subqueues and the bias against subqueues tied to different cache substructures make it unlikely that every subqueue is picked. To make things worst, the small number of \procs mean that few helping attempts are made. This combination of low selection and few helping attempts allow a \at to become stranded on a subqueue for a long time until it gets randomly helped. On a system with 2 \procs, 256 \glspl{hthrd} with narrow cache sharing, and a 100:1 bias, it can actually take multiple seconds for a \at to get dequeued from a remote queue. Therefore, a more dynamic matching of subqueues to cache instance is needed. \subsection{Topological Work Stealing} The approach that is used in the \CFA scheduler is to have per-\proc subqueue, but have an excplicit data-structure track which cache instance each subqueue is tied to. This is requires some finess because reading this data structure must lead to fewer cache misses than not having the data structure in the first place. Therefore, the approach used in the \CFA scheduler is to have per-\proc subqueues, but have an explicit data-structure track which cache substructure each subqueue is tied to. This tracking requires some finesse because reading this data structure must lead to fewer cache misses than not having the data structure in the first place. A key element however is that, like the timestamps for helping, reading the cache instance mapping only needs to give the correct result \emph{often enough}. Therefore the algorithm can be built as follows: Before enqueuing or dequeing a \at, each \proc queries the CPU id and the corresponding cache instance. Therefore the algorithm can be built as follows: before enqueueing or dequeuing a \at, each \proc queries the CPU id and the corresponding cache instance. Since subqueues are tied to \procs, each \proc can then update the cache instance mapped to the local subqueue(s). To avoid unnecessary cache line invalidation, the map is only written to if the mapping changes. This scheduler is used in the remainder of the thesis for managing CPU execution, but additional scheduling is needed to handle long-term blocking and unblocking, such as I/O.
• ## doc/theses/thierry_delisle_PhD/thesis/thesis.tex

 r06bdba4 \usepackage{graphicx} % For including graphics \usepackage{subcaption} \usepackage{comment} % Removes large sections of the document. % Hyperlinks make it very easy to navigate an electronic document.
• ## src/Common/Eval.cc

 r06bdba4 // Created On       : Mon May 18 07:44:20 2015 // Last Modified By : Peter A. Buhr // Last Modified On : Wed Jul 24 15:09:06 2019 // Update Count     : 64 // Last Modified On : Fri Jul  1 08:41:03 2022 // Update Count     : 117 // #include "Common/PassVisitor.h" #include "CodeGen/OperatorTable.h"                                              // access: OperatorInfo #include "AST/Pass.hpp" #include "InitTweak/InitTweak.h" // Old AST struct EvalOld : public WithShortCircuiting { long long int value = 0; bool valid = true; long long int value = 0;                                                        // compose the result of the constant expression bool valid = true;                                                                      // true => constant expression and value is the result // false => not constant expression, e.g., ++i bool cfavalid = true;                                                           // true => constant expression and value computable // false => constant expression but value not computable, e.g., sizeof(int) void previsit( const BaseSyntaxNode * ) { visit_children = false; } // New AST struct EvalNew : public ast::WithShortCircuiting { long long int value = 0; bool valid = true; long long int value = 0;                                                        // compose the result of the constant expression bool valid = true;                                                                      // true => constant expression and value is the result // false => not constant expression, e.g., ++i bool cfavalid = true;                                                           // true => constant expression and value computable // false => constant expression but value not computable, e.g., sizeof(int) void previsit( const ast::Node * ) { visit_children = false; } void postvisit( const ast::Node * ) { valid = false; } void postvisit( const ast::ConstantExpr * expr ) { void postvisit( const ast::Node * ) { cfavalid = valid = false; } void postvisit( const ast::UntypedExpr * ) { assertf( false, "UntypedExpr in constant expression evaluation" ); // FIX ME, resolve variable } void postvisit( const ast::ConstantExpr * expr ) {      // only handle int constants value = expr->intValue(); } void postvisit( const ast::SizeofExpr * expr ) { if ( expr->expr ) value = eval(expr->expr).first; else if ( expr->type ) value = eval(expr->expr).first; else SemanticError( expr->location, ::toString( "Internal error: SizeofExpr has no expression or type value" ) ); } void postvisit( const ast::CastExpr * expr ) { void postvisit( const ast::SizeofExpr * ) { // do not change valid or value => let C figure it out cfavalid = false; } void postvisit( const ast::AlignofExpr * ) { // do not change valid or value => let C figure it out cfavalid = false; } void postvisit( const ast::OffsetofExpr * ) { // do not change valid or value => let C figure it out cfavalid = false; } void postvisit( const ast::LogicalExpr * expr ) { std::pair arg1, arg2; arg1 = eval( expr->arg1 ); valid &= arg1.second; if ( ! valid ) return; arg2 = eval( expr->arg2 ); valid &= arg2.second; if ( ! valid ) return; if ( expr->isAnd ) { value = arg1.first && arg2.first; } else { value = arg1.first || arg2.first; } // if } void postvisit( const ast::ConditionalExpr * expr ) { std::pair arg1, arg2, arg3; arg1 = eval( expr->arg1 ); valid &= arg1.second; if ( ! valid ) return; arg2 = eval( expr->arg2 ); valid &= arg2.second; if ( ! valid ) return; arg3 = eval( expr->arg3 ); valid &= arg3.second; if ( ! valid ) return; value = arg1.first ? arg2.first : arg3.first; } void postvisit( const ast::CastExpr * expr ) { // cfa-cc generates a cast before every constant and many other places, e.g., (int)3, so the cast argument must // be evaluated to get the constant value. auto arg = eval(expr->arg); valid = arg.second; value = arg.first; // TODO: perform type conversion on value if valid } void postvisit( const ast::VariableExpr * expr ) { // No hit cfavalid = false; } void postvisit( const ast::VariableExpr * expr ) { if ( const ast::EnumInstType * inst = dynamic_cast(expr->result.get()) ) { if ( const ast::EnumDecl * decl = inst->base ) { const std::string & fname = function->name; assertf( expr->args.size() == 1 || expr->args.size() == 2, "Intrinsic function with %zd arguments: %s", expr->args.size(), fname.c_str() ); std::pair arg1, arg2; arg1 = eval(expr->args.front()); valid = valid && arg1.second; if ( ! valid ) return; if ( expr->args.size() == 2 ) { if ( expr->args.size() == 1 ) { // pre/postfix operators ++ and -- => assignment, which is not constant std::pair arg1; arg1 = eval(expr->args.front()); valid &= arg1.second; if ( ! valid ) return; if (fname == "+?") { value = arg1.first; } else if (fname == "-?") { value = -arg1.first; } else if (fname == "~?") { value = ~arg1.first; } else if (fname == "!?") { value = ! arg1.first; } else { valid = false; } // if } else { // => expr->args.size() == 2 // infix assignment operators => assignment, which is not constant std::pair arg1, arg2; arg1 = eval(expr->args.front()); valid &= arg1.second; if ( ! valid ) return; arg2 = eval(expr->args.back()); valid = valid && arg2.second; if ( ! valid ) return; } if (fname == "?+?") { value = arg1.first + arg2.first; } else if (fname == "?-?") { value = arg1.first - arg2.first; } else if (fname == "?*?") { value = arg1.first * arg2.first; } else if (fname == "?/?") { value = arg1.first / arg2.first; } else if (fname == "?%?") { value = arg1.first % arg2.first; } else { valid = false; } valid &= arg2.second; if ( ! valid ) return; if (fname == "?+?") { value = arg1.first + arg2.first; } else if (fname == "?-?") { value = arg1.first - arg2.first; } else if (fname == "?*?") { value = arg1.first * arg2.first; } else if (fname == "?/?") { value = arg1.first / arg2.first; } else if (fname == "?%?") { value = arg1.first % arg2.first; } else if (fname == "?<>?") { value = arg1.first >> arg2.first; } else if (fname == "??") { value = arg1.first > arg2.first; } else if (fname == "?<=?") { value = arg1.first <= arg2.first; } else if (fname == "?>=?") { value = arg1.first >= arg2.first; } else if (fname == "?==?") { value = arg1.first == arg2.first; } else if (fname == "?!=?") { value = arg1.first != arg2.first; } else if (fname == "?&?") { value = arg1.first & arg2.first; } else if (fname == "?^?") { value = arg1.first ^ arg2.first; } else if (fname == "?|?") { value = arg1.first | arg2.first; } else { valid = false; } } // if // TODO: implement other intrinsic functions } }; std::pair eval( const Expression * expr) { std::pair eval( const Expression * expr ) { PassVisitor ev; if (expr) { expr->accept(ev); return std::make_pair(ev.pass.value, ev.pass.valid); if ( expr ) { expr->accept( ev ); return std::make_pair( ev.pass.value, ev.pass.valid ); } else { return std::make_pair(0, false); return std::make_pair( 0, false ); } } std::pair eval(const ast::Expr * expr) { std::pair eval( const ast::Expr * expr ) { ast::Pass ev; if (expr) { expr->accept(ev); return std::make_pair(ev.core.value, ev.core.valid); if ( expr ) { expr->accept( ev ); return std::make_pair( ev.core.value, ev.core.valid ); } else { return std::make_pair(0, false); return std::make_pair( 0, false ); } }
• ## src/Parser/parser.yy

 r06bdba4 // Created On       : Sat Sep  1 20:22:55 2001 // Last Modified By : Peter A. Buhr // Last Modified On : Sat May 14 09:16:22 2022 // Update Count     : 5401 // Last Modified On : Fri Jul  1 15:35:08 2022 // Update Count     : 5405 // // empty { $$= nullptr; } // | '=' constant_expression // {$$ = $2; } | simple_assignment_operator initializer { $$= 1 == OperKinds::Assign ? 2 : 2->set_maybeConstructed( false ); } | '=' constant_expression {$$ = new InitializerNode($2 ); } | '=' '{' initializer_list_opt comma_opt '}' { $$= new InitializerNode( 3, true ); } // | simple_assignment_operator initializer // {$$ = $1 == OperKinds::Assign ?$2 : \$2->set_maybeConstructed( false ); } ;