Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.prolog > #14769 > unrolled thread

VIP0909: VibeCore Improvement Proposal

Started byMild Shock <janburse@fastmail.fm>
First post2025-08-11 11:35 +0200
Last post2026-08-09 20:25 +0200
Articles 9 — 1 participant

Back to article view | Back to comp.lang.prolog


Contents

  VIP0909: VibeCore Improvement Proposal Mild Shock <janburse@fastmail.fm> - 2025-08-11 11:35 +0200
    VIP0111: Does a Map have a Constructor? (Was: VIP0909: VibeCore Improvement Proposal) Mild Shock <janburse@fastmail.fm> - 2026-03-14 18:11 +0100
      100% Prolog Hash map beats SWI C Trie (Was: VIP0111: Does a Map have a Constructor?) Mild Shock <janburse@fastmail.fm> - 2026-03-17 04:07 +0100
      AI Accelerators and ISO Prolog multi-threading (Was: VIP0111: Does a Map have a Constructor?) Mild Shock <janburse@fastmail.fm> - 2026-07-29 15:28 +0200
        Actor/Erlang is dead, no Thread and Mailbox conflation [golang channels] (Was: AI Accelerators and ISO Prolog multi-threading) Mild Shock <janburse@fastmail.fm> - 2026-07-29 15:41 +0200
          Summer Challenge: libSQL = Prolog+Modes [VDBE versus π-WAM] (Was: Actor/Erlang is dead, no Thread and Mailbox conflation [golang channels]) Mild Shock <janburse@fastmail.fm> - 2026-07-30 11:22 +0200
            Work slicing can simulate AbortController (Was: Summer Challenge: libSQL = Prolog+Modes [VDBE versus π-WAM]) Mild Shock <janburse@fastmail.fm> - 2026-08-01 13:23 +0200
        Introducing an asm/1 statement in a Prolog system (Was: AI Accelerators and ISO Prolog multi-threading) Mild Shock <janburse@fastmail.fm> - 2026-08-09 20:21 +0200
        Introducing an asm/1 statement in a Prolog system (Re: AI Accelerators and ISO Prolog multi-threading) Mild Shock <janburse@fastmail.fm> - 2026-08-09 20:25 +0200

#14769 — VIP0909: VibeCore Improvement Proposal

FromMild Shock <janburse@fastmail.fm>
Date2025-08-11 11:35 +0200
SubjectVIP0909: VibeCore Improvement Proposal
Message-ID<107cdg8$3ok7g$1@solani.org>
Hi,

Functional requirement:

?- Y = g(_,_), X = f(Y,C,D,Y), term_singletons(X, L),
    L == [C,D].

?- Y = g(A,X,B), X = f(Y,C,D), term_singletons(X, L),
    L == [A,B,C,D].

Non-Functional requirement:

?- member(N,[5,10,15]), time(singletons(N)), fail; true.
% Zeit 1 ms, GC 0 ms, Lips 4046000, Uhr 11.08.2025 01:36
% Zeit 3 ms, GC 0 ms, Lips 1352000, Uhr 11.08.2025 01:36
% Zeit 3 ms, GC 0 ms, Lips 1355333, Uhr 11.08.2025 01:36
true.

Can your Prolog system do that?

P.S.: Benchmark was:

singletons(N) :-
    hydra2(N,Y),
    between(1,1000,_), term_singletons(Y,_), fail; true.

hydra2(0, _) :- !.
hydra2(N, s(X,X)) :-
    M is N-1,
    hydra2(M, X).

Bye

[toc] | [next] | [standalone]


#15488 — VIP0111: Does a Map have a Constructor? (Was: VIP0909: VibeCore Improvement Proposal)

FromMild Shock <janburse@fastmail.fm>
Date2026-03-14 18:11 +0100
SubjectVIP0111: Does a Map have a Constructor? (Was: VIP0909: VibeCore Improvement Proposal)
Message-ID<10p44s1$16ps$1@solani.org>
In reply to#14769
Hi,

How would we do a reverse sorted map?

I find in Java:

TreeMap(Comparator<? super K> comparator) 	
Constructs a new, empty tree map, ordered
according to the given comparator.
https://docs.oracle.com/javase/8/docs/api/java/util/TreeMap.html

Or in Dogelog Player:

tree_new(T):
tree_new(T, F):
The predicate succeeds in R with a new red-black tree.
The binary predicate allows specifying a term compare F.
https://www.dogelog.ch/typtab/doclet/book/12_lang/05_libraries/03_util/06_tree.html

Here is an example, using the destructive API. But
the same constructor works also for the non-destructive API.

?- tree_new(_T), tree_add(_T, 0rInf, foo),
    tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
L = [0rNaN-bar, 0rInf-foo].

And now using a comparator modifier, aggregate with a comparator,
as a closure. Some Joy of Higher Order logic programming:

reverse(C, R, X, Y) :- call(C, R, Y, X).

?- tree_new(_T,reverse(compare)), tree_add(_T, 0rInf, foo),
    tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
L = [0rInf-foo, 0rNaN-bar].

?- tree_new(_T,reverse(reverse(compare))), tree_add(_T, 0rInf, foo),
    tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
L = [0rNaN-bar, 0rInf-foo].

Just toying around with my new NaNs.

Have Fun!

Bye

