Пример #1
0
int
main (void)
{
    matrix_t            r = read_matrix ();
    matrix_t            mayw;
    matrix_t            mustw;
    dm_copy(&r, &mayw);
    dm_copy(&r, &mustw);
    printf ("matrix:\n");
    dm_print (stdout, &r);
    // nub
    dm_sort_rows (&r, &mayw, &mustw, &max_row_first);
    dm_nub_rows (&r, &mayw, &mustw, &eq_rows, NULL);
    // optimize
    dm_optimize (&r, &mayw, &mustw);
    // sort again
    dm_sort_rows (&r, &mayw, &mustw, &max_row_first);

    printf ("matrix:\n");
    dm_print (stdout, &r);
    printf ("state mapping:\n");
    state_mapping (&r);
    printf ("transition mapping:\n");
    transition_mapping (&r);
    printf ("dependencies:\n");
    dependencies (&r);

    return 0;
}
Пример #2
0
static void
init_model(char *file)
{
    Warning(info, "opening %s", file);
    model = GBcreateBase();
    GBsetChunkMap (model, HREgreyboxTableFactory());

    HREbarrier(HREglobal());
    GBloadFile(model, file, &model);

    HREbarrier(HREglobal());

    if (HREme(HREglobal())==0 && !PINS_USE_GUARDS && no_soundness_check) {
        Abort("Option --no-soundness-check is incompatible with --pins-guards=false");
    }

    if (HREme(HREglobal())==0 && log_active(infoLong) && !no_matrix) {
        fprintf(stderr, "Dependency Matrix:\n");
        GBprintDependencyMatrixCombined(stderr, model);
    }

    ltstype = GBgetLTStype(model);
    N = lts_type_get_state_length(ltstype);
    eLbls = lts_type_get_edge_label_count(ltstype);
    sLbls = GBgetStateLabelInfo(model) == NULL ? 0 : dm_nrows(GBgetStateLabelInfo(model));
    nGrps = dm_nrows(GBgetDMInfo(model));
    max_sat_levels = (N / sat_granularity) + 1;
    if (PINS_USE_GUARDS) {
        nGuards = GBgetStateLabelGroupInfo(model, GB_SL_GUARDS)->count;
        if (HREme(HREglobal())==0) {
            Warning(info, "state vector length is %d; there are %d groups and %d guards", N, nGrps, nGuards);
        }
    } else {
        if (HREme(HREglobal())==0) {
            Warning(info, "state vector length is %d; there are %d groups", N, nGrps);
        }
    }

    int id=GBgetMatrixID(model,"inhibit");
    if (id>=0){
        inhibit_matrix=GBgetMatrix(model,id);
        if (HREme(HREglobal())==0) {
            Warning(infoLong,"inhibit matrix is:");
            if (log_active(infoLong)) dm_print(stderr,inhibit_matrix);
        }
    }
    id = GBgetMatrixID(model,LTSMIN_EDGE_TYPE_ACTION_CLASS);
    if (id>=0){
        class_matrix=GBgetMatrix(model,id);
        if (HREme(HREglobal())==0) {
            Warning(infoLong,"inhibit class matrix is:");
            if (log_active(infoLong)) dm_print(stderr,class_matrix);
        }
    }

    HREbarrier(HREglobal());
}
Пример #3
0
void
print_matrix (matrix_t *m)
{
    printf ("matrix(%d, %d)\n", dm_nrows (m), dm_ncols (m));
    dm_print (stdout, m);
    printf ("\n");
}
Пример #4
0
permute_t *
permute_create (permutation_perm_t permutation, model_t model, alg_state_seen_f ssf,
                int worker_index, void *run_ctx)
{
    permute_t          *perm = RTalign (CACHE_LINE_SIZE, sizeof(permute_t));
    perm->todos = RTalign (CACHE_LINE_SIZE, sizeof(permute_todo_t[K+TODO_MAX]));
    perm->tosort = RTalign (CACHE_LINE_SIZE, sizeof(int[K+TODO_MAX]));
    perm->shift = ((double)K)/W;
    perm->shiftorder = (1UL<<dbs_size) / W * worker_index;
    perm->start_group = perm->shift * worker_index;
    perm->model = model;
    perm->state_seen = ssf;
    perm->por_proviso = 1;
    perm->permutation = permutation;
    perm->run_ctx = run_ctx;
    perm->next = state_info_create ();
    if (Perm_Otf == perm->permutation)
        perm->pad = RTalign (CACHE_LINE_SIZE, sizeof(int[K+TODO_MAX]));
    if (Perm_Random == perm->permutation) {
        perm->rand = RTalignZero (CACHE_LINE_SIZE, sizeof(int*[K+TODO_MAX]));
        for (size_t i = 1; i < K+TODO_MAX; i++) {
            perm->rand[i] = RTalign (CACHE_LINE_SIZE, sizeof(int[ i ]));
            randperm (perm->rand[i], i, perm->shiftorder);
        }
    }
    if (Perm_RR == perm->permutation) {
        perm->rand = RTalignZero (CACHE_LINE_SIZE, sizeof(int*));
        perm->rand[0] = RTalign (CACHE_LINE_SIZE, sizeof(int[1<<RR_ARRAY_SIZE]));
        srandom (time(NULL) + 9876432*worker_index);
        for (int i =0; i < (1<<RR_ARRAY_SIZE); i++)
            perm->rand[0][i] = random();
    }
    if (Perm_SR == perm->permutation || Perm_Dynamic == perm->permutation) {
        perm->rand = RTalignZero (CACHE_LINE_SIZE, sizeof(int*));
        perm->rand[0] = RTalign (CACHE_LINE_SIZE, sizeof(int[K+TODO_MAX]));
        randperm (perm->rand[0], K+TODO_MAX, (time(NULL) + 9876*worker_index));
    }
    perm->labels = lts_type_get_edge_label_count (GBgetLTStype(model));
    for (size_t i = 0; i < K+TODO_MAX; i++) {
        if (act_detect || files[1] || (PINS_BUCHI_TYPE == PINS_BUCHI_TYPE_TGBA)) {
            perm->todos[i].ti.labels = RTmalloc (sizeof(int*[perm->labels]));
        } else {
            perm->todos[i].ti.labels = NULL;
        }
    }

    perm->class_label = lts_type_find_edge_label (GBgetLTStype(model),LTSMIN_EDGE_TYPE_ACTION_CLASS);
    if (inhibit){
        int id=GBgetMatrixID(model,"inhibit");
        if (id>=0){
            perm->inhibit_matrix = GBgetMatrix (model, id);
            Warning(infoLong,"inhibit matrix is:");
            if (log_active(infoLong)) dm_print (stderr, perm->inhibit_matrix);
            perm->inhibited_by = (ci_list **)dm_cols_to_idx_table (perm->inhibit_matrix);
        } else {
            Warning(infoLong,"no inhibit matrix");
        }
        id = GBgetMatrixID(model,LTSMIN_EDGE_TYPE_ACTION_CLASS);
        if (id>=0){
            perm->class_matrix=GBgetMatrix(model,id);
            Warning(infoLong,"inhibit class matrix is:");
            if (log_active(infoLong)) dm_print(stderr,perm->class_matrix);
        } else {
            Warning(infoLong,"no inhibit class matrix");
        }
        if (perm->class_label>=0) {
            Warning(infoLong,"inhibit class label is %d",perm->class_label);
        } else {
            Warning(infoLong,"no inhibit class label");
        }
    }

    if (PINS_POR) por_set_find_state (state_find, perm);

    return perm;
}