vdom_t vdom_create_sylvan_from_file(FILE *f) { Warning(info,"Creating a Sylvan domain."); // Call initializator of library (if needed) ltsmin_sylvan_init(); size_t vector_size, bits_per_integer; fread(&vector_size, sizeof(size_t), 1, f); fread(&bits_per_integer, sizeof(size_t), 1, f); // Create data structure of domain vdom_t dom = (vdom_t)RTmalloc(sizeof(struct vector_domain)); vdom_init_shared(dom, vector_size); dom_set_function_pointers(dom); fddbits = dom->bits_per_integer = bits_per_integer; dom->vec_to_bddvar = (BDDVAR*)RTmalloc(sizeof(BDDVAR) * bits_per_integer * vector_size); dom->prime_vec_to_bddvar = (BDDVAR*)RTmalloc(sizeof(BDDVAR) * bits_per_integer * vector_size); fread(dom->vec_to_bddvar, sizeof(BDDVAR), vector_size * bits_per_integer, f); fread(dom->prime_vec_to_bddvar, sizeof(BDDVAR), vector_size * bits_per_integer, f); return dom; }
static void rel_load(FILE* f, vrel_t rel) { if (rel->bdd) sylvan_deref(rel->bdd); if (rel->vec_to_bddvar) RTfree(rel->vec_to_bddvar); if (rel->prime_vec_to_bddvar) RTfree(rel->prime_vec_to_bddvar); if (rel->variables) sylvan_deref(rel->variables); if (rel->prime_variables) sylvan_deref(rel->prime_variables); if (rel->all_variables) sylvan_deref(rel->all_variables); sylvan_serialize_fromfile(f); size_t bdd; fread(&bdd, sizeof(size_t), 1, f); rel->bdd = sylvan_ref(sylvan_serialize_get_reversed(bdd)); fread(&rel->vector_size, sizeof(size_t), 1, f); rel->vec_to_bddvar = (BDDVAR*)RTmalloc(sizeof(BDDVAR) * fddbits * rel->vector_size); rel->prime_vec_to_bddvar = (BDDVAR*)RTmalloc(sizeof(BDDVAR) * fddbits * rel->vector_size); fread(rel->vec_to_bddvar, sizeof(BDDVAR), rel->vector_size*fddbits, f); fread(rel->prime_vec_to_bddvar, sizeof(BDDVAR), rel->vector_size*fddbits, f); sylvan_gc_disable(); LACE_ME; rel->variables = sylvan_ref(sylvan_set_fromarray(rel->vec_to_bddvar, fddbits * rel->vector_size)); rel->prime_variables = sylvan_ref(sylvan_set_fromarray(rel->prime_vec_to_bddvar, fddbits * rel->vector_size)); rel->all_variables = sylvan_ref(sylvan_set_addall(rel->prime_variables, rel->variables)); sylvan_gc_enable(); }
/** * Create a domain with object size n */ vdom_t vdom_create_sylvan(int n) { Warning(info,"Creating a Sylvan domain."); // Call initializator of library (if needed) ltsmin_sylvan_init(); // Create data structure of domain vdom_t dom = (vdom_t)RTmalloc(sizeof(struct vector_domain)); vdom_init_shared(dom,n); dom_set_function_pointers(dom); dom->bits_per_integer = fddbits; // Create universe dom->vec_to_bddvar = (BDDVAR*)RTmalloc(sizeof(BDDVAR) * fddbits * n); dom->prime_vec_to_bddvar = (BDDVAR*)RTmalloc(sizeof(BDDVAR) * fddbits * n); for (int i=0; i<n; i++) { for (int j=0; j<fddbits; j++) { dom->vec_to_bddvar[i*fddbits+j] = 2*(i*fddbits+j); dom->prime_vec_to_bddvar[i*fddbits+j] = 2*(i*fddbits+j)+1; } } return dom; }
/** * This means: create a new BDD set in the domain dom * dom = my domain (just copy) * k is the number of integers in proj * proj is a list of indices of the state vector in the projection */ static vset_t set_create(vdom_t dom, int k, int* proj) { vset_t set = (vset_t)RTmalloc(sizeof(struct vector_set)); LACE_ME; set->dom = dom; set->bdd = sylvan_false; // Initialize with an empty BDD if (k>=0 && k<dom->shared.size) { // We are creating a projection set->vector_size = k; set->vec_to_bddvar = (BDDVAR*)RTmalloc(sizeof(BDDVAR) * fddbits * set->vector_size); for (int i=0; i<k; i++) { for (int j=0; j<fddbits; j++) { set->vec_to_bddvar[i*fddbits + j] = dom->vec_to_bddvar[proj[i]*fddbits + j]; } } } else { // Use all variables set->vector_size = dom->shared.size; set->vec_to_bddvar = (BDDVAR*)RTmalloc(sizeof(BDDVAR) * fddbits * set->vector_size); memcpy(set->vec_to_bddvar, dom->vec_to_bddvar, sizeof(BDDVAR) * fddbits * set->vector_size); } sylvan_gc_disable(); set->variables = sylvan_ref(sylvan_set_fromarray(set->vec_to_bddvar, fddbits * set->vector_size)); set->projection = sylvan_ref(sylvan_set_removeall(dom->universe, set->variables)); sylvan_gc_enable(); return set; }
/** * Create a "relation" (Dom x Dom) * 0 < k <= dom->shared.size * The integers in proj, a k-length array, are indices of the * state vector. */ static vrel_t rel_create(vdom_t dom, int k, int* proj) { LACE_ME; sylvan_gc_disable(); vrel_t rel = (vrel_t)RTmalloc(sizeof(struct vector_relation)); rel->dom = dom; rel->bdd = sylvan_false; // Initially, empty. // Relations are always projections. assert (k >= 0 && k<=dom->shared.size); rel->vector_size = k; rel->vec_to_bddvar = (BDDVAR*)RTmalloc(sizeof(BDDVAR) * fddbits * rel->vector_size); rel->prime_vec_to_bddvar = (BDDVAR*)RTmalloc(sizeof(BDDVAR) * fddbits * rel->vector_size); for (int i=0; i<k; i++) { for (int j=0; j<fddbits; j++) { rel->vec_to_bddvar[i*fddbits + j] = dom->vec_to_bddvar[proj[i]*fddbits + j]; rel->prime_vec_to_bddvar[i*fddbits + j] = dom->prime_vec_to_bddvar[proj[i]*fddbits + j]; } } sylvan_gc_disable(); rel->variables = sylvan_ref(sylvan_set_fromarray(rel->vec_to_bddvar, fddbits * rel->vector_size)); rel->prime_variables = sylvan_ref(sylvan_set_fromarray(rel->prime_vec_to_bddvar, fddbits * rel->vector_size)); rel->all_variables = sylvan_ref(sylvan_set_addall(rel->prime_variables, rel->variables)); sylvan_gc_enable(); return rel; }
static stream_t stream_zip(stream_t parent,int compress,int level,int bufsize){ stream_t s=(stream_t)RTmallocZero(sizeof(struct stream_s)); stream_init(s); s->bufsize=bufsize; s->s=parent; s->compress=compress; if(stream_writable(parent)){ s->procs.write=gzip_write; //s->procs.flush= TO DO s->wr.zalloc = Z_NULL; s->wr.zfree = Z_NULL; s->wr.opaque = Z_NULL; s->wr_buf=(char*)RTmalloc(bufsize); s->wr.next_in=Z_NULL; s->wr.avail_in=0; s->wr.next_out=s->wr_buf; s->wr.avail_out=bufsize; if (compress) { if (deflateInit(&s->wr, level)!= Z_OK) { Abort("gzip init failed"); } } else { if (inflateInit(&s->wr)!= Z_OK) { Abort("gzip init failed"); } } } else { s->wr_buf=NULL; } if(stream_readable(parent)){ s->procs.read_max=gzip_read_max; s->procs.read=gzip_read; //s->procs.empty= TO DO s->rd.zalloc = Z_NULL; s->rd.zfree = Z_NULL; s->rd.opaque = Z_NULL; s->rd.next_in=Z_NULL; s->rd.avail_in=0; s->rd.next_out=Z_NULL; s->rd.avail_out=0; s->rd_buf=(char*)RTmalloc(bufsize); if (compress) { if (inflateInit(&s->rd)!= Z_OK) { Abort("gzip init failed"); } } else { if (deflateInit(&s->rd, level)!= Z_OK) { Abort("gzip init failed"); } } } else { s->rd_buf=NULL; } s->procs.close=gzip_close; s->procs.close_z=gzip_close_z; return stream_buffer(s,4096); }
/* * Sanitizes and caches all the variable names of an lts_type_t. Should only be * called once. */ void sanitize_variables(lts_type_t ltstype) { int n_vars = lts_type_get_state_length(ltstype); sanitized_variables = (char**)RTmalloc(n_vars*sizeof(char*)); for (int i=0;i<n_vars;i++) { char *name = lts_type_get_state_name(ltstype,i); int len = strlen(name)+2; sanitized_variables[i] = (char*)RTmalloc(len); sanitize_ID(name,len,sanitized_variables[i]); Debug("Sanitizing variable %s to %s", name, sanitized_variables[i]); } }
isb_allocator_t isba_create(int element_size) { isb_allocator_t res = RTmalloc(sizeof *res); res->el_size = element_size; res->max_blocks = INIT_MAX_BLOCKS; res->blocks = RTmalloc(res->max_blocks*sizeof(int*)); res->num_block = 0; add_block(res); return res; }
/** * \brief Creates a new spgsolver_options object. */ spgsolver_options* spg_get_solver_options() { spgsolver_options* options = (spgsolver_options*)RTmalloc(sizeof(spgsolver_options)); switch (attr_strategy) { case CHAIN: options->attr = spg_attractor_chaining; Print(infoLong, "attractor: chaining"); break; #ifdef HAVE_SYLVAN case PAR: options->attr = spg_attractor_par; Print(infoLong, "attractor: par"); break; case PAR2: options->attr = spg_attractor_par2; Print(infoLong, "attractor: par2"); break; #endif default: options->attr = spg_attractor; Print(infoLong, "attractor: default"); break; } options->attr_options = (spg_attr_options*)RTmalloc(sizeof(spg_attr_options)); options->attr_options->dot = false; #ifdef LTSMIN_DEBUG options->attr_options->dot = (dot_flag > 0); options->attr_options->dot_count = 0; #endif options->attr_options->saturation = (saturating_attractor_flag > 0); options->attr_options->timer = RTcreateTimer(); options->strategy_filename = strategy_filename; options->attr_options->compute_strategy = (strategy_filename != NULL); if (options->attr_options->compute_strategy) { if (options->attr == spg_attractor_chaining) { Abort("Computing stategy not supported in chaining attractor. Use, e.g., '--attr=default'."); } Print(info, "Writing winning strategies to %s", strategy_filename); } options->check_strategy = (check_strategy_flag > 0); options->interactive_strategy_play = (interactive_strategy_play_flag > 0); if (player == 0 || player == 1) { options->player = player; } else { Abort("Invalid player: %d", player); } return options; }
static void fifo_write(stream_t fifo,void*buf,size_t count){ if (count <= (fifo->blocksize-fifo->write_idx)){ // write fits empty space in current block. memcpy(fifo->write_block+fifo->write_idx,buf,count); fifo->write_idx+=count; } else { // write to current block what we can. size_t len=fifo->blocksize-fifo->write_idx; memcpy(fifo->write_block+fifo->write_idx,buf,len); buf+=len; count-=len; len=fifo->blocksize-sizeof(void*); for(;;){ // extend the fifo with one more block. void*new_blk=RTmalloc(fifo->blocksize); *((void**)new_blk)=NULL; *((void**)fifo->write_block)=new_blk; fifo->write_block=new_blk; fifo->blocks++; if (count < len){ // The write fits the current buffer. memcpy(new_blk+sizeof(void*),buf,count); fifo->write_idx=sizeof(void*)+count; return; } else { // The write is more than the current buffer. memcpy(new_blk+sizeof(void*),buf,len); buf+=len; count-=len; } } } }
void trc_find_and_write (trc_env_t *env, char *trc_output, ref_t dst_idx, int level, ref_t *parent_ofs, ref_t start_idx) { rt_timer_t timer = RTcreateTimer (); RTstartTimer (timer); /* Other workers may have influenced the trace, writing to parent_ofs. * we artificially limit the length of the trace to 10 times that of the * found one */ size_t max_length = level * 10; ref_t *trace = RTmalloc(sizeof(ref_t) * max_length); if (trace == NULL) Abort("unable to allocate memory for trace"); int i = max_length - 1; ref_t curr_idx = dst_idx; trace[i] = curr_idx; while(curr_idx != start_idx) { i--; if (i < 0) Abort("Trace length 10x longer than initially found trace. Giving up."); curr_idx = parent_ofs[curr_idx]; trace[i] = curr_idx; } Warning (info, "reconstructed trace length: %zu", max_length - i); RTstopTimer (timer); RTprintTimer (info, timer, "constructing the trace took"); trc_write_trace (env, trc_output, &trace[i], max_length - i); RTfree (trace); }
ltsmin_expr_t ltsmin_expr_lookup(ltsmin_expr_t e, char *text, ltsmin_expr_list_t **le_list) { // lookup expression ltsmin_expr_list_t **pp_le_list = le_list; while(*pp_le_list != NULL) { if (e) { // compare on expression if ((*pp_le_list)->expr->hash == e->hash) { if (LTSminExprEq((*pp_le_list)->expr, e)) { return (*pp_le_list)->expr; } } } else { // compare on text if (strcmp((*pp_le_list)->text, text) == 0) return (*pp_le_list)->expr; } pp_le_list = (ltsmin_expr_list_t**)&((*pp_le_list)->next); } // alloc room for this predicate expression *pp_le_list = (ltsmin_expr_list_t*) RTmalloc(sizeof(ltsmin_expr_list_t)); (*pp_le_list)->text = strdup(text); (*pp_le_list)->expr = e; Debug ("LTL Symbol table: record expression %p as '%s'", e, text); (*pp_le_list)->next = NULL; return e; }
void lts_set_type(lts_t lts,LTS_TYPE type){ uint32_t i,j; if (lts->type==type) return; /* no type change */ /* first change to LTS_LIST */ switch(lts->type){ case LTS_LIST: lts->begin=(u_int32_t*)RTmalloc(sizeof(u_int32_t)*(lts->states+1)); break; case LTS_BLOCK: lts->src=(u_int32_t*)RTmalloc(sizeof(u_int32_t)*(lts->transitions)); for(i=0;i<lts->states;i++){ for(j=lts->begin[i];j<lts->begin[i+1];j++){ lts->src[j]=i; } } break; case LTS_BLOCK_INV: lts->dest=(u_int32_t*)RTmalloc(sizeof(u_int32_t)*(lts->transitions)); for(i=0;i<lts->states;i++){ for(j=lts->begin[i];j<lts->begin[i+1];j++){ lts->dest[j]=i; } } break; } // MEMSTAT_CHECK; /* then change to requried type */ lts->type=type; switch(type){ case LTS_LIST: free(lts->begin); lts->begin=NULL; return; case LTS_BLOCK: build_block(lts->states,lts->transitions,lts->begin,lts->src,lts->label,lts->dest); free(lts->src); lts->src=NULL; return; case LTS_BLOCK_INV: build_block(lts->states,lts->transitions,lts->begin,lts->dest,lts->label,lts->src); free(lts->dest); lts->dest=NULL; return; } }
raf_t MPI_Load_raf(char *name,MPI_Comm comm){ raf_t raf=(raf_t)RTmalloc(sizeof(struct raf_struct_s)); raf_init(raf,name); raf->blocksize=65536; MPI_File f; MPI_Comm_size(comm,&(raf->workers)); MPI_Comm_rank(comm,&(raf->rank)); int e=MPI_File_open(comm,name,MPI_MODE_RDONLY,MPI_INFO_NULL,&f); if(e){ int i=1024; char msg[1024]; MPI_Error_string(e,msg,&i); Fatal(0,error,"err is %s\n",msg); } MPI_File_set_errhandler(f,MPI_ERRORS_ARE_FATAL); MPI_File_get_size(f,&(raf->size)); if ((raf->size)%(raf->blocksize)) Fatal(0,error,"file not multiple of block size"); if (((raf->size)/(raf->blocksize))%(raf->workers)) Fatal(0,error,"block count not multiple of worker count"); //Warning(info,"my share is %d",(raf->size)/(raf->workers)); raf->data=RTmalloc((raf->size)/(raf->workers)); if (1) { Warning(info,"using MPI_File_read_all"); MPI_Datatype ftype; MPI_Type_vector((raf->size)/(raf->blocksize),(raf->blocksize),(raf->blocksize)*(raf->workers),MPI_CHAR,&ftype); MPI_Type_commit(&ftype); MPI_File_set_view(f,(raf->blocksize)*(raf->rank),MPI_CHAR,ftype,"native",MPI_INFO_NULL); MPI_File_read_all(f,raf->data,(raf->size)/(raf->workers),MPI_CHAR,MPI_STATUS_IGNORE); MPI_File_close(&f); MPI_Type_free(&ftype); } else { Warning(info,"using MPI_File_read_at"); int blockcount=((raf->size)/(raf->blocksize))/(raf->workers); for(int i=0;i<blockcount;i++){ MPI_File_read_at(f,((i*(raf->workers)+(raf->rank))*(raf->blocksize)), (raf->data)+(i*(raf->blocksize)),(raf->blocksize),MPI_CHAR,MPI_STATUS_IGNORE); } MPI_File_close(&f); } raf->rq_tag=core_add(raf,request_service); raf->ack_tag=core_add(raf,receive_service); raf->shared.read=read_at; raf->shared.size=mpi_size; raf->shared.close=mpi_close; //Warning(info,"file loaded"); return raf; }
prob_client_t prob_client_create() { prob_client_t pc = (prob_client_t) RTmalloc(sizeof(struct prob_client)); pc->id_count = 0; return pc; }
/** * \brief Creates an empty result. */ recursive_result recursive_result_create(vdom_t dom) { recursive_result result; result.dom = dom; for(int p=0; p < 2; p++) { result.win[p] = vset_create(dom, -1, NULL); /* for storing strategy as sequence of level sets: */ result.strategy_levels_max[p] = INIT_STRATEGY_MAX; // max number of sets per player result.strategy_levels_count[p] = 0; // number of sets per player result.strategy_levels[p] = RTmalloc((result.strategy_levels_max[p])*sizeof(vset_t)); // level sets, computed by the attractor result.strategy_boundary_count[p] = 1; result.strategy_boundaries[p] = RTmalloc(INIT_STRATEGY_MAX*sizeof(int)); // boundaries between separate attractor computations result.strategy_boundaries[p][0] = 0; } return result; }
model_t GBaddCheck (model_t model) { HREassert (model != NULL, "No model"); if (!PINS_CORRECTNESS_CHECK) return model; Print1 (info, "Matrix checking layer activated."); model_t check = GBcreateBase (); check_ctx_t *ctx = RTmalloc (sizeof(check_ctx_t)); ctx->N = pins_get_state_variable_count (model); ctx->K = pins_get_group_count (model); ctx->L = pins_get_edge_label_count (model); ctx->S = pins_get_state_label_count (model); ctx->src2 = RTmalloc(sizeof(int[ctx->N])); ctx->check_must = ci_create (ctx->N); ctx->read = (ci_list **) dm_rows_to_idx_table (GBgetDMInfoRead(model)); ctx->must = (ci_list **) dm_rows_to_idx_table (GBgetDMInfoMustWrite(model)); ctx->may = GBgetDMInfoMayWrite(model); ctx->stack = isba_create (ctx->N); ctx->parent = model; ctx->magic[0] = RTmalloc(sizeof(int[ctx->N])); ctx->magic[1] = RTmalloc(sizeof(int[ctx->N])); for (int i = 0; i < ctx->N; i++) { int max = type_max (ctx, i); int min = type_min (ctx, i); int c = max - min; HREassert (c > 0, "Empty type range for slot: %d -- %s", i, str_slot(ctx, NULL, i)); ctx->magic[0][i] = min; ctx->magic[1][i] = min + 1; } ctx->reentrent = 0; GBsetContext (check, ctx); GBsetNextStateAll (check, check_all); GBsetNextStateLong (check, check_long); GBsetNextStateShort (check, check_short); //GBsetActionsLong (check, check_long); //GBsetActionsShort (check, check_short); GBinitModelDefaults (&check, model); return check; }
static vrel_t rel_load_proj(FILE* f, vdom_t dom) { vrel_t rel = (vrel_t)RTmalloc(sizeof(struct vector_relation)); memset(rel, 0, sizeof(struct vector_relation)); rel->dom = dom; return rel; // Do not actually load anything from file (void)f; }
static void add_block(isb_allocator_t buf) { Debug("adding block %zu", buf->num_block-1); size_t size = ((buf->el_size)*sizeof(int))<<BLOCK_ELT_POW; int *block = RTmalloc(size); buf->blocks[buf->num_block] = block; buf->num_block++; buf->cur_index = 0; }
static void pvar_slice(lts_type_t ltstype){ if (pvars==NULL) { pv_count=0; return; } int N=lts_type_get_state_length(ltstype); char *tmp=pvars; pv_count=0; while(tmp){ pv_count++; int i=0; while(tmp[i]&&tmp[i]!=' ') { i++; } if (tmp[i]) { tmp[i]=0; tmp=&tmp[i+1]; } else { tmp=NULL; } } pvar_name=RTmalloc(pv_count*sizeof(char*)); pvar_idx=RTmalloc(pv_count*sizeof(int)); tmp=pvars; Warning(info,"state length is %d",N); for(int j=0;j<N;j++) Warning(info,"state %d is %s",j, lts_type_get_state_name(ltstype,j)); for(int i=0;i<pv_count;i++){ pvar_name[i]=tmp; pvar_idx[i]=-1; for(int j=0;j<N;j++){ if (strcmp(tmp,lts_type_get_state_name(ltstype,j))!=0) continue; pvar_idx[i]=j; break; } tmp=tmp+strlen(tmp)+1; } for(int i=0;i<pv_count;i++){ Warning(info,"variable %d is %s, idx %d",i,pvar_name[i],pvar_idx[i]); } }
static void dbg_found_read_dep_error (check_ctx_t *ctx, int *dst, int *dst2, int idx) { char *res = RTmalloc (1024); lts_type_t ltstype = GBgetLTStype (ctx->parent); int typeno = lts_type_get_state_typeno (ltstype, idx); print_chunk (ctx->parent, res, 1024, typeno, dst[idx]); Print1 (lerror, "Found missing read dependency in group %d (diff slot: %d -- %s != %s).\\" "Identifying culprit read slot...", ctx->group, idx, str_slot(ctx, dst2, idx), res); RTfree (res); }
/* * Sanitizes and caches all type symbols of an etf_model_t. Should only be * called once. */ void sanitize_types(etf_model_t model) { lts_type_t ltstype = etf_type(model); int n_types = lts_type_get_type_count(ltstype); sanitized_types = (char***)RTmallocZero(n_types*sizeof(char**)); for (int i=0;i<n_types;i++) { int v_count = etf_get_value_count(model, i); if (v_count) { sanitized_types[i] = (char**)RTmalloc(v_count*sizeof(char*)); for (int j=0;j<v_count;j++) { chunk ch = etf_get_value(model, i, j); char tmp[ch.len+1]; strncpy(tmp,ch.data,ch.len); tmp[ch.len] = '\0'; int len = ch.len+2; sanitized_types[i][j] = (char*)RTmalloc(len); sanitize_ID(tmp,len,sanitized_types[i][j]); Debug("Sanitizing type %s to %s", tmp, sanitized_types[i][j]); } } } }
trc_env_t * trc_create (model_t model, trc_get_state_f get, void *arg) { trc_env_t *trace = RTmalloc(sizeof(trc_env_t)); lts_type_t ltstype = GBgetLTStype (model); trace->N = lts_type_get_state_length (ltstype); trace->state_labels = lts_type_get_state_label_count (ltstype); trace->get_state = get; trace->get_state_arg = arg; trace->model = model; return trace; }
/** * initializer for the UF array */ uf_t * uf_create () { HREassert (sizeof (uf_state_t) == sizeof (int[8]), "Improper structure for uf_state_t. Expected: size = %zu", sizeof (int[8])); uf_t *uf = RTmalloc (sizeof (uf_t)); uf->array = RTalignZero (sizeof(int[8]), sizeof (uf_state_t) * (1ULL << dbs_size) ); return uf; }
rt_timer_t RTcreateTimer(){ rt_timer_t timer; timer=(rt_timer_t)RTmalloc(sizeof(struct timer)); if (timer){ timer->real_time=0; timer->times.tms_utime=0; timer->times.tms_stime=0; timer->times.tms_cutime=0; timer->times.tms_cstime=0; timer->running=0; } return timer; }
lts_t lts_create(){ lts_t lts=(lts_t)RTmalloc(sizeof(struct lts)); lts->begin=NULL; lts->src=NULL; lts->label=NULL; lts->dest=NULL; lts->type=LTS_LIST; lts->transitions=0; lts->states=0; lts->tau=-1; lts->label_string=NULL; return lts; }
/** * initializer for the UF array */ uf_t * uf_create () { HREassert (sizeof (uf_state_t) == sizeof (int[8]), "Improper structure for uf_state_t. Expected: size = %zu", sizeof (int[8])); uf_t *uf = RTmalloc (sizeof (uf_t)); // allocate one entry extra since [0] is not used uf->array = RTalignZero (sizeof(int[8]), sizeof (uf_state_t) * ( (1ULL << dbs_size) + 1 ) ); return uf; }
raf_t raf_unistd(char *name){ int fd=open(name,O_RDWR|O_CREAT,DEFFILEMODE); if (fd==-1) FatalCall(1,error,"could not open %s",name); raf_t raf=(raf_t)RTmalloc(sizeof(struct raf_struct_s)); raf_init(raf,name); raf->fd=fd; raf->shared.read=RAFread; raf->shared.write=RAFwrite; raf->shared.awrite=RAFwrite; raf->shared.await=RAFwait; raf->shared.size=RAFsize; raf->shared.resize=RAFresize; raf->shared.close=RAFclose; return raf; }
static vset_t set_load(FILE* f, vdom_t dom) { vset_t set = (vset_t)RTmalloc(sizeof(struct vector_set)); set->dom = dom; sylvan_serialize_fromfile(f); size_t bdd; fread(&bdd, sizeof(size_t), 1, f); set->bdd = sylvan_ref(sylvan_serialize_get_reversed(bdd)); fread(&set->vector_size, sizeof(size_t), 1, f); set->vec_to_bddvar = (BDDVAR*)RTmalloc(sizeof(BDDVAR) * fddbits * set->vector_size); fread(set->vec_to_bddvar, sizeof(BDDVAR), fddbits * set->vector_size, f); LACE_ME; sylvan_gc_disable(); set->variables = sylvan_ref(sylvan_set_fromarray(set->vec_to_bddvar, fddbits * set->vector_size)); set->projection = sylvan_ref(sylvan_set_removeall(dom->universe, set->variables)); sylvan_gc_enable(); return set; }
void reach_sat(reach_proc_t reach_proc, vset_t visited, bitvector_t *reach_groups, long *eg_count, long *next_count, long *guard_count) { (void) reach_proc; (void) next_count; (void) guard_count; if (PINS_USE_GUARDS) Abort("guard-splitting not supported with saturation=sat"); if (act_detect != NULL && trc_output != NULL) Abort("Action detection with trace generation not supported"); for (int i = 0; i < nGrps; i++) { if (bitvector_is_set(reach_groups, i)) { struct expand_info *ctx = RTmalloc(sizeof(struct expand_info)); ctx->group = i; ctx->group_explored = group_explored[i]; ctx->eg_count = eg_count; vrel_set_expand(group_next[i], expand_group_next_projected, ctx); } } if (trc_output != NULL) save_level(visited); stats_and_progress_report(NULL, visited, 0); if (USE_PARALLELISM) vset_least_fixpoint_par(visited, visited, group_next, nGrps); else vset_least_fixpoint(visited, visited, group_next, nGrps); stats_and_progress_report(NULL, visited, 1); check_invariants(visited, -1); if (dlk_detect) { vset_t deadlocks = vset_create(domain, -1, NULL); vset_t dlk_temp = vset_create(domain, -1, NULL); vset_copy(deadlocks, visited); for (int i = 0; i < nGrps; i++) { vset_prev(dlk_temp, visited, group_next[i],deadlocks); reduce(i, dlk_temp); vset_minus(deadlocks, dlk_temp); vset_clear(dlk_temp); } deadlock_check(deadlocks, reach_groups); vset_destroy(deadlocks); vset_destroy(dlk_temp); } }