HackersDelight | Code from the book Hacker 's Delight '' by Henry S | Learning library
kandi X-RAY | HackersDelight Summary
kandi X-RAY | HackersDelight Summary
Code from the book "Hacker's Delight" by Henry S. Warren, Jr. (original and my own modifications).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of HackersDelight
HackersDelight Key Features
HackersDelight Examples and Code Snippets
Community Discussions
Trending Discussions on HackersDelight
QUESTION
How can I get the SICStus Prolog JIT to use any of the following ISA?
Intel BMI:
POPCNT
,LZCNT
,TZCNT
,PDEP
,PEXT
Intel CLMUL:
PCLMULQDQ
ARM AArch64:
RBIT
I need them for supercharging clpz. Right now, I got:
the non-ISO arithmetic function
msb/1
.
For a start that's good, but I want more. Please help!
...ANSWER
Answered 2019-Sep-30 at 10:19Unfortunately, there is no way for users to extend the JIT for cases like this.
I have been thinking about accessing the population count instructions (for some unrelated uses) from Prolog. The way to add this and other similar instructions would be:
- Add a new arithmetic instruction to
is/2
. This needs to be supported by all our code, not just JIT-compiled code, so interpreter, WAM-emulator, various internal byte-code-processors, all the static analyzers in our IDE, etc. etc. - Add JIT-compilation that just calls back into the corresponding C routine in the runtime system.
- If it can be demonstrated to benefit performance sufficiently, make the JIT compiler emit the special purpose CPU instructions for targets that have them.
(1) requires sufficient user demand (or explicit financing, of course). (3) requires convincing benchmarks. Currently neither of these are available, but that could change, of course.
QUESTION
It is well known that integer division is slow operation (typically several times slower than integer multiplication). But, if one need to perform many divide operations with a fixed divisor, it is possible to do some preconditioning on the divisor and replace "/" with multiplication and bit operations (Chapter 10 in Hacker's Delight).
As I've tested, if the divisor is a compilation-time constant, (e.g. static final long DIVISOR = 12345L;
) JVM will do the trick and replace all divisions by DIVISOR
with multiplication and bit operations. I'm interesting in the same kind of trick but when the divisor is known only at runtime.
For example, the following (slow) method:
...ANSWER
Answered 2017-Mar-16 at 20:53There is well known C/C++ libdivide library for fast integer division, and there is my adaptation of this library for Java libdivide4j.
Fast division with libdivide4j looks as follows:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install HackersDelight
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page