Mild Shock schrieb:
> Hi,
> 
> Functional requirement:
> 
> ?- Y = g(_,_), X = f(Y,C,D,Y), term_singletons(X, L),
>     L == [C,D].
> 
> ?- Y = g(A,X,B), X = f(Y,C,D), term_singletons(X, L),
>     L == [A,B,C,D].
> 
> Non-Functional requirement:
> 
> ?- member(N,[5,10,15]), time(singletons(N)), fail; true.
> % Zeit 1 ms, GC 0 ms, Lips 4046000, Uhr 11.08.2025 01:36
> % Zeit 3 ms, GC 0 ms, Lips 1352000, Uhr 11.08.2025 01:36
> % Zeit 3 ms, GC 0 ms, Lips 1355333, Uhr 11.08.2025 01:36
> true.
> 
> Can your Prolog system do that?
> 
> P.S.: Benchmark was:
> 
> singletons(N) :-
>     hydra2(N,Y),
>     between(1,1000,_), term_singletons(Y,_), fail; true.
> 
> hydra2(0, _) :- !.
> hydra2(N, s(X,X)) :-
>     M is N-1,
>     hydra2(M, X).
> 
> Bye

[toc] | [prev] | [next] | [standalone]


#15492 — 100% Prolog Hash map beats SWI C Trie (Was: VIP0111: Does a Map have a Constructor?)

FromMild Shock <janburse@fastmail.fm>
Date2026-03-17 04:07 +0100
Subject100% Prolog Hash map beats SWI C Trie (Was: VIP0111: Does a Map have a Constructor?)
Message-ID<10paghr$5fom$1@solani.org>
In reply to#15488
Hi,

This is also fun:

% test
test :-
    distinct(dump(_)),
    fail.
test.

The Dogelog Player has a 100% Prolog implemented hash map,
using only some primitives term_hash/2 and (==)/2. While
SWI-Prolog uses a C code trie for distinct/2.

Problem with a trie, a lot of copying from the key term
into the trie sub keys. Right? Whereas my hash map doesn't
copy anything (decoupling), respectively I have program

sharing (PS) via the heap, since Dogelog Player is
a heap (sic!) Prolog system:

% SWI-Prolog 10.1.1
?- between(1,3,_), random_dump, time(test), fail; true.
% 400,009 inferences, 0.594 CPU in 0.635 seconds (94% CPU, 673699 Lips)
% 400,009 inferences, 0.578 CPU in 0.636 seconds (91% CPU, 691907 Lips)
% 400,009 inferences, 0.562 CPU in 0.640 seconds (88% CPU, 711127 Lips)
% true.

% Dogelog 2.1.6 for Java
?- between(1,3,_), random_dump, time(test), fail; true.
% Zeit 358.544 ms, GC 0.000 ms, Lips 20350 k
% Zeit 346.934 ms, GC 0.000 ms, Lips 21019 k
% Zeit 356.943 ms, GC 0.000 ms, Lips 20434 k
true.

The above is a preview, it uses a new feature of
Dogelog Player frozen compounds, namely pre-
computed hashes. The SWI C Trie overhead could be

also somewhere else, maybe acyclic_term/1 is slow?
I do a similar thing in my code as well, so I am
not comparing oranges with apples, its rather

a comparison apples with apples.

Have Fun!

Bye

Mild Shock schrieb:
> Hi,
> 
> How would we do a reverse sorted map?
> 
> I find in Java:
> 
> TreeMap(Comparator<? super K> comparator)
> Constructs a new, empty tree map, ordered
> according to the given comparator.
> https://docs.oracle.com/javase/8/docs/api/java/util/TreeMap.html
> 
> Or in Dogelog Player:
> 
> tree_new(T):
> tree_new(T, F):
> The predicate succeeds in R with a new red-black tree.
> The binary predicate allows specifying a term compare F.
> https://www.dogelog.ch/typtab/doclet/book/12_lang/05_libraries/03_util/06_tree.html 
> 
> 
> Here is an example, using the destructive API. But
> the same constructor works also for the non-destructive API.
> 
> ?- tree_new(_T), tree_add(_T, 0rInf, foo),
>     tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
> L = [0rNaN-bar, 0rInf-foo].
> 
> And now using a comparator modifier, aggregate with a comparator,
> as a closure. Some Joy of Higher Order logic programming:
> 
> reverse(C, R, X, Y) :- call(C, R, Y, X).
> 
> ?- tree_new(_T,reverse(compare)), tree_add(_T, 0rInf, foo),
>     tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
> L = [0rInf-foo, 0rNaN-bar].
> 
> ?- tree_new(_T,reverse(reverse(compare))), tree_add(_T, 0rInf, foo),
>     tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
> L = [0rNaN-bar, 0rInf-foo].
> 
> Just toying around with my new NaNs.
> 
> Have Fun!
> 
> Bye
> 
> Mild Shock schrieb:
>> Hi,
>>
>> Functional requirement:
>>
>> ?- Y = g(_,_), X = f(Y,C,D,Y), term_singletons(X, L),
>>     L == [C,D].
>>
>> ?- Y = g(A,X,B), X = f(Y,C,D), term_singletons(X, L),
>>     L == [A,B,C,D].
>>
>> Non-Functional requirement:
>>
>> ?- member(N,[5,10,15]), time(singletons(N)), fail; true.
>> % Zeit 1 ms, GC 0 ms, Lips 4046000, Uhr 11.08.2025 01:36
>> % Zeit 3 ms, GC 0 ms, Lips 1352000, Uhr 11.08.2025 01:36
>> % Zeit 3 ms, GC 0 ms, Lips 1355333, Uhr 11.08.2025 01:36
>> true.
>>
>> Can your Prolog system do that?
>>
>> P.S.: Benchmark was:
>>
>> singletons(N) :-
>>     hydra2(N,Y),
>>     between(1,1000,_), term_singletons(Y,_), fail; true.
>>
>> hydra2(0, _) :- !.
>> hydra2(N, s(X,X)) :-
>>     M is N-1,
>>     hydra2(M, X).
>>
>> Bye
> 

