void net_add_domain(struct domain *dp) { kprintf("Adding domain %s (family %d)\n", dp->dom_name, dp->dom_family); /* First, link in the domain */ lck_mtx_lock(domain_proto_mtx); concat_domain(dp); init_domain(dp); lck_mtx_unlock(domain_proto_mtx); }
int commit_parameters(){ int out_level = par_geti_def("log","out_level",0); int err_level = par_geti_def("log","err_level",0); ath_log_set_level(out_level, err_level); if(has_external_gravitational_potential) { StaticGravPot = grav_pot; } CourNo = par_getd("time","cour_no"); #ifdef ISOTHERMAL Iso_csound = par_getd("problem","iso_csound"); Iso_csound2 = Iso_csound*Iso_csound; #else Gamma = par_getd("problem","gamma"); Gamma_1 = Gamma - 1.0; Gamma_2 = Gamma - 2.0; #endif init_domain(&level0_Grid, &level0_Domain); init_grid(&level0_Grid, &level0_Domain); if ((Potentials = (Real***)calloc_3d_array( level0_Grid.Nx3 + 2 * nghost, level0_Grid.Nx2 + 2 * nghost, level0_Grid.Nx1 + 2 * nghost, sizeof(Real))) == NULL) { return -1; } return 0; }
int main (int argc, char **argv) { /* arrays used to contain each PE's rows - specify cols, no need to spec rows */ float **U_Curr; float **U_Next; /* helper variables */ /* available iterator */ int i, j, k, m, n; int per_proc, remainder, my_start_row, my_end_row, my_num_rows; int verbose = 0; int show_time = 0; double time; double t, tv[2]; /*OpenSHMEM initilization*/ start_pes (0); p = _num_pes (); my_rank = _my_pe (); if (p > 8) { fprintf(stderr, "Ignoring test when run with more than 8 pes\n"); return 77; } /* argument processing done by everyone */ int c, errflg; extern char *optarg; extern int optind, optopt; while ((c = getopt (argc, argv, "e:h:m:tw:v")) != -1) { switch (c) { case 'e': EPSILON = atof (optarg); break; case 'h': HEIGHT = atoi (optarg); break; case 'm': /* selects the numerical methods */ switch (atoi (optarg)) { case 1: /* jacobi */ meth = 1; break; case 2: /* gauss-seidel */ meth = 2; break; case 3: /* sor */ meth = 3; break; } break; case 't': show_time++; /* overridden by -v (verbose) */ break; case 'w': WIDTH = atoi (optarg); break; case 'v': verbose++; break; /* handle bad arguments */ case ':': /* -h or -w without operand */ if (ROOT == my_rank) fprintf (stderr, "Option -%c requires an operand\n", optopt); errflg++; break; case '?': if (ROOT == my_rank) fprintf (stderr, "Unrecognized option: -%c\n", optopt); errflg++; break; } } if (ROOT == my_rank && argc < 2) { printf ("Using defaults: -h 20 -w 20 -m 2\n"); } // if (0 < errflg) // exit(EXIT_FAILURE); /* wait for user to input runtime params */ for (i = 0; i < _SHMEM_REDUCE_SYNC_SIZE; i += 1) pSync[i] = _SHMEM_SYNC_VALUE; shmem_barrier_all (); /* broadcast method to use */ shmem_broadcast32 (&meth, &meth, 1, 0, 0, 0, p, pSync); switch (meth) { case 1: method = &jacobi; break; case 2: method = &gauss_seidel; break; case 3: method = &sor; break; } /* let each processor decide what rows(s) it owns */ my_start_row = get_start (my_rank); my_end_row = get_end (my_rank); my_num_rows = get_num_rows (my_rank); if (0 < verbose) printf ("proc %d contains (%d) rows %d to %d\n", my_rank, my_num_rows, my_start_row, my_end_row); fflush (stdout); /* allocate 2d array */ U_Curr = (float **) malloc (sizeof (float *) * my_num_rows); U_Curr[0] = (float *) malloc (sizeof (float) * my_num_rows * (int) floor (WIDTH / H)); for (i = 1; i < my_num_rows; i++) { U_Curr[i] = U_Curr[i - 1] + (int) floor (WIDTH / H); } /* allocate 2d array */ U_Next = (float **) malloc (sizeof (float *) * my_num_rows); U_Next[0] = (float *) malloc (sizeof (float) * my_num_rows * (int) floor (WIDTH / H)); for (i = 1; i < my_num_rows; i++) { U_Next[i] = U_Next[i - 1] + (int) floor (WIDTH / H); } /* initialize global grid */ init_domain (U_Curr, my_rank); init_domain (U_Next, my_rank); /* iterate for solution */ if (my_rank == ROOT) { tv[0] = gettime (); } k = 1; while (1) { method (U_Curr, U_Next); local_convergence_sqd = get_convergence_sqd (U_Curr, U_Next, my_rank); shmem_barrier_all (); shmem_float_sum_to_all (&convergence_sqd, &local_convergence_sqd, 1, 0, 0, p, pWrk, pSync); if (my_rank == ROOT) { convergence = sqrt (convergence_sqd); if (verbose == 1) { printf ("L2 = %f\n", convergence); } } /* broadcast method to use */ shmem_barrier_all (); shmem_broadcast32 (&convergence, &convergence, 1, 0, 0, 0, p, pSync); if (convergence <= EPSILON) { break; } /* copy U_Next to U_Curr */ for (j = my_start_row; j <= my_end_row; j++) { for (i = 0; i < (int) floor (WIDTH / H); i++) { U_Curr[j - my_start_row][i] = U_Next[j - my_start_row][i]; } } k++; //MPI_Barrier(MPI_COMM_WORLD); shmem_barrier_all (); } /* say something at the end */ if (my_rank == ROOT) { //time = MPI_Wtime() - time; tv[1] = gettime (); t = dt (&tv[1], &tv[0]); printf ("Estimated time to convergence in %d iterations using %d processors on a %dx%d grid is %f seconds\n", k, p, (int) floor (WIDTH / H), (int) floor (HEIGHT / H), t / 1000000.0); } //MPI_Finalize(); exit (EXIT_SUCCESS); return 0; }
const HParser* init_rdata(uint16_t type) { static const HParser *parsers[RDATA_TYPE_MAX+1]; static int inited = 0; if (type >= sizeof(parsers)) return NULL; if (inited) return parsers[type]; H_RULE (domain, init_domain()); H_ARULE(cstr, init_character_string()); H_RULE (a, h_uint32()); H_RULE (ns, domain); H_RULE (md, domain); H_RULE (mf, domain); H_RULE (cname, domain); H_ARULE(soa, h_sequence(domain, // MNAME domain, // RNAME h_uint32(), // SERIAL h_uint32(), // REFRESH h_uint32(), // RETRY h_uint32(), // EXPIRE h_uint32(), // MINIMUM NULL)); H_RULE (mb, domain); H_RULE (mg, domain); H_RULE (mr, domain); H_VRULE(null, h_many(h_uint8())); H_RULE (wks, h_sequence(h_uint32(), h_uint8(), h_many(h_uint8()), NULL)); H_RULE (ptr, domain); H_RULE (hinfo, h_sequence(cstr, cstr, NULL)); H_RULE (minfo, h_sequence(domain, domain, NULL)); H_RULE (mx, h_sequence(h_uint16(), domain, NULL)); H_ARULE(txt, h_many1(cstr)); parsers[ 0] = NULL; // there is no type 0 parsers[ 1] = a; parsers[ 2] = ns; parsers[ 3] = md; parsers[ 4] = mf; parsers[ 5] = cname; parsers[ 6] = soa; parsers[ 7] = mb; parsers[ 8] = mg; parsers[ 9] = mr; parsers[10] = null; parsers[11] = wks; parsers[12] = ptr; parsers[13] = hinfo; parsers[14] = minfo; parsers[15] = mx; parsers[16] = txt; // All parsers must consume their input exactly. for(uint16_t i; i<sizeof(parsers); i++) { if(parsers[i]) { parsers[i] = h_action(h_sequence(parsers[i], h_end_p(), NULL), act_index0); } } inited = 1; return parsers[type]; }
void domaininit(void) { register struct domain *dp; /* * allocate lock group attribute and group for domain mutexes */ domain_proto_mtx_grp_attr = lck_grp_attr_alloc_init(); domain_proto_mtx_grp = lck_grp_alloc_init("domain", domain_proto_mtx_grp_attr); /* * allocate the lock attribute for per domain mutexes */ domain_proto_mtx_attr = lck_attr_alloc_init(); if ((domain_proto_mtx = lck_mtx_alloc_init(domain_proto_mtx_grp, domain_proto_mtx_attr)) == NULL) { printf("domaininit: can't init domain mtx for domain list\n"); return; /* we have a problem... */ } /* * Add all the static domains to the domains list */ lck_mtx_lock(domain_proto_mtx); concat_domain(&localdomain); concat_domain(&routedomain); concat_domain(&inetdomain); #if NETAT concat_domain(&atalkdomain); #endif #if INET6 concat_domain(&inet6domain); #endif #if IPSEC concat_domain(&keydomain); #endif #if NS concat_domain(&nsdomain); #endif #if ISO concat_domain(&isodomain); #endif #if CCITT concat_domain(&ccittdomain); #endif concat_domain(&ndrvdomain); concat_domain(&systemdomain); /* * Now ask them all to init (XXX including the routing domain, * see above) */ for (dp = domains; dp; dp = dp->dom_next) init_domain(dp); lck_mtx_unlock(domain_proto_mtx); timeout(pffasttimo, NULL, 1); timeout(pfslowtimo, NULL, 1); }
int main(int argc, char** argv) { int p,my_rank; /* arrays used to contain each PE's rows - specify cols, no need to spec rows */ float **U_Curr; float **U_Next; /* helper variables */ float convergence,convergence_sqd,local_convergence_sqd; /* available iterator */ int i,j,k,m,n; int per_proc,remainder,my_start_row,my_end_row,my_num_rows; int verbose = 0; int show_time = 0; double time; /* initialize mpi stuff */ MPI_Init(&argc, &argv); /* get number of procs */ MPI_Comm_size(MPI_COMM_WORLD,&p); /* get rank of current process */ MPI_Comm_rank(MPI_COMM_WORLD,&my_rank); /* argument processing done by everyone */ int c,errflg; extern char *optarg; extern int optind, optopt; while ((c = getopt(argc, argv, "e:h:m:tw:v")) != -1) { switch(c) { case 'e': EPSILON = atof(optarg); break; case 'h': HEIGHT = atoi(optarg); break; case 'm': /* selects the numerical methods */ switch(atoi(optarg)) { case 1: /* jacobi */ meth = 1; break; case 2: /* gauss-seidel */ meth = 2; break; case 3: /* sor */ meth = 3; break; } break; case 't': show_time++; /* overridden by -v (verbose) */ break; case 'w': WIDTH = atoi(optarg); break; case 'v': verbose++; break; /* handle bad arguments */ case ':': /* -h or -w without operand */ if (ROOT == my_rank) fprintf(stderr,"Option -%c requires an operand\n", optopt); errflg++; break; case '?': if (ROOT == my_rank) fprintf(stderr,"Unrecognized option: -%c\n", optopt); errflg++; break; } } /* if (0 < errflg) exit(EXIT_FAILURE); */ /* wait for user to input runtime params */ MPI_Barrier(MPI_COMM_WORLD); /* broadcast method to use */ (void) MPI_Bcast(&meth,1,MPI_INT,0,MPI_COMM_WORLD); switch (meth) { case 1: method = &jacobi; break; case 2: method = &gauss_seidel; break; case 3: method = &sor; break; } /* let each processor decide what rows(s) it owns */ my_start_row = get_start(my_rank); my_end_row = get_end(my_rank); my_num_rows = get_num_rows(my_rank); if ( 0 < verbose ) printf("proc %d contains (%d) rows %d to %d\n",my_rank,my_num_rows,my_start_row,my_end_row); fflush(stdout); /* allocate 2d array */ U_Curr = (float**)malloc(sizeof(float*)*my_num_rows); U_Curr[0] = (float*)malloc(sizeof(float)*my_num_rows*(int)floor(WIDTH/H)); for (i=1;i<my_num_rows;i++) { U_Curr[i] = U_Curr[i-1]+(int)floor(WIDTH/H); } /* allocate 2d array */ U_Next = (float**)malloc(sizeof(float*)*my_num_rows); U_Next[0] = (float*)malloc(sizeof(float)*my_num_rows*(int)floor(WIDTH/H)); for (i=1;i<my_num_rows;i++) { U_Next[i] = U_Next[i-1]+(int)floor(WIDTH/H); } /* initialize global grid */ init_domain(U_Curr,my_rank); init_domain(U_Next,my_rank); /* iterate for solution */ if (my_rank == ROOT) { time = MPI_Wtime(); } k = 1; while (1) { method(U_Curr,U_Next); local_convergence_sqd = get_convergence_sqd(U_Curr,U_Next,my_rank); MPI_Reduce(&local_convergence_sqd,&convergence_sqd,1,MPI_FLOAT,MPI_SUM,ROOT,MPI_COMM_WORLD); if (my_rank == ROOT) { convergence = sqrt(convergence_sqd); if (verbose == 1) { printf("L2 = %f\n",convergence); } } /* broadcast method to use */ (void) MPI_Bcast(&convergence,1,MPI_INT,0,MPI_COMM_WORLD); if (convergence <= EPSILON) { break; } /* copy U_Next to U_Curr */ for (j=my_start_row;j<=my_end_row;j++) { for (i=0;i<(int)floor(WIDTH/H);i++) { U_Curr[j-my_start_row][i] = U_Next[j-my_start_row][i]; } } k++; MPI_Barrier(MPI_COMM_WORLD); } /* say something at the end */ if (my_rank == ROOT) { time = MPI_Wtime() - time; if (0 < verbose) { printf("Estimated time to convergence in %d iterations using %d processors on a %dx%d grid is %f seconds\n",k,p,(int)floor(WIDTH/H),(int)floor(HEIGHT/H),time); } else if (show_time) { printf("%f\n",time); } /* else show nothing */ } MPI_Finalize(); exit(EXIT_SUCCESS); return 0; }
static void actual_main(void *arg) #endif { int argc = ((struct args_t*)arg)->argc; char **argv = ((struct args_t*)arg)->argv; /* initialize HRE */ HREinitBegin(argv[0]); HREaddOptions(options,"Perform a symbolic reachability analysis of <model>\n" "The optional output of this analysis is an ETF " "representation of the input\n\nOptions"); lts_lib_setup(); // add options for LTS library HREinitStart(&argc,&argv,1,2,files,"<model> [<etf>]"); /* initialize HRE on other workers */ init_hre(HREglobal()); /* check for unsupported options */ if (PINS_POR != PINS_POR_NONE) Abort("Partial-order reduction and symbolic model checking are not compatible."); if (inhibit_matrix != NULL && sat_strategy != NO_SAT) Abort("Maximal progress is incompatibale with saturation."); if (files[1] != NULL) { char *ext = strrchr(files[1], '.'); if (ext == NULL || ext == files[1]) { Abort("Output filename has no extension!"); } if (strcasecmp(ext, ".etf") != 0) { // not ETF if (!(vset_default_domain == VSET_Sylvan && strcasecmp(ext, ".bdd") == 0) && !(vset_default_domain == VSET_LDDmc && strcasecmp(ext, ".ldd") == 0)) { Abort("Only supported output formats are ETF, BDD (with --vset=sylvan) and LDD (with --vset=lddmc)"); } if (PINS_USE_GUARDS) { Abort("Exporting symbolic state space not comptabile with " "guard-splitting"); } } } #ifdef HAVE_SYLVAN if (!USE_PARALLELISM) { if (strategy == PAR_P) { strategy = BFS_P; Print(info, "Front-end not thread-safe; using --order=bfs-prev instead of --order=par-prev."); } else if (strategy == PAR) { strategy = BFS; Print(info, "Front-end not thread-safe; using --order=bfs instead of --order=par."); } } #endif /* turn off Lace for now to speed up while not using parallelism */ lace_suspend(); /* initialize the model and PINS wrappers */ init_model(files[0]); /* initialize action detection */ act_label = lts_type_find_edge_label_prefix (ltstype, LTSMIN_EDGE_TYPE_ACTION_PREFIX); if (act_label != -1) action_typeno = lts_type_get_edge_label_typeno(ltstype, act_label); if (act_detect != NULL) init_action_detection(); bitvector_create(&state_label_used, sLbls); if (inv_detect != NULL) init_invariant_detection(); else if (PINS_USE_GUARDS) { for (int i = 0; i < nGuards; i++) { bitvector_set(&state_label_used, i); } } init_maxsum(ltstype); /* turn on Lace again (for Sylvan) */ if (vset_default_domain==VSET_Sylvan || vset_default_domain==VSET_LDDmc) { lace_resume(); } if (next_union) vset_next_fn = vset_next_union_src; init_domain(VSET_IMPL_AUTOSELECT); vset_t initial = vset_create(domain, -1, NULL); int *src = RTmalloc (sizeof(int[N])); GBgetInitialState(model, src); vset_add(initial, src); Print(infoShort, "got initial state"); /* if writing .dot files, open directory first */ if (dot_dir != NULL) { DIR* dir = opendir(dot_dir); if (dir) { closedir(dir); } else if (ENOENT == errno) { Abort("Option 'dot-dir': directory '%s' does not exist", dot_dir); } else { Abort("Option 'dot-dir': failed opening directory '%s'", dot_dir); } } if (vset_dir != NULL) { DIR *dir = opendir(vset_dir); if (dir) { closedir(dir); } else if (errno == ENOENT) { Abort("Option 'save-levels': directory '%s' does not exist", vset_dir); } else { Abort("Option 'save-levels': failed opening directory '%s'", vset_dir); } } init_mu_calculus(); /* determine if we need to generate a symbolic parity game */ #ifdef LTSMIN_PBES bool spg = true; #else bool spg = GBhaveMucalc() ? true : false; #endif /* if spg, then initialize labeling stuff before reachability */ if (spg) { Print(infoShort, "Generating a Symbolic Parity Game (SPG)."); init_spg(model); } /* create timer */ reach_timer = RTcreateTimer(); /* fix level 0 */ visited = vset_create(domain, -1, NULL); vset_copy(visited, initial); /* check the invariants at level 0 */ check_invariants(visited, 0); /* run reachability */ run_reachability(visited, files[1]); /* report states */ final_stat_reporting(visited); /* save LTS */ if (files[1] != NULL) { char *ext = strrchr(files[1], '.'); if (strcasecmp(ext, ".etf") == 0) { do_output(files[1], visited); } else { // if not .etf, then the filename ends with .bdd or .ldd, symbolic LTS do_dd_output (initial, visited, files[1]); } } compute_maxsum(visited, domain); CHECK_MU(visited, src); if (max_mu_count > 0) { Print(info, "Mu-calculus peak nodes: %ld", max_mu_count); } /* optionally print counts of all group_next and group_explored sets */ final_final_stats_reporting (); if (spg) { // converting the LTS to a symbolic parity game, save and solve. lts_to_pg_solve (visited, src); } #ifdef HAVE_SYLVAN /* in case other Lace threads were still suspended... */ if (vset_default_domain!=VSET_Sylvan && vset_default_domain!=VSET_LDDmc) { lace_resume(); } else if (SYLVAN_STATS) { sylvan_stats_report(stderr); } #endif RTfree (src); GBExit(model); }