[m-rev.] diff: Reset memo tables in fast_loose test.

Peter Wang novalazy at gmail.com
Wed Nov 11 18:11:07 AEDT 2020


tests/tabling/fast_loose.m:
    Reset memo tables between before each trial. Results left in the
    memo tables from previous trials cause subsequent trials to run
    faster than they otherwise would, making it harder to detect a
    difference in run time between strict and fast-loose tabling.
    The program ends up trying bigger and bigger numbers, inflating the
    memo tables, and possibly running out of heap or stack space.

diff --git a/tests/tabling/fast_loose.m b/tests/tabling/fast_loose.m
index c8ecfff5c..d8f95cb8b 100644
--- a/tests/tabling/fast_loose.m
+++ b/tests/tabling/fast_loose.m
@@ -25,6 +25,8 @@ main(!IO) :-
 :- pred perform_trials(int::in, io::di, io::uo) is cc_multi.
 
 perform_trials(N, !IO) :-
+    table_reset_for_strict_sum_2(!IO),
+    table_reset_for_fast_loose_sum_2(!IO),
     trial(N, STime, FLTime),
     % io.write_int(N, !IO),
     % io.write_string(": ", !IO),
@@ -65,7 +67,7 @@ strict(N, R) :-
     strict_sum(iota(N), R).
 
 :- pred strict_sum(list(int)::in, int::out) is det.
-:- pragma memo(strict_sum/2).
+:- pragma memo(strict_sum/2, [allow_reset]).
 
 strict_sum([], 0).
 strict_sum([H | T], H + TS) :-
@@ -77,7 +79,7 @@ fast_loose(N, R) :-
     fast_loose_sum(iota(N), R).
 
 :- pred fast_loose_sum(list(int)::in, int::out) is det.
-:- pragma memo(fast_loose_sum/2, [fast_loose]).
+:- pragma memo(fast_loose_sum/2, [fast_loose, allow_reset]).
 
 fast_loose_sum([], 0).
 fast_loose_sum([H | T], H + TS) :-
-- 
2.29.2



More information about the reviews mailing list