[toc] | [prev] | [next] | [standalone]


#15781 — AI Accelerators and ISO Prolog multi-threading (Was: VIP0111: Does a Map have a Constructor?)

FromMild Shock <janburse@fastmail.fm>
Date2026-07-29 15:28 +0200
SubjectAI Accelerators and ISO Prolog multi-threading (Was: VIP0111: Does a Map have a Constructor?)
Message-ID<114cv6j$kb0c$1@solani.org>
In reply to#15488
Hi,

Usual question:

 > Why implement both pre-emptive threading
AND cooperative tasks/engines?

I had implemented the ISO proposal in formerly Jekejeke
Prolog, you find the ISO proposal here:

ISO/IEC DTR 13211–5:2007
Prolog multi-threading support
https://logtalk.org/plstd/threads.pdf

But the ISO proposal doesn't match modern WebGPU APIs,
where your logical threads can live remotely in a dedicated GPU

in the VRAM there, and where you would have launch
parameters that say: Hey please run 4096 compute

shaders for me, that have independet thread state. Using
cooperative multi-tasking as the orchestrator works well.

Bye

Mild Shock schrieb:
> Hi,
> 
> How would we do a reverse sorted map?
> 
> I find in Java:
> 
> TreeMap(Comparator<? super K> comparator)
> Constructs a new, empty tree map, ordered
> according to the given comparator.
> https://docs.oracle.com/javase/8/docs/api/java/util/TreeMap.html
> 
> Or in Dogelog Player:
> 
> tree_new(T):
> tree_new(T, F):
> The predicate succeeds in R with a new red-black tree.
> The binary predicate allows specifying a term compare F.
> https://www.dogelog.ch/typtab/doclet/book/12_lang/05_libraries/03_util/06_tree.html 
> 
> 
> Here is an example, using the destructive API. But
> the same constructor works also for the non-destructive API.
> 
> ?- tree_new(_T), tree_add(_T, 0rInf, foo),
>     tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
> L = [0rNaN-bar, 0rInf-foo].
> 
> And now using a comparator modifier, aggregate with a comparator,
> as a closure. Some Joy of Higher Order logic programming:
> 
> reverse(C, R, X, Y) :- call(C, R, Y, X).
> 
> ?- tree_new(_T,reverse(compare)), tree_add(_T, 0rInf, foo),
>     tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
> L = [0rInf-foo, 0rNaN-bar].
> 
> ?- tree_new(_T,reverse(reverse(compare))), tree_add(_T, 0rInf, foo),
>     tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
> L = [0rNaN-bar, 0rInf-foo].
> 
> Just toying around with my new NaNs.
> 
> Have Fun!
> 
> Bye
> 
> Mild Shock schrieb:
>> Hi,
>>
>> Functional requirement:
>>
>> ?- Y = g(_,_), X = f(Y,C,D,Y), term_singletons(X, L),
>>     L == [C,D].
>>
>> ?- Y = g(A,X,B), X = f(Y,C,D), term_singletons(X, L),
>>     L == [A,B,C,D].
>>
>> Non-Functional requirement:
>>
>> ?- member(N,[5,10,15]), time(singletons(N)), fail; true.
>> % Zeit 1 ms, GC 0 ms, Lips 4046000, Uhr 11.08.2025 01:36
>> % Zeit 3 ms, GC 0 ms, Lips 1352000, Uhr 11.08.2025 01:36
>> % Zeit 3 ms, GC 0 ms, Lips 1355333, Uhr 11.08.2025 01:36
>> true.
>>
>> Can your Prolog system do that?
>>
>> P.S.: Benchmark was:
>>
>> singletons(N) :-
>>     hydra2(N,Y),
>>     between(1,1000,_), term_singletons(Y,_), fail; true.
>>
>> hydra2(0, _) :- !.
>> hydra2(N, s(X,X)) :-
>>     M is N-1,
>>     hydra2(M, X).
>>
>> Bye
> 

[toc] | [prev] | [next] | [standalone]


#15782 — Actor/Erlang is dead, no Thread and Mailbox conflation [golang channels] (Was: AI Accelerators and ISO Prolog multi-threading)

FromMild Shock <janburse@fastmail.fm>
Date2026-07-29 15:41 +0200
SubjectActor/Erlang is dead, no Thread and Mailbox conflation [golang channels] (Was: AI Accelerators and ISO Prolog multi-threading)
Message-ID<114cvub$kbhu$1@solani.org>
In reply to#15781
Hi,

Mostlikely for high performance computing à la,
the Actor/Erlang model is dead, they might rely
on MPMC (Multiple Producer, Multiple Consumer)

queue entities separate from the threads. The
ISO Prolog multi-threading support had also such
threads. But besides that was also Actor/Erlang

leaning in practice, like SWI, where threads
have some default queues:

 > KOAN/Fortran-S was an early 1990s research programming
 > system for distributed-memory multiprocessors . Developed
 > at ENS Lyon in the early 1990s . Often listed alongside
 > other historical parallel programming efforts.
 >
 > The Message Passing: The research explicitly
 > compared the SVM approach against message passing
 > on the same hardware . The finding was that SVM
 > could achieve good performance without the low-level
 >
 > complexity of managing explicit messages, though
 > the best results often came from a hybrid approach (sic!)

