2010-04-20 03:59:48 +01:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%% %%
|
|
|
|
%% The YapTab/YapOr/OPTYap systems %%
|
|
|
|
%% %%
|
|
|
|
%% YapTab extends the Yap Prolog engine to support sequential tabling %%
|
|
|
|
%% YapOr extends the Yap Prolog engine to support or-parallelism %%
|
|
|
|
%% OPTYap extends the Yap Prolog engine to support or-parallel tabling %%
|
|
|
|
%% %%
|
|
|
|
%% %%
|
|
|
|
%% Yap Prolog was developed at University of Porto, Portugal %%
|
|
|
|
%% %%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
:- meta_predicate
|
2011-06-25 12:50:22 +01:00
|
|
|
parallel(0),
|
|
|
|
parallel_findall(?,0,?),
|
|
|
|
parallel_once(0).
|
2010-04-20 03:59:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-05-25 18:38:46 +01:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%% or_statistics/0 %%
|
|
|
|
%% opt_statistics/0 %%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
or_statistics :-
|
|
|
|
current_output(Stream),
|
|
|
|
or_statistics(Stream).
|
|
|
|
|
|
|
|
opt_statistics :-
|
|
|
|
current_output(Stream),
|
|
|
|
opt_statistics(Stream).
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-04-20 03:59:48 +01:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%% or_statistics/2 %%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
2010-04-23 04:22:10 +01:00
|
|
|
%% should match with code in OPTYap/opt.preds.c
|
2010-04-20 03:59:48 +01:00
|
|
|
or_statistics(total_memory,[BytesInUse,BytesAllocated]) :-
|
|
|
|
'$c_get_optyap_statistics'(0,BytesInUse,BytesAllocated).
|
|
|
|
or_statistics(or_frames,[BytesInUse,StructsInUse]) :-
|
|
|
|
'$c_get_optyap_statistics'(4,BytesInUse,StructsInUse).
|
|
|
|
or_statistics(query_goal_solution_frames,[BytesInUse,StructsInUse]) :-
|
|
|
|
'$c_get_optyap_statistics'(12,BytesInUse,StructsInUse).
|
|
|
|
or_statistics(query_goal_answer_frames,[BytesInUse,StructsInUse]) :-
|
|
|
|
'$c_get_optyap_statistics'(13,BytesInUse,StructsInUse).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
%% opt_statistics/2 %%
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
2010-04-23 04:22:10 +01:00
|
|
|
%% should match with code in OPTYap/opt.preds.c
|
2010-04-20 03:59:48 +01:00
|
|
|
opt_statistics(total_memory,[BytesInUse,BytesAllocated]) :-
|
|
|
|
'$c_get_optyap_statistics'(0,BytesInUse,BytesAllocated).
|
|
|
|
opt_statistics(table_entries,[BytesInUse,StructsInUse]) :-
|
|
|
|
'$c_get_optyap_statistics'(1,BytesInUse,StructsInUse).
|
|
|
|
opt_statistics(subgoal_frames,[BytesInUse,StructsInUse]) :-
|
|
|
|
'$c_get_optyap_statistics'(2,BytesInUse,StructsInUse).
|
|
|
|
opt_statistics(dependency_frames,[BytesInUse,StructsInUse]) :-
|
|
|
|
'$c_get_optyap_statistics'(3,BytesInUse,StructsInUse).
|
|
|
|
opt_statistics(or_frames,[BytesInUse,StructsInUse]) :-
|
|
|
|
'$c_get_optyap_statistics'(4,BytesInUse,StructsInUse).
|
|
|
|
opt_statistics(suspension_frames,[BytesInUse,StructsInUse]) :-
|
|
|
|
'$c_get_optyap_statistics'(5,BytesInUse,StructsInUse).
|
|
|
|
opt_statistics(subgoal_trie_nodes,[BytesInUse,StructsInUse]) :-
|
|
|
|
'$c_get_optyap_statistics'(6,BytesInUse,StructsInUse).
|
|
|
|
opt_statistics(answer_trie_nodes,[BytesInUse,StructsInUse]) :-
|
|
|
|
'$c_get_optyap_statistics'(7,BytesInUse,StructsInUse).
|
|
|
|
opt_statistics(subgoal_trie_hashes,[BytesInUse,StructsInUse]) :-
|
|
|
|
'$c_get_optyap_statistics'(8,BytesInUse,StructsInUse).
|
|
|
|
opt_statistics(answer_trie_hashes,[BytesInUse,StructsInUse]) :-
|
|
|
|
'$c_get_optyap_statistics'(9,BytesInUse,StructsInUse).
|
|
|
|
opt_statistics(global_trie_nodes,[BytesInUse,StructsInUse]) :-
|
|
|
|
'$c_get_optyap_statistics'(10,BytesInUse,StructsInUse).
|
|
|
|
opt_statistics(global_trie_hashes,[BytesInUse,StructsInUse]) :-
|
|
|
|
'$c_get_optyap_statistics'(11,BytesInUse,StructsInUse).
|
|
|
|
opt_statistics(query_goal_solution_frames,[BytesInUse,StructsInUse]) :-
|
|
|
|
'$c_get_optyap_statistics'(12,BytesInUse,StructsInUse).
|
|
|
|
opt_statistics(query_goal_answer_frames,[BytesInUse,StructsInUse]) :-
|
|
|
|
'$c_get_optyap_statistics'(13,BytesInUse,StructsInUse).
|
|
|
|
opt_statistics(table_subgoal_solution_frames,[BytesInUse,StructsInUse]) :-
|
|
|
|
'$c_get_optyap_statistics'(14,BytesInUse,StructsInUse).
|
|
|
|
opt_statistics(table_subgoal_answer_frames,[BytesInUse,StructsInUse]) :-
|
|
|
|
'$c_get_optyap_statistics'(15,BytesInUse,StructsInUse).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2011-06-21 15:19:07 +01:00
|
|
|
%% parallel/1 %%
|
2010-04-20 03:59:48 +01:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2011-06-21 15:19:07 +01:00
|
|
|
parallel(Goal) :-
|
|
|
|
parallel_mode(Mode), Mode = on, !,
|
|
|
|
(
|
|
|
|
'$parallel_query'(Goal)
|
|
|
|
;
|
|
|
|
true
|
|
|
|
).
|
|
|
|
parallel(Goal) :-
|
|
|
|
(
|
|
|
|
'$execute'(Goal),
|
|
|
|
fail
|
|
|
|
;
|
|
|
|
true
|
|
|
|
).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2011-06-21 15:19:07 +01:00
|
|
|
'$parallel_query'(Goal) :-
|
|
|
|
'$c_yapor_start',
|
|
|
|
'$execute'(Goal),
|
|
|
|
fail.
|
|
|
|
'$parallel_query'(_).
|
2010-04-20 03:59:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2011-06-21 15:19:07 +01:00
|
|
|
%% parallel_findall/3 %%
|
2010-04-20 03:59:48 +01:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
2011-06-21 15:19:07 +01:00
|
|
|
parallel_findall(Template,Goal,Answers) :-
|
|
|
|
parallel_mode(Mode), Mode = on, !,
|
2010-04-20 03:59:48 +01:00
|
|
|
(
|
2011-06-21 15:19:07 +01:00
|
|
|
'$parallel_findall_query'(Template,Goal)
|
2010-04-20 03:59:48 +01:00
|
|
|
;
|
2011-06-21 15:19:07 +01:00
|
|
|
findall(X,'$parallel_findall_recorded'(X), Answers)
|
2010-04-20 03:59:48 +01:00
|
|
|
).
|
2011-06-21 15:19:07 +01:00
|
|
|
parallel_findall(Template,Goal,Answers) :-
|
|
|
|
findall(Template,Goal,Answers).
|
|
|
|
|
|
|
|
'$parallel_findall_query'(Template,Goal) :-
|
|
|
|
'$c_yapor_start',
|
|
|
|
'$execute'(Goal),
|
|
|
|
recordz(parallel_findall,Template,_),
|
|
|
|
%% '$c_parallel_new_answer'(Ref),
|
|
|
|
fail.
|
|
|
|
'$parallel_findall_query'(_,_).
|
|
|
|
|
|
|
|
'$parallel_findall_recorded'(Template) :-
|
|
|
|
recorded(parallel_findall,Template,Ref),
|
|
|
|
erase(Ref).
|
2010-04-20 03:59:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2011-06-21 15:19:07 +01:00
|
|
|
%% parallel_once/1 %%
|
2010-04-20 03:59:48 +01:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
2011-06-21 15:19:07 +01:00
|
|
|
parallel_once(Goal) :-
|
|
|
|
parallel_mode(Mode), Mode = on, !,
|
2010-04-20 03:59:48 +01:00
|
|
|
(
|
2011-06-21 15:19:07 +01:00
|
|
|
'$parallel_once_query'(Goal)
|
2010-04-20 03:59:48 +01:00
|
|
|
;
|
2011-06-21 15:19:07 +01:00
|
|
|
recorded(parallel_once,Goal,Ref),
|
|
|
|
erase(Ref)
|
2010-04-20 03:59:48 +01:00
|
|
|
).
|
2011-06-21 15:19:07 +01:00
|
|
|
parallel_once(Goal) :-
|
|
|
|
once(Goal).
|
|
|
|
|
|
|
|
'$parallel_once_query'(Goal) :-
|
|
|
|
'$c_yapor_start',
|
2011-06-22 19:20:56 +01:00
|
|
|
'$execute'(once(Goal)),
|
2011-06-21 15:19:07 +01:00
|
|
|
recordz(parallel_once,Goal,_),
|
|
|
|
fail.
|
|
|
|
'$parallel_once_query'(_).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2010-04-23 04:22:10 +01:00
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|