Example #1
0
void runPasses(PhaseTracker& tracker, bool isChpldoc) {
  size_t passListSize = sizeof(sPassList) / sizeof(sPassList[0]);

  setupLogfiles();

  if (printPasses == true || printPassesFile != 0) {
    tracker.ReportPass();
  }

  for (size_t i = 0; i < passListSize; i++) {
    runPass(tracker, i);

    USR_STOP(); // quit if fatal errors were encountered in pass

    currentPassNo++;

    // Break early if this is a chpl doc run
    if (isChpldoc == true && strcmp(sPassList[i].name, "docs") == 0) {
      break;
    }
  }

  destroyAst();
  teardownLogfiles();
}
Example #2
0
void runPasses(void) {
  setupLogfiles();
  PassInfo* pass = passlist+1;  // skip over FIRST
  bool chpldoc = strcmp(chplBinaryName, "chpldoc") == 0;
  if (chpldoc) 
    fDocs = true;
  while (pass->name != NULL) {
    advanceCurrentPass(pass->name);
    runPass(pass->name, pass->pass_fn, pass->check_fn, pass->log_tag);
    USR_STOP(); // quit if fatal errors were encountered in pass
    if (chpldoc && (strcmp(pass->name, "docs") == 0)) {
      break;
    }
    pass++;
  }
  advanceCurrentPass("finishing up");
  destroyAst();
  teardownLogfiles();
}
Example #3
0
void engine(double *mesh, hydro_prob *Hyp, hydro_args *Hya){
  int n, i,j;
  int bndL;
  int bndH;
  double dt;
  double cTime, nxttout;

  double volCell;
  double oTM,oTE;
  double TM,TE;
  int M_exp, E_exp;
  double M_prec, E_prec;

  char outfile[30];

  size_t primSize, qSize, flxSize;

  double initT, endT;

  Hp=Hyp;
  Ha=Hya;

  n=0;
  cTime=0;
  nxttout=-1.0;
  
  if(Hp->ny>=Hp->nx){
    primSize=Hp->nvar*(Hp->nx+4)*Hp->ny;
    qSize   =Hp->nvar*(Hp->nx+2)*Hp->ny;
    flxSize =Hp->nvar*(Hp->nx+1)*Hp->ny;
  }else{
    primSize=Hp->nvar*(Hp->ny+4)*Hp->nx;
    qSize   =Hp->nvar*(Hp->ny+2)*Hp->nx;
    flxSize =Hp->nvar*(Hp->ny+1)*Hp->nx;
  }

  if(Ha->nstepmax<0&&Ha->tend<0.0)return;

  q  =(double*)malloc(primSize*sizeof(double));
  qr =(double*)malloc(qSize*sizeof(double));
  ql =(double*)malloc(qSize*sizeof(double));
  flx=(double*)malloc(flxSize*sizeof(double));

  if(Ha->tend>0.0){
    nxttout=Ha->tend;
  }
  if(Ha->dtoutput>0.0&&nxttout>Ha->dtoutput){
    nxttout=Ha->dtoutput;
  }

  volCell=Hp->dx*Hp->dy;
  oTM=sumArray(mesh,VARRHO,Hp->nx,Hp->ny);
  oTE=sumArray(mesh,VARPR ,Hp->nx,Hp->ny);
#ifdef M_PREC_CMP
  frexp(oTM,&M_exp);
  frexp(oTE,&E_exp);

  M_prec=ldexp(DBL_EPSILON,M_exp-1);
  E_prec=ldexp(DBL_EPSILON,E_exp-1);

  printf("TM:%g+-%g TE:%g+-%g\n",volCell*oTM,volCell*M_prec,volCell*oTE,volCell*E_prec);
#endif

  //Print initial condition
  snprintf(outfile,29,"%s%05d",Ha->outPre,n);
  writeVis(outfile,mesh,Hp->dx,Hp->dy,Hp->nvar,Hp->nx,Hp->ny);
  printf("INIT: TM: %g TE: %g\n",volCell*oTM,volCell*oTE);
  
  initT=omp_get_wtime();

  while((n<Ha->nstepmax||Ha->nstepmax<0)&&(cTime<Ha->tend||Ha->tend<0)){
    //Calculate timestep
    dt=Ha->sigma*calcDT(mesh);
    if(nxttout>0.0&&dt>(nxttout-cTime)){
      printf("Adjusting timestep from %g to %g for iter %d\n",dt,nxttout-cTime,n);
      dt=(nxttout-cTime);
    }
    if(n%2==0){
      //X Dir
      runPass(mesh,dt,n,0);
      //Y Dir
      runPass(mesh,dt,n,1);
    }else{
      //Y Dir
      runPass(mesh,dt,n,1);
      //X Dir
      runPass(mesh,dt,n,0);
    }
    n+=1;
    cTime+=dt;
    if(n%Ha->nprtLine==0){
      TM=sumArray(mesh,VARRHO,Hp->nx,Hp->ny);
      TE=sumArray(mesh,VARPR ,Hp->nx,Hp->ny);
      printf("Iter %05d time %f dt %g TM: %g TE: %g\n",n,cTime,dt,volCell*TM,volCell*TE);
      if(0&&(fabs(TM-oTM)>0.0||fabs(TE-oTE)>0.0)){
	printf("ERR(%5s): Mass %g Ene %g\n","RAW",volCell*(TM-oTM),volCell*(TE-oTE));
	printf("ERR(%5s): Mass %g Ene %g\n","%",100.0*(TM-oTM)/oTM,100.0*(TE-oTE)/oTE);
#ifdef M_PREC_CMP
	printf("ERR(%5s): Mass %g Ene %g\n","M PRE",(TM-oTM)/M_prec,(TE-oTE)/E_prec);
#endif
      }
    }
    if((cTime>=nxttout&&nxttout>0)||(Ha->noutput>0&&n%Ha->noutput==0)){
      printf("Vis file @ time %f iter %d\n",cTime,n);
      if(cTime>=nxttout&&nxttout>0.0){
	nxttout+=Ha->dtoutput;
	if(nxttout>Ha->tend&&Ha->tend>0)nxttout=Ha->tend;
	//printf("Next Vis Time: %f\n",nxttout);
      }
      snprintf(outfile,29,"%s%05d",Ha->outPre,n);
      writeVis(outfile,mesh,Hp->dx,Hp->dy,Hp->nvar,Hp->nx,Hp->ny);
    }
  }
  printf("time: %f, %d iters run\n",cTime,n);

  endT=omp_get_wtime();

  printf("TFMT:%s,%s,%s,%s,%s,%s,%s,%s\n","cType","mType","init","nproc","nth","niters","ncells","wRunt");
  printf("TIME:%s,%s,%s,%d,%d,%d,%d,%g\n","\"OMP\"","\"CPU:?\"","\"Init\"",1,omp_get_max_threads(),n,Hp->nx*Hp->ny,(endT-initT));

  //Print final condition
  snprintf(outfile,29,"%s%05d",Ha->outPre,n);
  writeVis(outfile,mesh,Hp->dx,Hp->dy,Hp->nvar,Hp->nx,Hp->ny);

  Hp->t+=cTime;
  free(q  );
  free(qr );
  free(ql );
  free(flx);
}