diff --git a/OPTYap/opt.init.c b/OPTYap/opt.init.c index 7648877d5..6dfbae84f 100644 --- a/OPTYap/opt.init.c +++ b/OPTYap/opt.init.c @@ -213,7 +213,7 @@ void make_root_frames(void) { SetOrFr_node(or_fr, B_BASE); OrFr_nearest_livenode(or_fr) = NULL; OrFr_depth(or_fr) = 0; - OrFr_pend_prune_cp(or_fr) = NULL; + Set_OrFr_pend_prune_cp(or_fr, NULL); OrFr_nearest_leftnode(or_fr) = or_fr; OrFr_qg_solutions(or_fr) = NULL; #ifdef TABLING_INNER_CUTS diff --git a/OPTYap/or.cut.c b/OPTYap/or.cut.c index df974eb99..6ca6a2988 100644 --- a/OPTYap/or.cut.c +++ b/OPTYap/or.cut.c @@ -154,7 +154,7 @@ void prune_shared_branch(choiceptr prune_cp) { while (Get_LOCAL_top_cp() != leftmost_cp) { ltt = BRANCH_LTT(worker_id, OrFr_depth(LOCAL_top_or_fr)); LOCK_OR_FRAME(LOCAL_top_or_fr); - if (OrFr_pend_prune_cp(LOCAL_top_or_fr)) + if (Get_OrFr_pend_prune_cp(LOCAL_top_or_fr)) prune_more = 0; aux_qg_solutions = OrFr_qg_solutions(LOCAL_top_or_fr); #ifdef TABLING_INNER_CUTS @@ -214,10 +214,10 @@ void prune_shared_branch(choiceptr prune_cp) { if (tg_solutions) tg_solutions = CUT_store_tg_answers(leftmost_or_fr, tg_solutions, ltt); #endif /* TABLING_INNER_CUTS */ - if (OrFr_pend_prune_cp(leftmost_or_fr)) + if (Get_OrFr_pend_prune_cp(leftmost_or_fr)) prune_more = 0; OrFr_alternative(leftmost_or_fr) = NULL; - OrFr_pend_prune_cp(leftmost_or_fr) = prune_cp; + Set_OrFr_pend_prune_cp(leftmost_or_fr, prune_cp); OrFr_pend_prune_ltt(leftmost_or_fr) = ltt; UNLOCK_OR_FRAME(leftmost_or_fr); #ifdef TABLING_INNER_CUTS diff --git a/OPTYap/or.engine.c b/OPTYap/or.engine.c index 7dbd4373d..c33b6a11b 100644 --- a/OPTYap/or.engine.c +++ b/OPTYap/or.engine.c @@ -200,7 +200,7 @@ int q_share_work(int worker_p) { return FALSE; } #ifdef YAPOR_ERRORS - if (OrFr_pend_prune_cp(LOCAL_top_or_fr) && + if (Get_OrFr_pend_prune_cp(LOCAL_top_or_fr) && BRANCH_LTT(worker_p, OrFr_depth(LOCAL_top_or_fr)) < OrFr_pend_prune_ltt(LOCAL_top_or_fr)) YAPOR_ERROR_MESSAGE("prune ltt > worker_p branch ltt (q_share_work)"); #endif /* YAPOR_ERRORS */ diff --git a/OPTYap/or.scheduler.c b/OPTYap/or.scheduler.c index 0132adedd..f34bc4fd7 100644 --- a/OPTYap/or.scheduler.c +++ b/OPTYap/or.scheduler.c @@ -285,14 +285,14 @@ int move_up_one_node(or_fr_ptr nearest_livenode) { /* pending prune ? */ - if (OrFr_pend_prune_cp(LOCAL_top_or_fr) + if (Get_OrFr_pend_prune_cp(LOCAL_top_or_fr) && ! Get_LOCAL_prune_request() && CUT_last_worker_left_pending_prune(LOCAL_top_or_fr)) { #ifdef TABLING choiceptr aux_cp = Get_LOCAL_top_cp(); #endif /* TABLIG */ - choiceptr prune_cp = OrFr_pend_prune_cp(LOCAL_top_or_fr); - OrFr_pend_prune_cp(LOCAL_top_or_fr) = NULL; + choiceptr prune_cp = Get_OrFr_pend_prune_cp(LOCAL_top_or_fr); + Set_OrFr_pend_prune_cp(LOCAL_top_or_fr, NULL); BRANCH(worker_id, OrFr_depth(LOCAL_top_or_fr)) = OrFr_pend_prune_ltt(LOCAL_top_or_fr); UNLOCK_OR_FRAME(LOCAL_top_or_fr); prune_shared_branch(prune_cp); diff --git a/OPTYap/or.structs.h b/OPTYap/or.structs.h index d085dc4be..906221e8c 100644 --- a/OPTYap/or.structs.h +++ b/OPTYap/or.structs.h @@ -39,7 +39,11 @@ typedef struct or_frame { struct or_frame *nearest_livenode; /* cut support */ int depth; +#ifdef THREADS + Int pending_prune_cp_offset; +#else choiceptr pending_prune_cp; +#endif volatile int pending_prune_ltt; struct or_frame *nearest_leftnode; struct query_goal_solution_frame *query_solutions; @@ -69,7 +73,14 @@ typedef struct or_frame { #endif #define OrFr_nearest_livenode(X) ((X)->nearest_livenode) #define OrFr_depth(X) ((X)->depth) +#ifdef THREADS +#define Get_OrFr_pend_prune_cp(X) offset_to_cptr_with_null((X)->pending_prune_cp_offset) +#define Set_OrFr_pend_prune_cp(X,V) ((X)->pending_prune_cp_offset = cptr_to_offset_with_null(V)) +#else #define OrFr_pend_prune_cp(X) ((X)->pending_prune_cp) +#define Get_OrFr_pend_prune_cp(X) ((X)->pending_prune_cp) +#define Set_OrFr_pend_prune_cp(X,V) ((X)->pending_prune_cp = (V)) +#endif #define OrFr_pend_prune_ltt(X) ((X)->pending_prune_ltt) #define OrFr_nearest_leftnode(X) ((X)->nearest_leftnode) #define OrFr_qg_solutions(X) ((X)->query_solutions) diff --git a/OPTYap/or.threadengine.c b/OPTYap/or.threadengine.c index d8ed025aa..6fc523b2e 100644 --- a/OPTYap/or.threadengine.c +++ b/OPTYap/or.threadengine.c @@ -36,6 +36,16 @@ REMOTE_end_local_copy(Q) = (CELL) (REMOTE_top_cp(Q)); \ REMOTE_start_trail_copy(Q) = (CELL) (REMOTE_top_cp(Q)->cp_tr); \ REMOTE_end_trail_copy(Q) = (CELL) (TR) +#undef COMPUTE_SEGMENTS_TO_COPY_TO +#define COMPUTE_SEGMENTS_TO_COPY_TO(Q) \ + REMOTE_start_global_copy(Q) = (CELL) (H0); \ + REMOTE_end_global_copy(Q) = (CELL) (B->cp_h); \ + REMOTE_start_local_copy(Q) = (CELL) (B); \ + REMOTE_end_local_copy(Q) = (CELL) (REMOTE_top_cp(Q)); \ + REMOTE_end_local_copy(Q) = (CELL) (GetOrFr_node(GLOBAL_root_or_fr)); \ + REMOTE_start_trail_copy(Q) = (CELL) (Yap_TrailBase); \ + REMOTE_start_trail_copy(Q) = (CELL) (REMOTE_top_cp(Q)->cp_tr); \ + REMOTE_end_trail_copy(Q) = (CELL) (TR) /* ------------------------------------- ** ** Local functions declaration ** @@ -145,7 +155,7 @@ int q_share_work(int worker_p) { return FALSE; } #ifdef YAPOR_ERRORS - if (OrFr_pend_prune_cp(LOCAL_top_or_fr) && + if (Get_OrFr_pend_prune_cp(LOCAL_top_or_fr) && BRANCH_LTT(worker_p, OrFr_depth(LOCAL_top_or_fr)) < OrFr_pend_prune_ltt(LOCAL_top_or_fr)) YAPOR_ERROR_MESSAGE("prune ltt > worker_p branch ltt (q_share_work)"); #endif /* YAPOR_ERRORS */ @@ -354,7 +364,7 @@ void share_private_nodes(int worker_q) { INIT_LOCK(OrFr_lock(or_frame)); SetOrFr_node(or_frame, sharing_node); OrFr_alternative(or_frame) = sharing_node->cp_ap; - OrFr_pend_prune_cp(or_frame) = NULL; + Set_OrFr_pend_prune_cp(or_frame, NULL); OrFr_nearest_leftnode(or_frame) = LOCAL_top_or_fr; OrFr_qg_solutions(or_frame) = NULL; #ifdef TABLING_INNER_CUTS