unsigned domount(int userarg) { setvbuf(stdout, NULL, _IONBF, 0); // need this to see i/o at all int sts; $DESCRIPTOR(bind, "bind"); $DESCRIPTOR(p, "p1"); char c[80]; struct dsc$descriptor o; o.dsc$a_pointer=c; o.dsc$w_length=80; memset (c, 0, 80); sts = cli$present(&p); if ((sts&1)==0) return sts; int retlen; char bindnam[80]; struct dsc$descriptor binddes; binddes.dsc$a_pointer=bindnam; binddes.dsc$w_length=80; memset (bindnam, 0, 80); int bind_sts = cli$present(&bind); if (bind_sts&1) { sts = cli$get_value(&bind, &binddes, &retlen); binddes.dsc$w_length = retlen; } char *dev = c; char *lab = 0; int devices = 0; char *devs[100],*labs[100]; #if 0 while (*lab != '\0') { labs[devices++] = lab; while (*lab != ',' && *lab != '\0') lab++; if (*lab != '\0') { *lab++ = '\0'; } else { break; } } #endif #if 0 // amd64 not happy with this? while (cli$get_value(&p, &o, &retlen)&1) { devs[devices++] = strdup(c); } #else cli$get_value(&p, &o, &retlen); devs[devices++] = strdup(c); #endif if (bind_sts&1) { for (dev = 0; dev < devices; dev ++) { short int chan; char buf[512]; struct _hm2 * hm2 = buf; struct dsc$descriptor dsc; dsc.dsc$w_length = strlen(devices[dev]); dsc.dsc$a_pointer = devices[dev]; sts=sys$assign(&dsc,&chan,0,0,0); char * nam = devices[dev]; int part = nam[3] - '1'; struct _iosb iosb; sts = sys$qiow(0, chan, IO$_READPBLK, &iosb, 0, 0, buf , 512, 1, part, 0, 0); hm2->hm2$w_rvn = dev + 1; memcpy(hm2->hm2$t_strucname, binddes.dsc$a_pointer, binddes.dsc$w_length); sts = sys$qiow(0, chan, IO$_WRITEPBLK, &iosb, 0, 0, buf , 512, 1, part, 0, 0); sys$dassgn(chan); } return 1; } #if 0 devices = 0; while (*dev != '\0') { devs[devices++] = dev; while (*dev != ',' && *dev != '\0') dev++; if (*dev != '\0') { *dev++ = '\0'; } else { break; } } #endif if (devices > 0) { unsigned i; struct VCB *vcb; struct item_list_3 it[2]; it[0].item_code=1; /*not yet */ it[0].buflen=strlen(devs[0]); it[0].bufaddr=devs[0]; it[1].item_code=0; // sts = mount(options,devices,devs,labs,&vcb); sts = sys$mount(it); #if 0 if (sts & 1) { for (i = 0; i < vcb->devices; i++) if (vcb->vcbdev[i].dev != NULL) printf("%%MOUNT-I-MOUNTED, Volume %12.12s mounted on %s\n", vcb->vcbdev[i].home.hm2$t_volname,vcb->vcbdev[i].dev->devnam); if (setdef_count == 0) { char *colon,defdir[256]; strcpy(defdir,vcb->vcbdev[0].dev->devnam); colon = strchr(defdir,':'); if (colon != NULL) *colon = '\0'; strcpy(defdir + strlen(defdir),":[000000]"); setdef(defdir); test_vcb = vcb; } } else { printf("Mount failed with %d\n",sts); } #endif } return sts; }
define() { remove(1); newdef(decbin(3)); setdef(arg(1),arg(2)); }
int main(int argc, char *argv[]) { int step, ie, iside, i, j, k; double mflops, tmax, nelt_tot = 0.0; char Class; logical ifmortar = false, verified; double t2, trecs[t_last+1]; char *t_names[t_last+1]; //-------------------------------------------------------------------- // Initialize NUMA control //-------------------------------------------------------------------- numa_initialize_env(NUMA_MIGRATE_EXISTING); //--------------------------------------------------------------------- // Read input file (if it exists), else take // defaults from parameters //--------------------------------------------------------------------- FILE *fp; if ((fp = fopen("timer.flag", "r")) != NULL) { timeron = true; t_names[t_total] = "total"; t_names[t_init] = "init"; t_names[t_convect] = "convect"; t_names[t_transfb_c] = "transfb_c"; t_names[t_diffusion] = "diffusion"; t_names[t_transf] = "transf"; t_names[t_transfb] = "transfb"; t_names[t_adaptation] = "adaptation"; t_names[t_transf2] = "transf+b"; t_names[t_add2] = "add2"; fclose(fp); } else { timeron = false; } printf("\n\n NAS Parallel Benchmarks (NPB3.3-OMP-C) - UA Benchmark\n\n"); if ((fp = fopen("inputua.data", "r")) != NULL) { int result; printf(" Reading from input file inputua.data\n"); result = fscanf(fp, "%d", &fre); while (fgetc(fp) != '\n'); result = fscanf(fp, "%d", &niter); while (fgetc(fp) != '\n'); result = fscanf(fp, "%d", &nmxh); while (fgetc(fp) != '\n'); result = fscanf(fp, "%lf", &alpha); Class = 'U'; fclose(fp); } else { printf(" No input file inputua.data. Using compiled defaults\n"); fre = FRE_DEFAULT; niter = NITER_DEFAULT; nmxh = NMXH_DEFAULT; alpha = ALPHA_DEFAULT; Class = CLASS_DEFAULT; } dlmin = pow(0.5, REFINE_MAX); dtime = 0.04*dlmin; printf(" Levels of refinement: %8d\n", REFINE_MAX); printf(" Adaptation frequency: %8d\n", fre); printf(" Time steps: %8d dt: %15.6E\n", niter, dtime); printf(" CG iterations: %8d\n", nmxh); printf(" Heat source radius: %8.4f\n", alpha); printf(" Number of available threads: %8d\n", omp_get_max_threads()); printf("\n"); top_constants(); for (i = 1; i <= t_last; i++) { timer_clear(i); } if (timeron) timer_start(t_init); // set up initial mesh (single element) and solution (all zero) create_initial_grid(); r_init_omp((double *)ta1, ntot, 0.0); nr_init_omp((int *)sje, 4*6*nelt, -1); init_locks(); // compute tables of coefficients and weights coef(); geom1(); // compute the discrete laplacian operators setdef(); // prepare for the preconditioner setpcmo_pre(); // refine initial mesh and do some preliminary work time = 0.0; mortar(); prepwork(); adaptation(&ifmortar, 0); if (timeron) timer_stop(t_init); timer_clear(1); time = 0.0; for (step = 0; step <= niter; step++) { if (step == 1) { // reset the solution and start the timer, keep track of total no elms r_init((double *)ta1, ntot, 0.0); time = 0.0; nelt_tot = 0.0; for (i = 1; i <= t_last; i++) { if (i != t_init) timer_clear(i); } timer_start(1); } // advance the convection step convect(ifmortar); if (timeron) timer_start(t_transf2); // prepare the intital guess for cg transf(tmort, (double *)ta1); // compute residual for diffusion term based on intital guess // compute the left hand side of equation, lapacian t #pragma omp parallel default(shared) private(ie,k,j,i) { #pragma omp for for (ie = 0; ie < nelt; ie++) { laplacian(ta2[ie], ta1[ie], size_e[ie]); } // compute the residual #pragma omp for for (ie = 0; ie < nelt; ie++) { for (k = 0; k < LX1; k++) { for (j = 0; j < LX1; j++) { for (i = 0; i < LX1; i++) { trhs[ie][k][j][i] = trhs[ie][k][j][i] - ta2[ie][k][j][i]; } } } } } //end parallel // get the residual on mortar transfb(rmor, (double *)trhs); if (timeron) timer_stop(t_transf2); // apply boundary condition: zero out the residual on domain boundaries // apply boundary conidtion to trhs #pragma omp parallel for default(shared) private(ie,iside) for (ie = 0; ie < nelt; ie++) { for (iside = 0; iside < NSIDES; iside++) { if (cbc[ie][iside] == 0) { facev(trhs[ie], iside, 0.0); } } } // apply boundary condition to rmor col2(rmor, tmmor, nmor); // call the conjugate gradient iterative solver diffusion(ifmortar); // add convection and diffusion if (timeron) timer_start(t_add2); add2((double *)ta1, (double *)t, ntot); if (timeron) timer_stop(t_add2); // perform mesh adaptation time = time + dtime; if ((step != 0) && (step/fre*fre == step)) { if (step != niter) { adaptation(&ifmortar, step); } } else { ifmortar = false; } nelt_tot = nelt_tot + (double)(nelt); } timer_stop(1); tmax = timer_read(1); verify(&Class, &verified); // compute millions of collocation points advanced per second. // diffusion: nmxh advancements, convection: 1 advancement mflops = nelt_tot*(double)(LX1*LX1*LX1*(nmxh+1))/(tmax*1.e6); print_results("UA", Class, REFINE_MAX, 0, 0, niter, tmax, mflops, " coll. point advanced", verified, NPBVERSION, COMPILETIME, CS1, CS2, CS3, CS4, CS5, CS6, "(none)"); //--------------------------------------------------------------------- // More timers //--------------------------------------------------------------------- if (timeron) { for (i = 1; i <= t_last; i++) { trecs[i] = timer_read(i); } if (tmax == 0.0) tmax = 1.0; printf(" SECTION Time (secs)\n"); for (i = 1; i <= t_last; i++) { printf(" %-10s:%9.3f (%6.2f%%)\n", t_names[i], trecs[i], trecs[i]*100./tmax); if (i == t_transfb_c) { t2 = trecs[t_convect] - trecs[t_transfb_c]; printf(" --> %11s:%9.3f (%6.2f%%)\n", "sub-convect", t2, t2*100./tmax); } else if (i == t_transfb) { t2 = trecs[t_diffusion] - trecs[t_transf] - trecs[t_transfb]; printf(" --> %11s:%9.3f (%6.2f%%)\n", "sub-diffuse", t2, t2*100./tmax); } } } //-------------------------------------------------------------------- // Teardown NUMA control //-------------------------------------------------------------------- numa_shutdown(); return 0; }