So an actor is basically a Thread and Mailbox
conflation. While a MPMC queue is a kind of
separate Mailbox, where multiple "actors" can

read from and write from. A kind of localized
Linda Tuple store. Which Programming language did
adopted the non-Actor pi-calculus model?

Right golang with its channels.

Bye

Mild Shock schrieb:
> Hi,
> 
> Usual question:
> 
>  > Why implement both pre-emptive threading
> AND cooperative tasks/engines?
> 
> I had implemented the ISO proposal in formerly Jekejeke
> Prolog, you find the ISO proposal here:
> 
> ISO/IEC DTR 13211–5:2007
> Prolog multi-threading support
> https://logtalk.org/plstd/threads.pdf
> 
> But the ISO proposal doesn't match modern WebGPU APIs,
> where your logical threads can live remotely in a dedicated GPU
> 
> in the VRAM there, and where you would have launch
> parameters that say: Hey please run 4096 compute
> 
> shaders for me, that have independet thread state. Using
> cooperative multi-tasking as the orchestrator works well.
> 
> Bye
> 
> Mild Shock schrieb:
>> Hi,
>>
>> How would we do a reverse sorted map?
>>
>> I find in Java:
>>
>> TreeMap(Comparator<? super K> comparator)
>> Constructs a new, empty tree map, ordered
>> according to the given comparator.
>> https://docs.oracle.com/javase/8/docs/api/java/util/TreeMap.html
>>
>> Or in Dogelog Player:
>>
>> tree_new(T):
>> tree_new(T, F):
>> The predicate succeeds in R with a new red-black tree.
>> The binary predicate allows specifying a term compare F.
>> https://www.dogelog.ch/typtab/doclet/book/12_lang/05_libraries/03_util/06_tree.html 
>>
>>
>> Here is an example, using the destructive API. But
>> the same constructor works also for the non-destructive API.
>>
>> ?- tree_new(_T), tree_add(_T, 0rInf, foo),
>>     tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
>> L = [0rNaN-bar, 0rInf-foo].
>>
>> And now using a comparator modifier, aggregate with a comparator,
>> as a closure. Some Joy of Higher Order logic programming:
>>
>> reverse(C, R, X, Y) :- call(C, R, Y, X).
>>
>> ?- tree_new(_T,reverse(compare)), tree_add(_T, 0rInf, foo),
>>     tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
>> L = [0rInf-foo, 0rNaN-bar].
>>
>> ?- tree_new(_T,reverse(reverse(compare))), tree_add(_T, 0rInf, foo),
>>     tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
>> L = [0rNaN-bar, 0rInf-foo].
>>
>> Just toying around with my new NaNs.
>>
>> Have Fun!
>>
>> Bye
>>
>> Mild Shock schrieb:
>>> Hi,
>>>
>>> Functional requirement:
>>>
>>> ?- Y = g(_,_), X = f(Y,C,D,Y), term_singletons(X, L),
>>>     L == [C,D].
>>>
>>> ?- Y = g(A,X,B), X = f(Y,C,D), term_singletons(X, L),
>>>     L == [A,B,C,D].
>>>
>>> Non-Functional requirement:
>>>
>>> ?- member(N,[5,10,15]), time(singletons(N)), fail; true.
>>> % Zeit 1 ms, GC 0 ms, Lips 4046000, Uhr 11.08.2025 01:36
>>> % Zeit 3 ms, GC 0 ms, Lips 1352000, Uhr 11.08.2025 01:36
>>> % Zeit 3 ms, GC 0 ms, Lips 1355333, Uhr 11.08.2025 01:36
>>> true.
>>>
>>> Can your Prolog system do that?
>>>
>>> P.S.: Benchmark was:
>>>
>>> singletons(N) :-
>>>     hydra2(N,Y),
>>>     between(1,1000,_), term_singletons(Y,_), fail; true.
>>>
>>> hydra2(0, _) :- !.
>>> hydra2(N, s(X,X)) :-
>>>     M is N-1,
>>>     hydra2(M, X).
>>>
>>> Bye
>>
> 

[toc] | [prev] | [next] | [standalone]


#15795 — Summer Challenge: libSQL = Prolog+Modes [VDBE versus π-WAM] (Was: Actor/Erlang is dead, no Thread and Mailbox conflation [golang channels])

FromMild Shock <janburse@fastmail.fm>
Date2026-07-30 11:22 +0200
SubjectSummer Challenge: libSQL = Prolog+Modes [VDBE versus π-WAM] (Was: Actor/Erlang is dead, no Thread and Mailbox conflation [golang channels])
Message-ID<114f54s$lao5$1@solani.org>
In reply to#15782
Hi,

Woa! Thats a very sad and non fitting statement:

"This was before I was indoctrinated into
ISO Prolog and the ways of monotonic logic
programming. Shen Prolog has many semantic
and syntactic limitations that Scryer Prolog
does not. Also, I now know constraints are a
much better, purer solution to the problems
mode declarations were meant to address"
https://github.com/mthom/scryer-prolog/issues/3410#issuecomment-5030471183

Ok, here is the summer challenge, thats the easy one:

     SQL --> Prolog --> WAN

Here come two variations, slightly mindboggling maybe?

     SQL --> AST --> VDBE

     SQL --> Prolog+Modes --> π-WAM

Bye

BTW: What is VDBE? Some abstract machine, that can
be used to run SQL, following some ideas here:

Database Co-Design With Asynchronous I/O
https://penberg.org/papers/penberg-edgesys24.pdf

Or to run Doom:

Doom on the Turso VDBE
https://github.com/tursodatabase/turso-vdbe-doom-example

