Template BigNum implemented without runtime loops

BCS BCS at pathlink.com
Tue Dec 12 10:34:46 PST 2006


Don Clugston wrote:
> BCS wrote:
> 
>> I have implemented a arbitrary precision integer type using a struct 
>> and templates. Currently it supports ==, +, -, *, +=, -= and *=. 
[...]
>> On my system DMD crashes for size > 73 (e.i. 73 * 32b = 2336b).
> 
> 
> Of course, there's not much value in unrolling loops to that extent 
> (cache misses will cost you more than you'll gain by eliminating the 
> last couple of branch instructions).

Yah, unrolling the 2Kb version probably won't gain much, however I 
expect that it would do 128b/256b and such just fine.

Hmm, I'll  have to look into having it do a loop for the higher size 
values and then benchmark the two versions.

> 
> However, the use of tuples and static foreach to enforce asm unrolling 
> is very cool. This ought to work with mixins as well as direct asm 
> instructions. I'd never found a way of mixing in multiple blocks of code 
> at the same level -- this technique will probably solve the problem.
> (And it might be a way of doing very high performance expression 
> templates :-)  ).

I guess it does more as a proof of concept that as a REALLY high 
precision type.



More information about the Digitalmars-d-announce mailing list