Why set zero in zero.c rather than use xor_n

Torbjörn Granlund tg at gmplib.org
Mon Feb 5 21:46:58 UTC 2018


As suspected, memset adds quite some moverhead.  So much that I'd say it
was poorly written (this is freebsd 9):

             MPN_ZERO      mpn_zero        memset
1             #2.9182        7.7789       30.1435
2             #1.9448        4.8618       15.0717
3             #1.6206        3.8895       10.0605
4             #1.4586        3.4043        7.5431
5             #1.3626        3.1160        6.0306
7             #1.2519        2.7796        4.3062
9             #1.1885        2.5930        3.3531
12            #2.0273        2.4317        2.5155
16            #2.0055        2.3101        2.3701
22             1.9905        2.2106       #1.9889
31             1.9761        2.1335       #1.6938
43             1.9680        2.4401       #1.4940
60             1.9633        2.0787       #1.3451
84             1.6791        1.8050       #0.9857
118            1.4755        1.5990       #0.9080
166            1.3313        1.4825       #0.7878
234            1.2258        1.3859       #0.7102
330            1.1525        1.3535       #0.6438
466            1.1002        1.2659       #0.5957
658            1.0625        1.2222       #0.5650
930            1.0367        1.2231       #0.5411

GNU's better:

             MPN_ZERO      mpn_zero        memset
1             #2.9262        6.8264       13.6536
2             #1.9513        4.3888        6.8267
3             #1.6256        3.5758        2.9263
4             #1.4630        3.1695        2.1946
5             #1.3654        2.9255        2.1456
7              2.9264        2.6471       #1.5326
9              2.9257        2.4925       #1.5170
12             2.9257        2.3570       #1.1378
16             2.9260        2.2552       #0.7924
22             2.9255        2.1720       #0.5763
31             2.9256        2.1079       #0.5978
43             2.6988        2.4042       #0.6124
60             2.2104        1.9992       #0.5364
84             1.8577        1.7074       #0.5225
118            1.6034        1.4960       #0.5043
166            1.4218        1.3454       #0.4994
234            1.2920        1.2381       #0.5043
330            1.1998        1.1615       #0.5379
466            1.1348        1.1070       #0.5232
658            1.0880        1.0687       #0.5130
930            1.0550        1.0413       #0.5056
1315           1.0317        1.0228       #0.5044
1859           1.0153        1.0084       #0.4997
2628           1.0037        0.9993       #0.4940
3715           0.9956        0.9923       #0.4933

-- 
Torbjörn
Please encrypt, key id 0xC8601622


More information about the gmp-devel mailing list