icompile table+orp

This commit is contained in:
Vítor Manuel de Morais Santos Costa 2010-01-14 17:38:39 +00:00
parent 5ef31fbfd2
commit a498dc1265
9 changed files with 47 additions and 23 deletions

View File

@ -3073,7 +3073,11 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
*entry_codep = code_p;
if (tabled) {
#if TABLING
#ifdef YAPOR
code_p = a_try(_table_try_single, (CELL)NEXTOP(code_p,Otapl), IPredArity, 1, 0, code_p, pass_no, cip);
#else
code_p = a_try(_table_try_single, (CELL)NEXTOP(code_p,Otapl), IPredArity, code_p, pass_no, cip);
#endif
#endif
}
if (dynamic) {

View File

@ -980,10 +980,13 @@ has_cut(yamop *pc)
#ifdef TABLING
case _table_load_answer:
case _table_try_answer:
case _table_try_me_single:
case _table_try_single:
case _table_try_me:
case _table_retry_me:
case _table_trust_me:
case _table_try:
case _table_retry:
case _table_trust:
case _table_answer_resolution:
case _table_completion:
#endif /* TABLING */

View File

@ -82,7 +82,7 @@ static Int p_tabling_statistics(void);
#endif /* TABLING */
#if defined(YAPOR) && defined(TABLING)
static int p_opt_statistics(void);
static Int p_opt_statistics(void);
#endif /* YAPOR && TABLING */
#if defined(YAPOR_ERRORS) || defined(TABLING_ERRORS)
@ -872,7 +872,7 @@ Int p_tabling_statistics(void) {
#if defined(YAPOR) && defined(TABLING)
static
int p_opt_statistics(void) {
Int p_opt_statistics(void) {
#ifdef SHM_MEMORY_ALLOC_SCHEME
long pages_in_use = 0, bytes_in_use = 0;

View File

@ -300,7 +300,7 @@ struct local_signals{
sharing = 1,
nodes_shared = 2,
copy_done = 3,
ready = 4
worker_ready = 4
} reply;
};
#endif /* YAPOR */
@ -342,7 +342,11 @@ struct local_data{
choiceptr bottom_pruning_scope;
#endif /* TABLING_INNER_CUTS */
#ifdef YAPOR
#ifdef THREADS
Int top_choice_point_on_stack_offset;
#else
choiceptr top_choice_point_on_stack;
#endif
struct or_frame *top_or_frame_with_suspensions;
#endif /* YAPOR */
#endif /* TABLING */

View File

@ -256,7 +256,7 @@ void prune_shared_branch(choiceptr prune_cp) {
end_prune_more:
CUT_reset_prune_request();
#ifdef TABLING
Set_LOCAL_top_cp_on_stack(LOCAL_top_cp);
Set_LOCAL_top_cp_on_stack(Get_LOCAL_top_cp());
#endif /* TABLING */
return;

View File

@ -365,7 +365,7 @@ void share_private_nodes(int worker_q) {
next_node_on_branch = sharing_node;
STACK_PUSH_UP(or_frame, stack);
STACK_CHECK_EXPAND1(stack, stack_limit, stack_base);
STACK_PUSH(sharing_node, stack);
STACK_PUSH_UP(sharing_node, stack); /* vsc: STACK_PUSH -> STACK_PUSH_UP? */
STACK_CHECK_EXPAND1(stack, stack_limit, stack_base);
sharing_node = consumer_cp;
dep_frame = DepFr_next(dep_frame);
@ -527,7 +527,7 @@ void share_private_nodes(int worker_q) {
/* update top shared nodes */
#ifdef TABLING
Set_REMOTE_top_cp_on_stack(worker_q,B);
Set_LOCAL_top_cp_on_stack, B);
Set_LOCAL_top_cp_on_stack( B );
#endif /* TABLING */
Set_REMOTE_top_cp(worker_q,B);
Set_LOCAL_top_cp(B);
@ -536,7 +536,7 @@ void share_private_nodes(int worker_q) {
#ifdef TABLING_INNER_CUTS
/* update worker Q pruning scope */
if (LOCAL_pruning_scope && EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp(), LOCAL_pruning_scope)) {
if (LOCAL_pruning_scope && EQUAL_OR_YOUNGER_CP(Get_LOCAL_top_cp(), LOCAL_pruning_scope)) {
REMOTE_pruning_scope(worker_q) = LOCAL_pruning_scope;
PUT_IN_PRUNING(worker_q);
} else {

View File

@ -303,9 +303,14 @@
#ifdef YAPOR
if (SCH_top_shared_cp(B)) {
#if 0
PROBLEM: cp_last_answer field is local to the cp!
-> we need a shared data structure to avoid redundant computations!
UNLOCK_OR_FRAME(LOCAL_top_or_fr);
#else
fprintf(stderr,"PROBLEM: cp_last_answer field is local to the cp!\n");
exit(1);
#endif
}
#endif /* YAPOR */
subs_ptr = (CELL *) (LOAD_CP(B) + 1);
@ -918,7 +923,7 @@
for (i = 0; i < number_workers; i++) {
if (BITMAP_member(members, i) &&
BRANCH_LTT(i, depth) > ltt &&
EQUAL_OR_YOUNGER_CP(OrFr_node(leftmost_or_fr), REMOTE_pruning_scope(i)))
EQUAL_OR_YOUNGER_CP(GetOrFr_node(leftmost_or_fr), REMOTE_pruning_scope(i)))
goto pending_table_new_answer;
}
BITMAP_minus(prune_members, members);
@ -933,7 +938,7 @@
for (i = 0; i < number_workers; i++) {
if (BITMAP_member(members, i) &&
BRANCH_LTT(i, depth) > ltt &&
EQUAL_OR_YOUNGER_CP(OrFr_node(leftmost_or_fr), REMOTE_pruning_scope(i))) {
EQUAL_OR_YOUNGER_CP(GetOrFr_node(leftmost_or_fr), REMOTE_pruning_scope(i))) {
/* update nearest leftnode data */
or_fr = LOCAL_top_or_fr;
nearest_or_fr = OrFr_nearest_leftnode(or_fr);
@ -1153,9 +1158,9 @@
end_or_fr = DepFr_top_or_fr(dep_fr);
if (start_or_fr != end_or_fr) {
LOCAL_top_or_fr = end_or_fr;
Set_LOCAL_top_cp(OrFr_node(end_or_fr));
Set_LOCAL_top_cp(GetOrFr_node(end_or_fr));
do {
while (YOUNGER_CP(OrFr_node(start_or_fr), OrFr_node(end_or_fr))) {
while (YOUNGER_CP(GetOrFr_node(start_or_fr), GetOrFr_node(end_or_fr))) {
LOCK_OR_FRAME(start_or_fr);
BITMAP_delete(OrFr_members(start_or_fr), worker_id);
if (BITMAP_empty(OrFr_members(start_or_fr))) {
@ -1187,7 +1192,7 @@
#endif /* TABLING_INNER_CUTS */
start_or_fr = OrFr_next(start_or_fr);
}
while (YOUNGER_CP(OrFr_node(end_or_fr), OrFr_node(start_or_fr))) {
while (YOUNGER_CP(GetOrFr_node(end_or_fr), GetOrFr_node(start_or_fr))) {
LOCK_OR_FRAME(end_or_fr);
BITMAP_insert(OrFr_members(end_or_fr), worker_id);
BRANCH(worker_id, OrFr_depth(end_or_fr)) = 1;
@ -1247,7 +1252,7 @@
start_or_fr = LOCAL_top_or_fr;
if (start_or_fr != end_or_fr) {
LOCAL_top_or_fr = end_or_fr;
Set_LOCAL_top_cp(OrFr_node(end_or_fr));
Set_LOCAL_top_cp(GetOrFr_node(end_or_fr));
while (start_or_fr != end_or_fr) {
LOCK_OR_FRAME(start_or_fr);
BITMAP_delete(OrFr_members(start_or_fr), worker_id);
@ -1447,7 +1452,7 @@
or_frame = OrFr_next(or_frame);
}
LOCAL_top_or_fr = DepFr_top_or_fr(dep_fr);
Set_LOCAL_top_cp(OrFr_node(LOCAL_top_or_fr));
Set_LOCAL_top_cp(GetOrFr_node(LOCAL_top_or_fr));
}
#endif /* YAPOR */
#ifdef OPTYAP_ERRORS
@ -1508,7 +1513,7 @@
if (YOUNGER_CP(B_FZ, B)) {
suspend_branch();
/* check for suspension frames to be resumed */
while (YOUNGER_CP(OrFr_node(LOCAL_top_susp_or_fr), Get_LOCAL_top_cp())) {
while (YOUNGER_CP(GetOrFr_node(LOCAL_top_susp_or_fr), Get_LOCAL_top_cp())) {
or_fr_ptr susp_or_fr;
susp_fr_ptr resume_fr;
susp_or_fr = LOCAL_top_susp_or_fr;
@ -1524,7 +1529,7 @@
OrFr_nearest_suspnode(susp_or_fr) = susp_or_fr;
}
UNLOCK_OR_FRAME(susp_or_fr);
rebind_variables(OrFr_node(susp_or_fr)->cp_tr, B->cp_tr);
rebind_variables(GetOrFr_node(susp_or_fr)->cp_tr, B->cp_tr);
resume_suspension_frame(resume_fr, susp_or_fr);
B = Get_LOCAL_top_cp();
SET_BB(B_FZ);
@ -1542,7 +1547,7 @@
if (frame_with_suspensions_not_collected(LOCAL_top_or_fr))
collect_suspension_frames(LOCAL_top_or_fr);
/* check for suspension frames to be resumed */
while (EQUAL_OR_YOUNGER_CP(OrFr_node(LOCAL_top_susp_or_fr), Get_LOCAL_top_cp())) {
while (EQUAL_OR_YOUNGER_CP(GetOrFr_node(LOCAL_top_susp_or_fr), Get_LOCAL_top_cp())) {
or_fr_ptr susp_or_fr;
susp_fr_ptr resume_fr;
susp_or_fr = LOCAL_top_susp_or_fr;
@ -1559,7 +1564,7 @@
if (YOUNGER_CP(B_FZ, B)) {
suspend_branch();
}
rebind_variables(OrFr_node(susp_or_fr)->cp_tr, B->cp_tr);
rebind_variables(GetOrFr_node(susp_or_fr)->cp_tr, B->cp_tr);
resume_suspension_frame(resume_fr, susp_or_fr);
B = Get_LOCAL_top_cp();
SET_BB(B_FZ);
@ -1605,7 +1610,7 @@
UNLOCK(DepFr_lock(LOCAL_top_dep_fr));
if (OrFr_owners(LOCAL_top_or_fr) > 1) {
/* more owners -> move up one node */
Set_LOCAL_top_cp_on_stack( OrFr_node(OrFr_next_on_stack(LOCAL_top_or_fr)) );
Set_LOCAL_top_cp_on_stack( GetOrFr_node(OrFr_next_on_stack(LOCAL_top_or_fr)) );
BITMAP_delete(OrFr_members(LOCAL_top_or_fr), worker_id);
OrFr_owners(LOCAL_top_or_fr)--;
LOCAL_top_dep_fr = DepFr_next(LOCAL_top_dep_fr);

View File

@ -14,6 +14,9 @@
** ------------------ */
#include <stdlib.h>
#if HAVE_STRING_H
#include <string.h>
#endif
#include "opt.mavar.h"
@ -104,7 +107,12 @@ STD_PROTO(static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames, (tg_sol_fr_p
#ifdef YAPOR
#define STACK_CHECK_EXPAND(STACK, STACK_LIMIT, STACK_BASE) \
if (STACK_LIMIT >= STACK) { \
Yap_Error(INTERNAL_ERROR, TermNil, "stack full (STACK_CHECK_EXPAND)")
Yap_Error(INTERNAL_ERROR, TermNil, "stack full (STACK_CHECK_EXPAND)"); \
}
/* should work for now */
#define STACK_CHECK_EXPAND1(STACK, STACK_LIMIT, STACK_BASE) STACK_CHECK_EXPAND(STACK, STACK_LIMIT, STACK_BASE)
#else
#define STACK_CHECK_EXPAND(STACK, STACK_LIMIT, STACK_BASE) \
if (STACK_LIMIT >= STACK) { \

View File

@ -341,9 +341,9 @@ void resume_suspension_frame(susp_fr_ptr resume_fr, or_fr_ptr top_or_fr) {
SetOrFr_node(top_or_fr, Get_LOCAL_top_cp());
LOCAL_top_sg_fr = SuspFr_top_sg_fr(resume_fr);
LOCAL_top_dep_fr = SuspFr_top_dep_fr(resume_fr);
Set_LOCAL_top_cp_on_stack( OrFr_node(SuspFr_top_or_fr_on_stack(resume_fr)) );
Set_LOCAL_top_cp_on_stack( GetOrFr_node(SuspFr_top_or_fr_on_stack(resume_fr)) );
sg_frame = LOCAL_top_sg_fr;
while (sg_frame && YOUNGER_CP(SgFr_gen_cp(sg_frame), LOCAL_top_cp_on_stack)) {
while (sg_frame && YOUNGER_CP(SgFr_gen_cp(sg_frame), Get_LOCAL_top_cp_on_stack())) {
SgFr_gen_worker(sg_frame) = worker_id;
sg_frame = SgFr_next(sg_frame);
}