Re: PIPs from the Basilisk Chamber (Was: 50 Years of Prolog Nonsense)

Liste des GroupesRevenir à cl prolog 
Sujet : Re: PIPs from the Basilisk Chamber (Was: 50 Years of Prolog Nonsense)
De : janburse (at) *nospam* fastmail.fm (Mild Shock)
Groupes : comp.lang.prolog
Date : 09. Nov 2024, 15:48:54
Autres entêtes
Message-ID : <vgnsol$d3as$2@solani.org>
References : 1 2 3 4 5 6 7 8 9 10
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.19
With this little change it already beats all
the call_cleanup/2 based findall/3 implementations
around from some novell Prolog systems:
/* Trealla Prolog 2.59.15 */
?- time(test).
% Time elapsed 0.356s, 3004004 Inferences, 8.436 MLips
    true.
/* Scryer Prolog 0.9.4-201 */
?- time(test).
    % CPU time: 0.464s, 5_062_044 inferences
    true.
Mild Shock schrieb:
I can speed it up, if I use nb_setarg/3 instead
of the explicit duplicate_term/2 and nb_linkarg/3 combo.
The change is as follows:
 /* Before */
sys_find2_next(T, X) :-
    C = [_|_],
    duplicate_term(T, H),
    nb_linkarg(1, C, H),
    arg(1, X, J),
    nb_linkarg(2, J, C),
    nb_linkarg(1, X, C)
 /* After */
sys_find2_next(T, X) :-
    C = [_|_],
    nb_setarg(1, C, T),
    arg(1, X, J),
    nb_linkarg(2, J, C),
    nb_linkarg(1, X, C).
 Now the timings are better:
 /* Before */
?- time(test2).
% 6,007,999 inferences, 0.422 CPU in 0.427
seconds (99% CPU, 14241183 Lips)
true.
 /* After */
?- time(test2).
% 5,007,999 inferences, 0.297 CPU in 0.298
seconds (100% CPU, 16869049 Lips)
true.
 A wooping more than 100 milliseconds are gone!

Date Sujet#  Auteur
29 Sep 24 * PIPs from the Basilisk Chamber (Was: 50 Years of Prolog Nonsense)7Mild Shock
8 Nov 24 +* Prolog Pearls I: Barklund and Millroth (Was: PIPs from the Basilisk Chamber)4Mild Shock
8 Nov 24 i`* Prolog Pearls II: Barklund and Millroth (Was: PIPs from the Basilisk Chamber)3Mild Shock
8 Nov 24 i `* change_arg/3 = nb_linkarg/3 ? (Was: PIPs from the Basilisk Chamber)2Mild Shock
8 Nov 24 i  `- Re: change_arg/3 = nb_linkarg/3 ? (Was: PIPs from the Basilisk Chamber)1Mild Shock
9 Nov 24 `* Re: PIPs from the Basilisk Chamber (Was: 50 Years of Prolog Nonsense)2Mild Shock
9 Nov 24  `- Re: PIPs from the Basilisk Chamber (Was: 50 Years of Prolog Nonsense)1Mild Shock

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal