Exemple #1
0
/* Set flags of switches appearing in the e-graphs and allocate an array
 * of pointers to such switches (This routine is based on compute_inside()).
 */
void alloc_occ_switches(void) {
	int i,j,k;
	EG_NODE_PTR eg_ptr;
	EG_PATH_PTR path_ptr;
	SW_INS_PTR sw_ins_ptr;
	int *occ_sw_flags;
	int b;

	/* Initialize the `occ' counters in switch instances */
	for (i = 0; i < sw_ins_tab_size; i++) {
		switch_instances[i]->occ = 0;
	}

	for (i = 0; i < sorted_egraph_size; i++) {
		eg_ptr = sorted_expl_graph[i];
		path_ptr = eg_ptr->path_ptr;
		while (path_ptr != NULL) {
			for (k = 0; k < path_ptr->sws_len; k++) {
				path_ptr->sws[k]->occ = 1;
			}
			path_ptr = path_ptr->next;
		}
	}

	/* Temporarily make an array of flags each of which indicates whether
	   a switch (not switch instance) occurs in the e-graphs */
	occ_sw_flags = (int *)MALLOC(sizeof(int) * sw_tab_size);
	occ_switch_tab_size = 0;
	for (i = 0; i < sw_tab_size; i++) {
		sw_ins_ptr = switches[i];
		b = 0;
		while (sw_ins_ptr != NULL) {
			b |= sw_ins_ptr->occ;
			sw_ins_ptr = sw_ins_ptr->next;
		}
		occ_sw_flags[i] = b;
		if (b) occ_switch_tab_size++;
	}

	occ_switches = (SW_INS_PTR *)MALLOC(sizeof(SW_INS_PTR) * occ_switch_tab_size);

	j = 0;
	for (i = 0; i < sw_tab_size; i++) {
		if (occ_sw_flags[i]) {
			occ_switches[j] = switches[i];  /* Copy */
			j++;
		}
	}

	free(occ_sw_flags);

	if (fix_init_order) {
		sort_occ_switches();
	}
}
Exemple #2
0
int pc_mpm_alloc_occ_switches_0(void)
{
    occ_switches = MALLOC(sizeof(SW_INS_PTR) * sw_tab_size);

    occ_switch_tab_size = sw_tab_size;
    memmove(occ_switches, switches, sizeof(SW_INS_PTR) * sw_tab_size);
    if (fix_init_order) {
        sort_occ_switches();
    }
    alloc_num_sw_vals();

    return BP_TRUE;
}
Exemple #3
0
int pc_prism_prepare_4(void)
{
    TERM  p_fact_list;
    int   size;

    p_fact_list        = bpx_get_call_arg(1,4);
    size               = bpx_get_integer(bpx_get_call_arg(2,4));
    num_goals          = bpx_get_integer(bpx_get_call_arg(3,4));
    failure_root_index = bpx_get_integer(bpx_get_call_arg(4,4));

    failure_observed = (failure_root_index != -1);

    if (failure_root_index != -1) {
        failure_subgoal_id = prism_goal_id_get(failure_atom);
        if (failure_subgoal_id == -1) {
            emit_internal_error("no subgoal ID allocated to `failure'");
            RET_INTERNAL_ERR;
        }
    }

    initialize_egraph_index();
    alloc_sorted_egraph(size);
    RET_ON_ERR(sort_egraphs(p_fact_list));
#ifndef MPI
    if (verb_graph) {
        print_egraph(0, PRINT_NEUTRAL);
    }
#endif /* !(MPI) */

    alloc_occ_switches();
    if (fix_init_order) {
        sort_occ_switches();
    }
    alloc_num_sw_vals();

    return BP_TRUE;
}