What if we would run Doom with π-WAM, an a GPU,
using multiple shaders. We could add some ray tracing.

Mild Shock schrieb:
> Hi,
> 
> Mostlikely for high performance computing à la,
> the Actor/Erlang model is dead, they might rely
> on MPMC (Multiple Producer, Multiple Consumer)
> 
> queue entities separate from the threads. The
> ISO Prolog multi-threading support had also such
> threads. But besides that was also Actor/Erlang
> 
> leaning in practice, like SWI, where threads
> have some default queues:
> 
>  > KOAN/Fortran-S was an early 1990s research programming
>  > system for distributed-memory multiprocessors . Developed
>  > at ENS Lyon in the early 1990s . Often listed alongside
>  > other historical parallel programming efforts.
>  >
>  > The Message Passing: The research explicitly
>  > compared the SVM approach against message passing
>  > on the same hardware . The finding was that SVM
>  > could achieve good performance without the low-level
>  >
>  > complexity of managing explicit messages, though
>  > the best results often came from a hybrid approach (sic!)
> 
> So an actor is basically a Thread and Mailbox
> conflation. While a MPMC queue is a kind of
> separate Mailbox, where multiple "actors" can
> 
> read from and write from. A kind of localized
> Linda Tuple store. Which Programming language did
> adopted the non-Actor pi-calculus model?
> 
> Right golang with its channels.
> 
> Bye
> 
> Mild Shock schrieb:
>> Hi,
>>
>> Usual question:
>>
>>  > Why implement both pre-emptive threading
>> AND cooperative tasks/engines?
>>
>> I had implemented the ISO proposal in formerly Jekejeke
>> Prolog, you find the ISO proposal here:
>>
>> ISO/IEC DTR 13211–5:2007
>> Prolog multi-threading support
>> https://logtalk.org/plstd/threads.pdf
>>
>> But the ISO proposal doesn't match modern WebGPU APIs,
>> where your logical threads can live remotely in a dedicated GPU
>>
>> in the VRAM there, and where you would have launch
>> parameters that say: Hey please run 4096 compute
>>
>> shaders for me, that have independet thread state. Using
>> cooperative multi-tasking as the orchestrator works well.
>>
>> Bye
>>
>> Mild Shock schrieb:
>>> Hi,
>>>
>>> How would we do a reverse sorted map?
>>>
>>> I find in Java:
>>>
>>> TreeMap(Comparator<? super K> comparator)
>>> Constructs a new, empty tree map, ordered
>>> according to the given comparator.
>>> https://docs.oracle.com/javase/8/docs/api/java/util/TreeMap.html
>>>
>>> Or in Dogelog Player:
>>>
>>> tree_new(T):
>>> tree_new(T, F):
>>> The predicate succeeds in R with a new red-black tree.
>>> The binary predicate allows specifying a term compare F.
>>> https://www.dogelog.ch/typtab/doclet/book/12_lang/05_libraries/03_util/06_tree.html 
>>>
>>>
>>> Here is an example, using the destructive API. But
>>> the same constructor works also for the non-destructive API.
>>>
>>> ?- tree_new(_T), tree_add(_T, 0rInf, foo),
>>>     tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
>>> L = [0rNaN-bar, 0rInf-foo].
>>>
>>> And now using a comparator modifier, aggregate with a comparator,
>>> as a closure. Some Joy of Higher Order logic programming:
>>>
>>> reverse(C, R, X, Y) :- call(C, R, Y, X).
>>>
>>> ?- tree_new(_T,reverse(compare)), tree_add(_T, 0rInf, foo),
>>>     tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
>>> L = [0rInf-foo, 0rNaN-bar].
>>>
>>> ?- tree_new(_T,reverse(reverse(compare))), tree_add(_T, 0rInf, foo),
>>>     tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
>>> L = [0rNaN-bar, 0rInf-foo].
>>>
>>> Just toying around with my new NaNs.
>>>
>>> Have Fun!
>>>
>>> Bye
>>>
>>> Mild Shock schrieb:
>>>> Hi,
>>>>
>>>> Functional requirement:
>>>>
>>>> ?- Y = g(_,_), X = f(Y,C,D,Y), term_singletons(X, L),
>>>>     L == [C,D].
>>>>
>>>> ?- Y = g(A,X,B), X = f(Y,C,D), term_singletons(X, L),
>>>>     L == [A,B,C,D].
>>>>
>>>> Non-Functional requirement:
>>>>
>>>> ?- member(N,[5,10,15]), time(singletons(N)), fail; true.
>>>> % Zeit 1 ms, GC 0 ms, Lips 4046000, Uhr 11.08.2025 01:36
>>>> % Zeit 3 ms, GC 0 ms, Lips 1352000, Uhr 11.08.2025 01:36
>>>> % Zeit 3 ms, GC 0 ms, Lips 1355333, Uhr 11.08.2025 01:36
>>>> true.
>>>>
>>>> Can your Prolog system do that?
>>>>
>>>> P.S.: Benchmark was:
>>>>
>>>> singletons(N) :-
>>>>     hydra2(N,Y),
>>>>     between(1,1000,_), term_singletons(Y,_), fail; true.
>>>>
>>>> hydra2(0, _) :- !.
>>>> hydra2(N, s(X,X)) :-
>>>>     M is N-1,
>>>>     hydra2(M, X).
>>>>
>>>> Bye
>>>
>>
> 

[toc] | [prev] | [next] | [standalone]


#15810 — Work slicing can simulate AbortController (Was: Summer Challenge: libSQL = Prolog+Modes [VDBE versus π-WAM])

