coq-club AT inria.fr
Subject: The Coq mailing list
List archive
Re: [Coq-Club] How does Int31 "underlying mechanism for hardware-efficient computations" work?
Chronological Thread
- From: Arnaud Spiwack <aspiwack AT lix.polytechnique.fr>
- To: Coq Club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] How does Int31 "underlying mechanism for hardware-efficient computations" work?
- Date: Tue, 28 Jun 2016 21:13:02 +0200
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=arnaud.spiwack AT gmail.com; spf=Pass smtp.mailfrom=arnaud.spiwack AT gmail.com; spf=None smtp.helo=postmaster AT mail-vk0-f52.google.com
- Ironport-phdr: 9a23:4yayERWP4w0vJCR7VXw2MtJsCAXV8LGtZVwlr6E/grcLSJyIuqrYZhOBt8tkgFKBZ4jH8fUM07OQ6PG4HzVbqs/b6jgrS99lb1c9k8IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUiv2OQc9HOnpAIma153xjLHqvcSIKFwS3nKUWvBbFF2OtwLft80b08NJC50a7V/3mEZOYPlc3mhyJFiezF7W78a0+4N/oWwL46pyv+YJa6jxfrw5QLpEF3xmdjltvIy4/SXEGCCI/zM3Vngc2k5DBBGA5xXnVL/wtDH7v6xzwn/JE9fxSOUdQzKr8qsjcwfply4MNHZt+XrPi9N5h6FzpBOx4QR4x5/IbYqVMvtnY66bc8lMFjkJZdpYSyEUWtD0VIAIFedUeL8A94Q=
Dear Michael,
Register
is indeed the manifestation of a hook mechanism in Coq’s kernel which I called retroknowledge. This mechanism allows the kernel to know about definitions from the standard library. What happens then, is that in vm_compute
or native_compute
, the compilation detects these 31-bit integers and their operation and compiles them to an efficient representation (they’re machine integers, but truncated to 32 bits for compatibility and the low bit fixed to 1 for the GC). At typing time, though, these are Coq terms so there was no need to invent new logic. If you have numerical-computation heavy code using Int31
(or BigN
or BigZ
) will probably give you a pretty big improvement in performances (though we’ve had mixed results with rational computations). At the price of a non-trivial increase in the trusted base.
This is not a perfect scheme though, because integer literals are, in fact, pretty big Coq terms, and so can be slow to type-check (there has been applications where type-checking the integer litteral was dominating any other performance bottleneck; in the ring
tactic it can even be slower to use BigN
coefficients instead of N
). So there has been another scheme in the work, where new logic and black-box constant to represent machine-integers. This has proven even faster, but the changes to the kernel are trickier. I haven’t been involved in this project and I don’t know its status.
I found it. The “Register” declarations get stripped from the generated documentation:
Register digits as int31 bits in "coq_int31" by True.
Register int31 as int31 type in "coq_int31" by True.
Best regards,
Michael
From: coq-club-request AT inria.fr [mailto:coq-club-request AT inria.fr] On Behalf Of Soegtrop, Michael
Sent: Tuesday, June 28, 2016 12:42 PM
To: coq-club AT inria.fr
Subject: [Coq-Club] How does Int31 "underlying mechanism for hardware-efficient computations" work?
Dear Coq Users,
the In31 library
https://coq.inria.fr/library/Coq.Numbers.Cyclic.Int31.Int31.html
states that the Int31 type comes with an “underlying mechanism for hardware-efficient computations”. I wonder what this means and how it works. The addition in Int31 seems to be implemented by conversion to Z, addition in Z and conversion back.
Best regards,
Michael
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
- [Coq-Club] How does Int31 "underlying mechanism for hardware-efficient computations" work?, Soegtrop, Michael, 06/28/2016
- RE: [Coq-Club] How does Int31 "underlying mechanism for hardware-efficient computations" work?, Soegtrop, Michael, 06/28/2016
- Re: [Coq-Club] How does Int31 "underlying mechanism for hardware-efficient computations" work?, Arnaud Spiwack, 06/28/2016
- RE: [Coq-Club] How does Int31 "underlying mechanism for hardware-efficient computations" work?, Soegtrop, Michael, 06/29/2016
- Re: [Coq-Club] How does Int31 "underlying mechanism for hardware-efficient computations" work?, Laurent Thery, 06/29/2016
- Re: [Coq-Club] How does Int31 "underlying mechanism for hardware-efficient computations" work?, Arnaud Spiwack, 06/29/2016
- RE: [Coq-Club] How does Int31 "underlying mechanism for hardware-efficient computations" work?, Soegtrop, Michael, 06/30/2016
- Re: [Coq-Club] How does Int31 "underlying mechanism for hardware-efficient computations" work?, Laurent Thery, 06/29/2016
- RE: [Coq-Club] How does Int31 "underlying mechanism for hardware-efficient computations" work?, Soegtrop, Michael, 06/29/2016
- Re: [Coq-Club] How does Int31 "underlying mechanism for hardware-efficient computations" work?, Arnaud Spiwack, 06/28/2016
- RE: [Coq-Club] How does Int31 "underlying mechanism for hardware-efficient computations" work?, Soegtrop, Michael, 06/28/2016
Archive powered by MHonArc 2.6.18.