2

How can I get the SICStus Prolog JIT to use any of the following ISA?

I need them for supercharging . Right now, I got:

  1. http://www.hackersdelight.org/ and

  2. the non-ISO arithmetic function msb/1.

For a start that's good, but I want more. Please help!

repeat
  • 18,496
  • 4
  • 54
  • 166
  • 1
    I can't help but feel that this is a technical issue to be raised directly with SICStus. – Daniel Lyons Sep 27 '19 at 14:53
  • @DanielLyons. My question is about (1) arcane details of (2) specific CPUs, running a (3) proprietary Prolog system. So if you think "this might be of interest for a subset of a subset of a subset of all Prolog programmers", I get that. Here's a different angle: the question is about (1) implementing the FD constraint propagators of `A + B #= C` on (2) the current and the assumed next predominant CPU architectures (x64, A64). This topic is a concern to all Prolog systems, including your favorite one. I merely started with (3) the one that has the best JIT. Does this make more sense to you now? – repeat Sep 27 '19 at 16:07
  • 1
    I think questions about implementation arcana are probably better addressed to the implementors themselves rather than a crowd of bystanders, especially if those sets are not known to overlap. But I didn't vote to close because if you do get an answer here I will enjoy reading it. – Daniel Lyons Sep 27 '19 at 16:35
  • @DanielLyons. Fair enough. I will edit the question and prepend a warning sign:) OTOH, Prolog related questions span an (compared to other programming languages) unusually large area of topics. Consider meta-interpreters. Or consider extensible unification by the means of attributed variables. Both enable amazing things, in "100% Prolog". – repeat Sep 27 '19 at 18:40
  • 1
    @DanielLyons. Have you yet had the time to look into (the implementation of) [tag:clpz]? A lot of amazing stuff, all in 100% Prolog. Currently only usable with SICStus, but I know of *two* free Prolog systems (Scryer Prolog and Like Prolog) working on support for it! – repeat Sep 27 '19 at 18:48
  • 1
    @DanielLyons: Is it really worth to start such a meta discussion? – false Sep 29 '19 at 21:34

1 Answers1

3

Unfortunately, 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:

  1. 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.
  2. Add JIT-compilation that just calls back into the corresponding C routine in the runtime system.
  3. 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.

Per Mildner
  • 10,469
  • 23
  • 30
  • 1
    What is so charming is that with a Jitter in place, actual code generation can change much more smoothly than in traditional machine code generating scenarios. I'm just thinking of that performance [boost](https://arxiv.org/pdf/1607.01590.pdf#page=6) from 4.3.2 to 4.3.3. – false Oct 03 '19 at 18:59
  • Popcnt and bitrev are low hanging fruit. It is surprising that SICStus does not pick them. – repeat Oct 15 '19 at 08:58
  • Let's talk financing. How much would you charge? – repeat Oct 15 '19 at 09:03