FromMild Shock <janburse@fastmail.fm>
Date2026-08-01 13:23 +0200
SubjectWork slicing can simulate AbortController (Was: Summer Challenge: libSQL = Prolog+Modes [VDBE versus π-WAM])
Message-ID<114kkvo$phte$1@solani.org>
In reply to#15795
Hi,

In reality alread Web Workers pose quite
challenge to control and diagnose them,
not only WebGPU. For example Ciao Prolog Playground

never managed, so far, to provide a proper
Prolog interrupt, to their WAM running inside
a worker. If you do Ctrl-C it will loose the

state of the dynamic database. Since it is a
cold and hard Worker.terminate() and you have to
restart the single Web Worker used for the WAM.

Remember when fetch() had no AbortController? So
while fetch can hardly be sliced, waiting for
remote servers to do something. A local GPU (even

when dedicated card and not accelerator) is
easier to slice, especially when it runs Hack VM.
The Dogelog Player has even register_interrupt() to

define promises that are uniformly Ctrl-C. SWI-Prolog
Tinker adopted this pattern from Dogelog Player,
and is better off then Ciao Prolog Playground:

function sleep_promise(buf, delay) {
     return new Promise(resolve => {
         function handler() {
             register_interrupt(buf, () => {});
             resolve();
         }
         let timer = setDelay(handler, delay);
         register_interrupt(buf, () => {
             clearTimeout(timer);
             register_interrupt(buf, () => {});
             resolve()
         });
     });
}

Not everybody might agree to do it like
that. Even SWI-Prolog might use a variation.
The above is for Dogelog Player where $YIELD/1,

is very primitive, can only handle fullfilment,
no rejects. So you have to wrap your promise
of interest into another promise. Add work slicing

and you can do a soft terminate() without state loss.

Bye

Mild Shock schrieb:
> Hi,
> 
> Woa! Thats a very sad and non fitting statement:
> 
> "This was before I was indoctrinated into
> ISO Prolog and the ways of monotonic logic
> programming. Shen Prolog has many semantic
> and syntactic limitations that Scryer Prolog
> does not. Also, I now know constraints are a
> much better, purer solution to the problems
> mode declarations were meant to address"
> https://github.com/mthom/scryer-prolog/issues/3410#issuecomment-5030471183
> 
> Ok, here is the summer challenge, thats the easy one:
> 
>      SQL --> Prolog --> WAN
> 
> Here come two variations, slightly mindboggling maybe?
> 
>      SQL --> AST --> VDBE
> 
>      SQL --> Prolog+Modes --> π-WAM
> 
> Bye
> 
> BTW: What is VDBE? Some abstract machine, that can
> be used to run SQL, following some ideas here:
> 
> Database Co-Design With Asynchronous I/O
> https://penberg.org/papers/penberg-edgesys24.pdf
> 
> Or to run Doom:
> 
> Doom on the Turso VDBE
> https://github.com/tursodatabase/turso-vdbe-doom-example
> 
> What if we would run Doom with π-WAM, an a GPU,
> using multiple shaders. We could add some ray tracing.
> 
> Mild Shock schrieb:
>> Hi,
>>
>> Mostlikely for high performance computing à la,
>> the Actor/Erlang model is dead, they might rely
>> on MPMC (Multiple Producer, Multiple Consumer)
>>
>> queue entities separate from the threads. The
>> ISO Prolog multi-threading support had also such
>> threads. But besides that was also Actor/Erlang
>>
>> leaning in practice, like SWI, where threads
>> have some default queues:
>>
>>  > KOAN/Fortran-S was an early 1990s research programming
>>  > system for distributed-memory multiprocessors . Developed
>>  > at ENS Lyon in the early 1990s . Often listed alongside
>>  > other historical parallel programming efforts.
>>  >
>>  > The Message Passing: The research explicitly
>>  > compared the SVM approach against message passing
>>  > on the same hardware . The finding was that SVM
>>  > could achieve good performance without the low-level
>>  >
>>  > complexity of managing explicit messages, though
>>  > the best results often came from a hybrid approach (sic!)
>>
>> So an actor is basically a Thread and Mailbox
>> conflation. While a MPMC queue is a kind of
>> separate Mailbox, where multiple "actors" can
>>
>> read from and write from. A kind of localized
>> Linda Tuple store. Which Programming language did
>> adopted the non-Actor pi-calculus model?
>>
>> Right golang with its channels.
>>
>> Bye
>>
>> Mild Shock schrieb:
>>> Hi,
>>>
>>> Usual question:
>>>
>>>  > Why implement both pre-emptive threading
>>> AND cooperative tasks/engines?
>>>
>>> I had implemented the ISO proposal in formerly Jekejeke
>>> Prolog, you find the ISO proposal here:
>>>
>>> ISO/IEC DTR 13211–5:2007
>>> Prolog multi-threading support
>>> https://logtalk.org/plstd/threads.pdf
>>>
>>> But the ISO proposal doesn't match modern WebGPU APIs,
>>> where your logical threads can live remotely in a dedicated GPU
>>>
>>> in the VRAM there, and where you would have launch
>>> parameters that say: Hey please run 4096 compute
>>>
>>> shaders for me, that have independet thread state. Using
>>> cooperative multi-tasking as the orchestrator works well.
>>>
>>> Bye
>>>
>>> Mild Shock schrieb:
>>>> Hi,
>>>>
>>>> How would we do a reverse sorted map?
>>>>
>>>> I find in Java:
>>>>
>>>> TreeMap(Comparator<? super K> comparator)
>>>> Constructs a new, empty tree map, ordered
>>>> according to the given comparator.
>>>> https://docs.oracle.com/javase/8/docs/api/java/util/TreeMap.html
>>>>
>>>> Or in Dogelog Player:
>>>>
>>>> tree_new(T):
>>>> tree_new(T, F):
>>>> The predicate succeeds in R with a new red-black tree.
>>>> The binary predicate allows specifying a term compare F.
>>>> https://www.dogelog.ch/typtab/doclet/book/12_lang/05_libraries/03_util/06_tree.html 
>>>>
>>>>
>>>> Here is an example, using the destructive API. But
>>>> the same constructor works also for the non-destructive API.
>>>>
>>>> ?- tree_new(_T), tree_add(_T, 0rInf, foo),
>>>>     tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
>>>> L = [0rNaN-bar, 0rInf-foo].
>>>>
>>>> And now using a comparator modifier, aggregate with a comparator,
>>>> as a closure. Some Joy of Higher Order logic programming:
>>>>
>>>> reverse(C, R, X, Y) :- call(C, R, Y, X).
>>>>
>>>> ?- tree_new(_T,reverse(compare)), tree_add(_T, 0rInf, foo),
>>>>     tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
>>>> L = [0rInf-foo, 0rNaN-bar].
>>>>
>>>> ?- tree_new(_T,reverse(reverse(compare))), tree_add(_T, 0rInf, foo),
>>>>     tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
>>>> L = [0rNaN-bar, 0rInf-foo].
>>>>
>>>> Just toying around with my new NaNs.
>>>>
>>>> Have Fun!
>>>>
>>>> Bye
>>>>
>>>> Mild Shock schrieb:
>>>>> Hi,
>>>>>
>>>>> Functional requirement:
>>>>>
>>>>> ?- Y = g(_,_), X = f(Y,C,D,Y), term_singletons(X, L),
>>>>>     L == [C,D].
>>>>>
>>>>> ?- Y = g(A,X,B), X = f(Y,C,D), term_singletons(X, L),
>>>>>     L == [A,B,C,D].
>>>>>
>>>>> Non-Functional requirement:
>>>>>
>>>>> ?- member(N,[5,10,15]), time(singletons(N)), fail; true.
>>>>> % Zeit 1 ms, GC 0 ms, Lips 4046000, Uhr 11.08.2025 01:36
>>>>> % Zeit 3 ms, GC 0 ms, Lips 1352000, Uhr 11.08.2025 01:36
>>>>> % Zeit 3 ms, GC 0 ms, Lips 1355333, Uhr 11.08.2025 01:36
>>>>> true.
>>>>>
>>>>> Can your Prolog system do that?
>>>>>
>>>>> P.S.: Benchmark was:
>>>>>
>>>>> singletons(N) :-
>>>>>     hydra2(N,Y),
>>>>>     between(1,1000,_), term_singletons(Y,_), fail; true.
>>>>>
>>>>> hydra2(0, _) :- !.
>>>>> hydra2(N, s(X,X)) :-
>>>>>     M is N-1,
>>>>>     hydra2(M, X).
>>>>>
>>>>> Bye
>>>>
>>>
>>
> 

