What's a reasonable size ratio for toom32?

Niels Möller nisse at lysator.liu.se
Thu Aug 24 07:37:20 CEST 2023


Paul Zimmermann <Paul.Zimmermann at inria.fr> writes:

> I suggest taking fixed non-rational ratios, for example sqrt(2), sqrt(3),
> sqrt(5), and comparing the old and new code over the range of sizes where
> this code is used.

Would it make sense to hack speed mpn_mul.r to do that? Currently,
specifying an r > 0 gives a fix size of the second operand, and r < 0
implies a fix product size of |r|. 

If we change the latter to instead imply a fixed ratio, e.g., use |r| /
100, by this change of line 1126 is speed.h:

-    if (size1 < 0) size1 = -size1 - s->size;				\
+    if (size1 < 0) size1 = -size1 * s->size / 100;			\

we could specify a 3/5 = 60% ratio like 

tune$ ./speed -p 1000000 -c -s 10-200 -f1.1 mpn_mul.-60
overhead 5.00 cycles, precision 1000000 units of 9.94e-10 secs, CPU freq 1006.24 MHz
          mpn_mul.-60
10             135.27
11             148.22
12             180.78
13             192.64
14             230.74
15             272.04
16             296.78
17             340.74
18             349.28
19             432.63
20             481.87
22             548.86
24             650.80
26             724.24
28             861.18
30            1022.95
33            1184.50
36            1405.78
39            1652.40
42            1908.10
46            2280.28
50            2580.60
55            3136.99
60            3493.01
66            4095.82
72            4807.55
79            5422.07
86            6186.81
94            7193.20
103           8372.21
113           9886.82
124          11556.88
136          13422.05
149          16084.65
163          17925.33
179          20106.22
196          23446.72

Does that make sense? Or can you suggest some other interface to specify
a fixed ratio?

Regards,
/Niels

-- 
Niels Möller. PGP key CB4962D070D77D7FCB8BA36271D8F1FF368C6677.
Internet email is subject to wholesale government surveillance.


More information about the gmp-devel mailing list