Merge branch 'master' of gitosis@yap.dcc.fc.up.pt:yap-6
This commit is contained in:
commit
788193b0c9
@ -4155,8 +4155,8 @@ Yap_InitCPreds(void)
|
|||||||
Yap_InitCPred("$has_yap_or", 0, p_has_yap_or, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
Yap_InitCPred("$has_yap_or", 0, p_has_yap_or, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||||
Yap_InitCPred("$has_eam", 0, p_has_eam, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
Yap_InitCPred("$has_eam", 0, p_has_eam, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||||
#ifndef YAPOR
|
#ifndef YAPOR
|
||||||
Yap_InitCPred("$default_sequential", 1, p_default_sequential, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
Yap_InitCPred("$c_default_sequential", 1, p_default_sequential, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||||
Yap_InitCPred("$yapor_threads", 1, p_yapor_threads, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
Yap_InitCPred("$c_yapor_threads", 1, p_yapor_threads, SafePredFlag|SyncPredFlag|HiddenPredFlag);
|
||||||
#endif
|
#endif
|
||||||
#ifdef INES
|
#ifdef INES
|
||||||
Yap_InitCPred("euc_dist", 3, p_euc_dist, SafePredFlag);
|
Yap_InitCPred("euc_dist", 3, p_euc_dist, SafePredFlag);
|
||||||
@ -4169,9 +4169,6 @@ Yap_InitCPreds(void)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Yap_InitCPred("dump_active_goals", 0, p_dump_active_goals, SafePredFlag|SyncPredFlag);
|
Yap_InitCPred("dump_active_goals", 0, p_dump_active_goals, SafePredFlag|SyncPredFlag);
|
||||||
#endif
|
#endif
|
||||||
#ifndef YAPOR
|
|
||||||
Yap_InitCPred("$yapor_threads", 1, p_yapor_threads, SafePredFlag|SyncPredFlag);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Yap_InitArrayPreds();
|
Yap_InitArrayPreds();
|
||||||
Yap_InitBBPreds();
|
Yap_InitBBPreds();
|
||||||
|
1892
OPTYap/opt.preds.c
1892
OPTYap/opt.preds.c
File diff suppressed because it is too large
Load Diff
10
pl/boot.yap
10
pl/boot.yap
@ -121,13 +121,13 @@ true :- true.
|
|||||||
nb_setval('$included_file',[]).
|
nb_setval('$included_file',[]).
|
||||||
|
|
||||||
'$init_or_threads' :-
|
'$init_or_threads' :-
|
||||||
'$yapor_threads'(W), !,
|
'$c_yapor_threads'(W), !,
|
||||||
'$start_orp_threads'(W).
|
'$start_orp_threads'(W).
|
||||||
'$init_or_threads'.
|
'$init_or_threads'.
|
||||||
|
|
||||||
'$start_orp_threads'(1) :- !.
|
'$start_orp_threads'(1) :- !.
|
||||||
'$start_orp_threads'(W) :-
|
'$start_orp_threads'(W) :-
|
||||||
thread_create('$worker',_,[detached(true)]),
|
thread_create('$c_worker',_,[detached(true)]),
|
||||||
W1 is W-1,
|
W1 is W-1,
|
||||||
'$start_orp_threads'(W1).
|
'$start_orp_threads'(W1).
|
||||||
|
|
||||||
@ -500,9 +500,9 @@ true :- true.
|
|||||||
% ***************************
|
% ***************************
|
||||||
|
|
||||||
'$query'(G,V) :-
|
'$query'(G,V) :-
|
||||||
\+ '$undefined'('$yapor_on', prolog),
|
\+ '$undefined'('$c_yapor_on', prolog),
|
||||||
'$yapor_on',
|
'$c_yapor_on',
|
||||||
\+ '$undefined'('$start_yapor', prolog),
|
\+ '$undefined'('$c_start_yapor', prolog),
|
||||||
'$parallelizable'(G), !,
|
'$parallelizable'(G), !,
|
||||||
'$parallel_query'(G,V),
|
'$parallel_query'(G,V),
|
||||||
fail.
|
fail.
|
||||||
|
@ -542,7 +542,7 @@ yap_flag(system_options,X) :-
|
|||||||
'$system_options'(low_level_tracer) :-
|
'$system_options'(low_level_tracer) :-
|
||||||
\+ '$undefined'(start_low_level_trace, prolog).
|
\+ '$undefined'(start_low_level_trace, prolog).
|
||||||
'$system_options'(or_parallelism) :-
|
'$system_options'(or_parallelism) :-
|
||||||
\+ '$undefined'('$yapor_on', prolog).
|
\+ '$undefined'('$c_yapor_on', prolog).
|
||||||
'$system_options'(rational_trees) :-
|
'$system_options'(rational_trees) :-
|
||||||
'$yap_has_rational_trees'.
|
'$yap_has_rational_trees'.
|
||||||
'$system_options'(readline) :-
|
'$system_options'(readline) :-
|
||||||
|
106
pl/tabling.yap
106
pl/tabling.yap
@ -1,27 +1,30 @@
|
|||||||
/*************************************************************************
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
* *
|
%% %%
|
||||||
* YAP Prolog *
|
%% The YapTab/YapOr/OPTYap systems %%
|
||||||
* *
|
%% %%
|
||||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
%% YapTab extends the Yap Prolog engine to support sequential tabling %%
|
||||||
* *
|
%% YapOr extends the Yap Prolog engine to support or-parallelism %%
|
||||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
%% OPTYap extends the Yap Prolog engine to support or-parallel tabling %%
|
||||||
* *
|
%% %%
|
||||||
**************************************************************************
|
%% %%
|
||||||
* *
|
%% Yap Prolog was developed at University of Porto, Portugal %%
|
||||||
* File: tabling.yap *
|
%% %%
|
||||||
* Last rev: 8/2/88 *
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
* mods: *
|
|
||||||
* comments: support tabling predicates *
|
|
||||||
* *
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
:- meta_predicate table(:), is_tabled(:), tabling_mode(:), abolish_table(:), show_table(:), table_statistics(:).
|
:- meta_predicate
|
||||||
|
table(:),
|
||||||
|
is_tabled(:),
|
||||||
|
tabling_mode(:),
|
||||||
|
abolish_table(:),
|
||||||
|
show_table(:),
|
||||||
|
table_statistics(:),
|
||||||
|
table_statistics(:,:).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/******************
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
* table/1 *
|
%% table/1 %%
|
||||||
******************/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
table(Pred) :-
|
table(Pred) :-
|
||||||
'$current_module'(Mod),
|
'$current_module'(Mod),
|
||||||
@ -64,9 +67,9 @@ table(Pred) :-
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
* is_tabled/1 *
|
%% is_tabled/1 %%
|
||||||
**********************/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
is_tabled(Pred) :-
|
is_tabled(Pred) :-
|
||||||
'$current_module'(Mod),
|
'$current_module'(Mod),
|
||||||
@ -95,9 +98,9 @@ is_tabled(Pred) :-
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*************************
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
* tabling_mode/2 *
|
%% tabling_mode/2 %%
|
||||||
*************************/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
tabling_mode(Pred,Options) :-
|
tabling_mode(Pred,Options) :-
|
||||||
'$current_module'(Mod),
|
'$current_module'(Mod),
|
||||||
@ -123,7 +126,6 @@ tabling_mode(Pred,Options) :-
|
|||||||
(
|
(
|
||||||
Flags /\ 0x000040 =\= 0, !, '$set_tabling_mode'(Mod,PredFunctor,Options)
|
Flags /\ 0x000040 =\= 0, !, '$set_tabling_mode'(Mod,PredFunctor,Options)
|
||||||
;
|
;
|
||||||
write(icardioi),nl,
|
|
||||||
'$do_error'(domain_error(table,Mod:PredName/PredArity),tabling_mode(Mod:PredName/PredArity,Options))
|
'$do_error'(domain_error(table,Mod:PredName/PredArity),tabling_mode(Mod:PredName/PredArity,Options))
|
||||||
).
|
).
|
||||||
'$do_tabling_mode'(Mod,Pred,Options) :-
|
'$do_tabling_mode'(Mod,Pred,Options) :-
|
||||||
@ -146,7 +148,7 @@ write(icardioi),nl,
|
|||||||
functor(PredFunctor,PredName,PredArity),
|
functor(PredFunctor,PredName,PredArity),
|
||||||
'$do_error'(domain_error(flag_value,tabling_mode+Options),tabling_mode(Mod:PredName/PredArity,Options)).
|
'$do_error'(domain_error(flag_value,tabling_mode+Options),tabling_mode(Mod:PredName/PredArity,Options)).
|
||||||
|
|
||||||
% should match with code in OPTYap/opt.preds.c
|
%% should match with code in OPTYap/opt.preds.c
|
||||||
'$transl_to_pred_flag_tabling_mode'(1,batched).
|
'$transl_to_pred_flag_tabling_mode'(1,batched).
|
||||||
'$transl_to_pred_flag_tabling_mode'(2,local).
|
'$transl_to_pred_flag_tabling_mode'(2,local).
|
||||||
'$transl_to_pred_flag_tabling_mode'(3,exec_answers).
|
'$transl_to_pred_flag_tabling_mode'(3,exec_answers).
|
||||||
@ -156,9 +158,9 @@ write(icardioi),nl,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**************************
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
* abolish_table/1 *
|
%% abolish_table/1 %%
|
||||||
**************************/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
abolish_table(Pred) :-
|
abolish_table(Pred) :-
|
||||||
'$current_module'(Mod),
|
'$current_module'(Mod),
|
||||||
@ -191,9 +193,9 @@ abolish_table(Pred) :-
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***********************
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
* show_table/1 *
|
%% show_table/1 %%
|
||||||
***********************/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
show_table(Pred) :-
|
show_table(Pred) :-
|
||||||
'$current_module'(Mod),
|
'$current_module'(Mod),
|
||||||
@ -226,9 +228,9 @@ show_table(Pred) :-
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
* table_statistics/1 *
|
%% table_statistics/1 %%
|
||||||
*****************************/
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
table_statistics(Pred) :-
|
table_statistics(Pred) :-
|
||||||
'$current_module'(Mod),
|
'$current_module'(Mod),
|
||||||
@ -258,3 +260,33 @@ table_statistics(Pred) :-
|
|||||||
).
|
).
|
||||||
'$do_table_statistics'(Mod,Pred) :-
|
'$do_table_statistics'(Mod,Pred) :-
|
||||||
'$do_error'(type_error(callable,Mod:Pred),table_statistics(Mod:Pred)).
|
'$do_error'(type_error(callable,Mod:Pred),table_statistics(Mod:Pred)).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
%% tabling_statistics/2 %%
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
%% should match with code in OPTYap/opt.preds.c
|
||||||
|
tabling_statistics(total_memory,[BytesInUse,BytesAllocated]) :-
|
||||||
|
'$c_get_optyap_statistics'(0,BytesInUse,BytesAllocated).
|
||||||
|
tabling_statistics(table_entries,[BytesInUse,StructsInUse]) :-
|
||||||
|
'$c_get_optyap_statistics'(1,BytesInUse,StructsInUse).
|
||||||
|
tabling_statistics(subgoal_frames,[BytesInUse,StructsInUse]) :-
|
||||||
|
'$c_get_optyap_statistics'(2,BytesInUse,StructsInUse).
|
||||||
|
tabling_statistics(dependency_frames,[BytesInUse,StructsInUse]) :-
|
||||||
|
'$c_get_optyap_statistics'(3,BytesInUse,StructsInUse).
|
||||||
|
tabling_statistics(subgoal_trie_nodes,[BytesInUse,StructsInUse]) :-
|
||||||
|
'$c_get_optyap_statistics'(6,BytesInUse,StructsInUse).
|
||||||
|
tabling_statistics(answer_trie_nodes,[BytesInUse,StructsInUse]) :-
|
||||||
|
'$c_get_optyap_statistics'(7,BytesInUse,StructsInUse).
|
||||||
|
tabling_statistics(subgoal_trie_hashes,[BytesInUse,StructsInUse]) :-
|
||||||
|
'$c_get_optyap_statistics'(8,BytesInUse,StructsInUse).
|
||||||
|
tabling_statistics(answer_trie_hashes,[BytesInUse,StructsInUse]) :-
|
||||||
|
'$c_get_optyap_statistics'(9,BytesInUse,StructsInUse).
|
||||||
|
tabling_statistics(global_trie_nodes,[BytesInUse,StructsInUse]) :-
|
||||||
|
'$c_get_optyap_statistics'(10,BytesInUse,StructsInUse).
|
||||||
|
tabling_statistics(global_trie_hashes,[BytesInUse,StructsInUse]) :-
|
||||||
|
'$c_get_optyap_statistics'(11,BytesInUse,StructsInUse).
|
||||||
|
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
245
pl/yapor.yap
245
pl/yapor.yap
@ -1,108 +1,208 @@
|
|||||||
/*************************************************************************
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
* *
|
%% %%
|
||||||
* YAP Prolog *
|
%% The YapTab/YapOr/OPTYap systems %%
|
||||||
* *
|
%% %%
|
||||||
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
%% YapTab extends the Yap Prolog engine to support sequential tabling %%
|
||||||
* *
|
%% YapOr extends the Yap Prolog engine to support or-parallelism %%
|
||||||
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
%% OPTYap extends the Yap Prolog engine to support or-parallel tabling %%
|
||||||
* *
|
%% %%
|
||||||
**************************************************************************
|
%% %%
|
||||||
* *
|
%% Yap Prolog was developed at University of Porto, Portugal %%
|
||||||
* File: yapor.yap *
|
%% %%
|
||||||
* Last rev: 8/2/88 *
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
* mods: *
|
|
||||||
* comments: support or-parallelism *
|
|
||||||
* *
|
|
||||||
*************************************************************************/
|
|
||||||
|
|
||||||
'$parallel_query'(G,[]) :- !, '$start_yapor', '$execute'(G), !,
|
:- meta_predicate
|
||||||
'$parallel_yes_answer'.
|
or_statistics(:,:),
|
||||||
'$parallel_query'(G,V) :- '$start_yapor', '$execute'(G), '$parallel_new_answer'(V).
|
opt_statistics(:,:),
|
||||||
|
default_sequential(:).
|
||||||
|
|
||||||
% ***************************
|
|
||||||
% * -------- YAPOR -------- *
|
|
||||||
% ***************************
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
%% or_statistics/2 %%
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
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 %%
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
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).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
%% default_sequential/1 %%
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
default_sequential(X) :-
|
default_sequential(X) :-
|
||||||
'$default_sequential'(X), !.
|
'$c_default_sequential'(X), !.
|
||||||
default_sequential(_).
|
default_sequential(_).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
%% $parallel_query/2 %%
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
'$parallel_query'(G,[]) :- !,
|
||||||
|
'$c_start_yapor',
|
||||||
|
'$execute'(G), !,
|
||||||
|
'$c_parallel_yes_answer'.
|
||||||
|
'$parallel_query'(G,V) :-
|
||||||
|
'$c_start_yapor',
|
||||||
|
'$execute'(G),
|
||||||
|
'$c_parallel_new_answer'(V).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
%% $sequential/0 %%
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
'$sequential' :-
|
'$sequential' :-
|
||||||
'$default_sequential'(X),
|
'$c_default_sequential'(X),
|
||||||
'$initialization'('$default_sequential'(X)),
|
'$initialization'('$c_default_sequential'(X)),
|
||||||
'$default_sequential'(on).
|
'$c_default_sequential'(on).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
%% $parallel/0 %%
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
'$parallel' :-
|
'$parallel' :-
|
||||||
'$default_sequential'(X),
|
'$c_default_sequential'(X),
|
||||||
'$initialization'('$default_sequential'(X)),
|
'$initialization'('$c_default_sequential'(X)),
|
||||||
'$default_sequential'(off).
|
'$c_default_sequential'(off).
|
||||||
|
|
||||||
'$sequential_directive'(X,_) :- var(X), !,
|
|
||||||
write(user_error, '[ Error: argument to sequential/1 should be a predicate ]'),
|
|
||||||
nl(user_error),
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
fail.
|
%% $sequential_directive/2 %%
|
||||||
'$sequential_directive'((A,B),M) :- !,
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
'$sequential_directive'(A,M), '$sequential_directive'(B,M).
|
|
||||||
'$sequential_directive'(M:A,_) :- !,
|
'$sequential_directive'(Pred,Mod) :-
|
||||||
'$sequential_directive'(A,M).
|
var(Pred), !,
|
||||||
'$sequential_directive'(A/N,M) :- integer(N), atom(A), !,
|
'$do_error'(instantiation_error,sequential(Mod:Pred)).
|
||||||
functor(T,A,N),
|
'$sequential_directive'(Mod:Pred,_) :- !,
|
||||||
'$flags'(T,M,F,F),
|
'$sequential_directive'(Pred,Mod).
|
||||||
|
'$sequential_directive'((Pred1,Pred2),Mod) :- !,
|
||||||
|
'$sequential_directive'(Pred1,Mod),
|
||||||
|
'$sequential_directive'(Pred2,Mod).
|
||||||
|
'$sequential_directive'(PredName/PredArity,Mod) :-
|
||||||
|
atom(PredName), integer(PredArity),
|
||||||
|
functor(PredFunctor,PredName,PredArity), !,
|
||||||
|
'$flags'(PredFunctor,Mod,Flags,Flags),
|
||||||
(
|
(
|
||||||
X is F /\ 0x00000020, X =\= 0, !,
|
Flags /\ 0x1991F880 =:= 0, !,
|
||||||
|
(
|
||||||
|
Flags /\ 0x00000020 =\= 0, !,
|
||||||
write(user_error, '[ Warning: '),
|
write(user_error, '[ Warning: '),
|
||||||
write(user_error, M:A/N),
|
write(user_error, Mod:PredName/PredArity),
|
||||||
write(user_error, ' is already declared as sequential ]'),
|
write(user_error, ' is already declared as sequential ]'),
|
||||||
nl(user_error)
|
nl(user_error)
|
||||||
;
|
;
|
||||||
X is F /\ 0x1991F880, X =:= 0, !, '$sequential'(T,M)
|
NewFlags is Flags \/ 0x00000020,
|
||||||
|
'$flags'(PredFunctor,Mod,Flags,NewFlags)
|
||||||
|
),
|
||||||
;
|
;
|
||||||
write(user_error, '[ Error: '),
|
write(user_error, '[ Error: '),
|
||||||
write(user_error, M:A/N),
|
write(user_error, Mod:PredName/PredArity),
|
||||||
write(user_error, ' cannot be declared as sequential ]'),
|
write(user_error, ' cannot be declared as sequential ]'),
|
||||||
nl(user_error),
|
nl(user_error),
|
||||||
fail
|
fail
|
||||||
).
|
).
|
||||||
'$sequential_directive'(X,_) :- write(user_error, '[ Error: '),
|
'$sequential_directive'(Pred,Mod) :-
|
||||||
write(user_error, X),
|
'$do_error'(type_error(callable,Mod:Pred),sequential(Mod:Pred)).
|
||||||
write(user_error, ' is an invalid argument to sequential/1 ]'),
|
|
||||||
nl(user_error),
|
|
||||||
fail.
|
|
||||||
|
|
||||||
'$parallel_directive'(X,M) :- var(X), !,
|
|
||||||
'$do_error'(instantiation_error,parallel(M:X)).
|
|
||||||
'$parallel_directive'((A,B),M) :- !,
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
'$parallel_directive'(A,M),
|
%% $parallel_directive/2 %%
|
||||||
'parallel_directive'(B,M).
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
'$parallel_directive'(M:A,_) :- !,
|
|
||||||
'$parallel_directive'(A,M).
|
'$parallel_directive'(Pred,Mod) :-
|
||||||
'$parallel_directive'(A/N,M) :- integer(N), atom(A), !,
|
var(Pred), !,
|
||||||
functor(T,A,N), '$flags'(T,M,F,F),
|
'$do_error'(instantiation_error,parallel(Mod:Pred)).
|
||||||
|
'$parallel_directive'((Pred1,Pred2),Mod) :- !,
|
||||||
|
'$parallel_directive'(Pred1,Mod),
|
||||||
|
'$parallel_directive'(Pred2,Mod).
|
||||||
|
'$parallel_directive'(Mod:Pred,_) :- !,
|
||||||
|
'$parallel_directive'(Pred,Mod).
|
||||||
|
'$parallel_directive'(PredName/PredArity,Mod) :-
|
||||||
|
atom(PredName), integer(PredArity),
|
||||||
|
functor(PredFunctor,PredName,PredArity), !,
|
||||||
|
'$flags'(PredFunctor,Mod,Flags,Flags),
|
||||||
(
|
(
|
||||||
NF is F /\ 0x00000020, '$flags'(T,F,NF) ;
|
Flags /\ 0x1991F880 =:= 0, !,
|
||||||
|
(
|
||||||
|
Flags /\ 0x00000020 =:= 0, !,
|
||||||
write(user_error, '[ Warning: '),
|
write(user_error, '[ Warning: '),
|
||||||
write(user_error, M:A/N),
|
write(user_error, Mod:PredName/PredArity),
|
||||||
write(user_error, ' is already declared as sequential ]'),
|
write(user_error, ' is already declared as parallel ]'),
|
||||||
nl(user_error)
|
nl(user_error)
|
||||||
;
|
;
|
||||||
X is F /\ 0x1991FC80, X =:= 0, !, '$sequential'(T)
|
NewFlags is Flags /\ 0xffffffdf,
|
||||||
|
'$flags'(PredFunctor,Mod,Flags,NewFlags)
|
||||||
|
),
|
||||||
;
|
;
|
||||||
write(user_error, '[ Error: '),
|
write(user_error, '[ Error: '),
|
||||||
write(user_error, M:A/N),
|
write(user_error, Mod:PredName/PredArity),
|
||||||
write(user_error, ' cannot be declared as parallel ]'),
|
write(user_error, ' cannot be declared as parallel ]'),
|
||||||
nl(user_error),
|
nl(user_error),
|
||||||
fail
|
fail
|
||||||
).
|
).
|
||||||
'$parallel_directive'(X,_) :- write(user_error, '[ Error: '),
|
'$parallel_directive'(Pred,Mod) :-
|
||||||
write(user_error, X),
|
'$do_error'(type_error(callable,Mod:Pred),parallel(Mod:Pred)).
|
||||||
write(user_error, ' is an invalid argument to parallel/1 ]'),
|
|
||||||
nl(user_error),
|
|
||||||
fail.
|
|
||||||
|
|
||||||
|
|
||||||
%
|
|
||||||
% do not try to run consult in the parallel system.
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
%
|
%% $parallelizable/1 %%
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
'$parallelizable'(_) :-
|
'$parallelizable'(_) :-
|
||||||
nb_getval('$consulting_file',S), S\=[], !, fail.
|
nb_getval('$consulting_file',S), S\=[], !, fail.
|
||||||
'$parallelizable'((G1,G2)) :- !,
|
'$parallelizable'((G1,G2)) :- !,
|
||||||
@ -125,5 +225,4 @@ default_sequential(_).
|
|||||||
'$parallelizable'(use_module(_)) :- !, fail.
|
'$parallelizable'(use_module(_)) :- !, fail.
|
||||||
'$parallelizable'(_).
|
'$parallelizable'(_).
|
||||||
|
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
Reference in New Issue
Block a user