[toc] | [prev] | [next] | [standalone]


#15848 — Introducing an asm/1 statement in a Prolog system (Was: AI Accelerators and ISO Prolog multi-threading)

FromMild Shock <janburse@fastmail.fm>
Date2026-08-09 20:21 +0200
SubjectIntroducing an asm/1 statement in a Prolog system (Was: AI Accelerators and ISO Prolog multi-threading)
Message-ID<115ageq$6cmg$1@solani.org>
In reply to#15781
Hi,

I am on the brink of introducig an asm/1 statement
in a Prolog system. The pi-WAM subsystem seems
predestined to support that. And it would help

somehow, to comfortable compile and extend the
pi-WAM subsystem and the submitted goals. One
could directly write built-ins in pi-WAM assembly,

targeting the Hack VM. asm/1 would be more free than
for example what Aquarius Prolog did when they had Berkeley
Abstract Machine (BAM) (*), and which wasn't exposed

it seems via a asm/1. On the other hand C and Rust,
support asm/1 for many targets, exposing their
Assembly phase from the compiler backend:

Inline assembly
https://en.cppreference.com/c/language/asm

Inline assembly
https://doc.rust-lang.org/reference/inline-assembly.html

While the above is true assembly, i.e. architectures
such as x86, ARM, etc.., and gives Scryer Prolog quite
some edge, it could try to transpile WAM to ASM.

In my case I would expose Hack ASM. And the thingy
would be highly dynamic, its not that is only a
compiletime thingy, it can of course be called

at runtime with dynamic arguments.

(*)
https://webperso.info.ucl.ac.be/~pvr/Thesis/ThesisMain.pdf

Mild Shock schrieb:
> Hi,
> 
> Usual question:
> 
>  > Why implement both pre-emptive threading
> AND cooperative tasks/engines?
> 
> I had implemented the ISO proposal in formerly Jekejeke
> Prolog, you find the ISO proposal here:
> 
> ISO/IEC DTR 13211–5:2007
> Prolog multi-threading support
> https://logtalk.org/plstd/threads.pdf
> 
> But the ISO proposal doesn't match modern WebGPU APIs,
> where your logical threads can live remotely in a dedicated GPU
> 
> in the VRAM there, and where you would have launch
> parameters that say: Hey please run 4096 compute
> 
> shaders for me, that have independet thread state. Using
> cooperative multi-tasking as the orchestrator works well.
> 
> Bye

[toc] | [prev] | [next] | [standalone]


#15849 — Introducing an asm/1 statement in a Prolog system (Re: AI Accelerators and ISO Prolog multi-threading)

FromMild Shock <janburse@fastmail.fm>
Date2026-08-09 20:25 +0200
SubjectIntroducing an asm/1 statement in a Prolog system (Re: AI Accelerators and ISO Prolog multi-threading)
Message-ID<115agnc$6cpu$1@solani.org>
In reply to#15781
Hi,

I am on the brink of introducig an asm/1 statement
in a Prolog system. The π-WAM subsystem seems
predestined to support that. And it would help

somehow, to comfortable compile and extend the
π-WAM subsystem and the submitted goals. One
could directly write built-ins in π-WAM assembly,

targeting the Hack VM. asm/1 would be more free than
for example what Aquarius Prolog did when they had Berkeley
Abstract Machine (BAM) (*), and which wasn't exposed

it seems via a asm/1. On the other hand C and Rust,
support asm/1 for many targets, exposing their
Assembly phase from the compiler backend:

Inline assembly
https://en.cppreference.com/c/language/asm

Inline assembly
https://doc.rust-lang.org/reference/inline-assembly.html

While the above is true assembly, i.e. architectures
such as x86, ARM, etc.., and gives Scryer Prolog quite
some edge, it could try to transpile WAM to ASM.

In my case I would expose Hack VM ASM. And the thingy
would be highly dynamic, its not that is only a
compiletime thingy, it can of course be called

at runtime with dynamic arguments.

(*)
Can Logic Programming Execute as Fast as Imperative Programming?
Peter Lodewijk Van Roy - 1990
https://webperso.info.ucl.ac.be/~pvr/Thesis/ThesisMain.pdf


Mild Shock schrieb:
> Hi,
> 
> Usual question:
> 
>  > Why implement both pre-emptive threading
> AND cooperative tasks/engines?
> 
> I had implemented the ISO proposal in formerly Jekejeke
> Prolog, you find the ISO proposal here:
> 
> ISO/IEC DTR 13211–5:2007
> Prolog multi-threading support
> https://logtalk.org/plstd/threads.pdf
> 
> But the ISO proposal doesn't match modern WebGPU APIs,
> where your logical threads can live remotely in a dedicated GPU
> 
> in the VRAM there, and where you would have launch
> parameters that say: Hey please run 4096 compute
> 
> shaders for me, that have independet thread state. Using
> cooperative multi-tasking as the orchestrator works well.
> 
> Bye
> 
> Mild Shock schrieb:
>> Hi,
>>
>> How would we do a reverse sorted map?
>>
>> I find in Java:
>>
>> TreeMap(Comparator<? super K> comparator)
>> Constructs a new, empty tree map, ordered
>> according to the given comparator.
>> https://docs.oracle.com/javase/8/docs/api/java/util/TreeMap.html
>>
>> Or in Dogelog Player:
>>
>> tree_new(T):
>> tree_new(T, F):
>> The predicate succeeds in R with a new red-black tree.
>> The binary predicate allows specifying a term compare F.
>> https://www.dogelog.ch/typtab/doclet/book/12_lang/05_libraries/03_util/06_tree.html 
>>
>>
>> Here is an example, using the destructive API. But
>> the same constructor works also for the non-destructive API.
>>
>> ?- tree_new(_T), tree_add(_T, 0rInf, foo),
>>     tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
>> L = [0rNaN-bar, 0rInf-foo].
>>
>> And now using a comparator modifier, aggregate with a comparator,
>> as a closure. Some Joy of Higher Order logic programming:
>>
>> reverse(C, R, X, Y) :- call(C, R, Y, X).
>>
>> ?- tree_new(_T,reverse(compare)), tree_add(_T, 0rInf, foo),
>>     tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
>> L = [0rInf-foo, 0rNaN-bar].
>>
>> ?- tree_new(_T,reverse(reverse(compare))), tree_add(_T, 0rInf, foo),
>>     tree_add(_T, 0rNaN, bar), tree_pairs(_T, L).
>> L = [0rNaN-bar, 0rInf-foo].
>>
>> Just toying around with my new NaNs.
>>
>> Have Fun!
>>
>> Bye
>>
>> Mild Shock schrieb:
>>> Hi,
>>>
>>> Functional requirement:
>>>
>>> ?- Y = g(_,_), X = f(Y,C,D,Y), term_singletons(X, L),
>>>     L == [C,D].
>>>
>>> ?- Y = g(A,X,B), X = f(Y,C,D), term_singletons(X, L),
>>>     L == [A,B,C,D].
>>>
>>> Non-Functional requirement:
>>>
>>> ?- member(N,[5,10,15]), time(singletons(N)), fail; true.
>>> % Zeit 1 ms, GC 0 ms, Lips 4046000, Uhr 11.08.2025 01:36
>>> % Zeit 3 ms, GC 0 ms, Lips 1352000, Uhr 11.08.2025 01:36
>>> % Zeit 3 ms, GC 0 ms, Lips 1355333, Uhr 11.08.2025 01:36
>>> true.
>>>
>>> Can your Prolog system do that?
>>>
>>> P.S.: Benchmark was:
>>>
>>> singletons(N) :-
>>>     hydra2(N,Y),
>>>     between(1,1000,_), term_singletons(Y,_), fail; true.
>>>
>>> hydra2(0, _) :- !.
>>> hydra2(N, s(X,X)) :-
>>>     M is N-1,
>>>     hydra2(M, X).
>>>
>>> Bye
>>
> 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.prolog


csiph-web