Exemplo n.º 1
0
void MainTest::deletePost()
{
    auto count = FROM(db.posts())
            WHERE(Post::idField() == postId)
            DELETE();

    QTEST_ASSERT(count == 1);

    count = FROM(db.posts())
            WHERE(Post::idField() == postId)
            COUNT();

    QTEST_ASSERT(count == 0);
}
Exemplo n.º 2
0
void
equation_of_state(int imin,
                  int imax,
                  const int Hnxyt,
                  const int Hnvar,
                  const real_t Hsmallc,
                  const real_t Hgamma,
                  const int slices, const int Hstep,
                  real_t eint[Hstep][Hnxyt], real_t q[Hnvar][Hstep][Hnxyt], real_t c[Hstep][Hnxyt]) {
  int k, s = slices;
  int inpar = 0;
  real_t smallp;

  WHERE("equation_of_state");
  smallp = Square(Hsmallc) / Hgamma;
  FLOPS(1, 1, 0, 0);

  // printf("EOS: %d %d %d %d %g %g %d %d\n", imin, imax, Hnxyt, Hnvar, Hsmallc, Hgamma, slices, Hstep);
#pragma simd
  for (k = imin; k < imax; k++) {
    real_t rhok = q[ID][s][k];
    real_t base = (Hgamma - one) * rhok * eint[s][k];
    base = MAX(base, (real_t) (rhok * smallp));

    q[IP][s][k] = base;
    c[s][k] = sqrt(Hgamma * base / rhok);
  }
  { 
    int nops = slices * (imax - imin);
    FLOPS(5 * nops, 2 * nops, 1 * nops, 0 * nops);
  }
}                               // equation_of_state
Exemplo n.º 3
0
void
// qleftright(const int idim, const hydroparam_t H, hydrovarwork_t * Hvw)
qleftright(const int idim,
           const int Hnx,
           const int Hny,
           const int Hnxyt,
           const int Hnvar,
           const int slices, const int Hstep,
	   double *qxm,
	   double *qxp, double *qleft, double *qright) {
           //double qxm[Hnvar][Hstep][Hnxyt],
           //double qxp[Hnvar][Hstep][Hnxyt], double qleft[Hnvar][Hstep][Hnxyt], double qright[Hnvar][Hstep][Hnxyt]) {
  // #define IHVW(i,v) ((i) + (v) * Hnxyt)
  int nvar, i, s;
  int bmax;
  WHERE("qleftright");
  if (idim == 1) {
    bmax = Hnx + 1;
  } else {
    bmax = Hny + 1;
  }

#pragma acc parallel pcopyin(qxm[0:Hnvar*Hstep*Hnxyt], qxp[0:Hnvar*Hstep*Hnxyt]) pcopyout(qleft[0:Hnvar*Hstep*Hnxyt], qright[0:Hnvar*Hstep*Hnxyt]) 
#pragma acc loop gang collapse(2)
  for (nvar = 0; nvar < Hnvar; nvar++) {
    for (s = 0; s < slices; s++) {
#pragma acc loop vector
      for (i = 0; i < bmax; i++) {
        qleft[IDX(nvar,s,i)] = qxm[IDX(nvar,s,i + 1)];
        qright[IDX(nvar,s,i)] = qxp[IDX(nvar,s,i + 2)];
      }
    }
  }
}
Exemplo n.º 4
0
void
compute_deltat(real_t *dt, const hydroparam_t H, hydrowork_t * Hw, hydrovar_t * Hv, hydrovarwork_t * Hvw) {
  real_t cournox, cournoy;
  int j, jend, slices, Hstep, Hmin, Hmax;
  real_t (*e)[H.nxyt];
  real_t (*c)[H.nxystep];
  real_t (*q)[H.nxystep][H.nxyt];
  WHERE("compute_deltat");

  //   compute time step on grid interior
  cournox = zero;
  cournoy = zero;

  c = (real_t (*)[H.nxystep]) Hw->c;
  e = (real_t (*)[H.nxystep]) Hw->e;
  q = (real_t (*)[H.nxystep][H.nxyt]) Hvw->q;

  Hstep = H.nxystep;
  Hmin = H.jmin + ExtraLayer;
  Hmax = H.jmax - ExtraLayer;
  for (j = Hmin; j < Hmax; j += Hstep) {
    jend = j + Hstep;
    if (jend >= Hmax)
      jend = Hmax;
    slices = jend - j;          // numbre of slices to compute
    ComputeQEforRow(j, H.smallr, H.nx, H.nxt, H.nyt, H.nxyt, H.nvar, slices, Hstep, Hv->uold, q, e);
    equation_of_state(0, H.nx, H.nxyt, H.nvar, H.smallc, H.gamma, slices, Hstep, e, q, c);
    courantOnXY(&cournox, &cournoy, H.nx, H.nxyt, H.nvar, slices, Hstep, c, q, Hw->tmpm1, Hw->tmpm2);
    // fprintf(stdout, "[%2d]\t%g %g %g %g\n", H.mype, cournox, cournoy, H.smallc, H.courant_factor);
  }

  *dt = H.courant_factor * H.dx / MAX(cournox, MAX(cournoy, H.smallc));
  FLOPS(1, 1, 2, 0);
  // fprintf(stdout, "[%2d]\t%g %g %g %g %g %g\n", H.mype, cournox, cournoy, H.smallc, H.courant_factor, H.dx, *dt);
}                               // compute_deltat
Exemplo n.º 5
0
void
equation_of_state(int imin,
                  int imax,
                  const int Hnxyt,
                  const int Hnvar,
                  const double Hsmallc,
                  const double Hgamma,
                  const int slices, const int Hstep,
                  double *eint, double *q, double *c) {
  //double eint[Hstep][Hnxyt], double q[Hnvar][Hstep][Hnxyt], double c[Hstep][Hnxyt]) {
  int k, s;
  double smallp;

  WHERE("equation_of_state");
  smallp = Square(Hsmallc) / Hgamma;
  CFLOPS(1);

#pragma acc parallel pcopyin(eint[0:Hstep*Hnxyt]) pcopy(q[0:Hnvar*Hstep*Hnxyt]) pcopyout(c[0:Hstep*Hnxyt])
#pragma acc loop gang
  for (s = 0; s < slices; s++) {
#pragma acc loop vector
    for (k = imin; k < imax; k++) {
      double rhok = q[IDX(ID,s,k)];
      double base = (Hgamma - one) * rhok * eint[IDXE(s,k)];
      base = MAX(base, (double) (rhok * smallp));

      q[IDX(IP,s,k)] = base;
      c[IDXE(s,k)] = sqrt(Hgamma * base / rhok);

      CFLOPS(7);
    }
  }
}                               // equation_of_state
Exemplo n.º 6
0
void
compute_deltat (hydro_real_t *dt, const hydroparam_t H, hydrowork_t * Hw,
		hydrovar_t * Hv, hydrovarwork_t * Hvw)
{
  hydro_real_t cournox, cournoy;
  int j, jend, slices, Hstep, Hmin, Hmax;
  hydro_real_t (*e)[H.nxyt];
  hydro_real_t (*c)[H.nxyt];
  hydro_real_t (*q)[H.nxystep][H.nxyt];
  WHERE ("compute_deltat");

  //   compute time step on grid interior
  cournox = zero;
  cournoy = zero;
  //Hvw->q = (double (*)) calloc (H.nvar * H.nxystep * H.nxyt, sizeof (double));
  //Hw->e = (double (*)) malloc ((H.nxyt) * H.nxystep * sizeof (double));
  //Hw->c = (double (*)) malloc ((H.nxyt) * H.nxystep * sizeof (double));

  c = (hydro_real_t (*)[H.nxyt]) Hw->c;
  e = (hydro_real_t (*)[H.nxyt]) Hw->e;
  q = (hydro_real_t (*)[H.nxystep][H.nxyt]) Hvw->q;

  Hstep = H.nxystep;
  Hmin = H.jmin + ExtraLayer;
  Hmax = H.jmax - ExtraLayer;
  
  for (j = Hmin; j < Hmax; j += Hstep)
  {
      jend = j + Hstep;
      if (jend >= Hmax)
			jend = Hmax;
      slices = jend - j;	// numbre of slices to compute
      ComputeQEforRow (j, H.smallr, H.nx, H.nxt, H.nyt, H.nxyt, H.nvar,
		       slices, Hstep, Hv->uold, q, e);
		       
//#pragma acc update device (q[0:H.nvar], e[0:H.nxystep], c[0:H.nxystep])
      equation_of_state (0, H.nx, H.nxyt, H.nvar, H.smallc, H.gamma, slices, Hstep, e, q, c);

			//download everything on Host
      //#pragma acc update host (q[0:H.nvar],c[0:H.nxystep])
      courantOnXY (&cournox, &cournoy, H.nx, H.nxyt, H.nvar, slices, Hstep, c, q);
		   
		   
#ifdef FLOPS
      flops += 10;
#endif /*  */
    }
  //Free (Hvw->q);
  //Free (Hw->e);
  //Free (Hw->c);
  *dt =(hydro_real_t)( H.courant_factor * H.dx / MAX (cournox, MAX (cournoy, H.smallc)));
#ifdef FLOPS
  flops += 2;

#endif /*  */

  // fprintf(stdout, "%g %g %g %g\n", cournox, cournoy, H.smallc, H.courant_factor);
}				// compute_deltat
Exemplo n.º 7
0
void
// qleftright(const int idim, const hydroparam_t H, hydrovarwork_t * Hvw)
qleftright (const int idim,
            const int Hnx,
            const int Hny,
            const int Hnxyt,
            const int Hnvar,
            const int slices, const int Hstep,
            hydro_real_t *qxm, hydro_real_t *qxp, hydro_real_t *qleft, hydro_real_t *qright)
{
    //double qxm[Hnvar][Hstep][Hnxyt],
    //double qxp[Hnvar][Hstep][Hnxyt], double qleft[Hnvar][Hstep][Hnxyt], double qright[Hnvar][Hstep][Hnxyt]) {
    // #define IHVW(i,v) ((i) + (v) * Hnxyt)
    //int nvar, i, s;
    int bmax;
    WHERE ("qleftright");
    if (idim == 1)
    {
        bmax = Hnx + 1;
    }
    else
    {
        bmax = Hny + 1;
    }

#pragma acc kernels present(qxm[0:Hnvar*Hstep*Hnxyt], qxp[0:Hnvar*Hstep*Hnxyt]) present(qleft[0:Hnvar*Hstep*Hnxyt], qright[0:Hnvar*Hstep*Hnxyt])
    {

#ifdef GRIDIFY
#ifndef GRIDIFY_TUNE_PHI
#pragma hmppcg gridify(nvar*s,i)
#else
#pragma hmppcg gridify(nvar*s,i), blocksize 512x1
#endif
#endif /* GRIDIFY */
#ifndef GRIDIFY
#pragma acc loop independent
#endif /* !GRIDIFY */
        for (int nvar = 0; nvar < Hnvar; nvar++)
        {
#ifndef GRIDIFY
#pragma acc loop independent
#endif /* !GRIDIFY */
            for (int s = 0; s < slices; s++)
            {
#ifndef GRIDIFY
#pragma acc loop independent
#endif /* !GRIDIFY */
                for (int i = 0; i < bmax; i++)
                {
                    qleft[IDX (nvar, s, i)] = qxm[IDX (nvar, s, i + 1)];
                    qright[IDX (nvar, s, i)] = qxp[IDX (nvar, s, i + 2)];
                }
            }
        }
    }//kernels region
}
Exemplo n.º 8
0
Arquivo: main.cpp Projeto: CCJY/coliru
int main()
{
    int a[10] { 0, 1, -2, 3, -4, -5, 6, 7, -8, 9 };

    const auto negative = []( int i ) { return i<0 ; } ;
    WHERE( a, negative, 25 ) ;

    for( int i : a ) std::cout << i << ' ' ;
    std::cout << '\n' ;
}
Exemplo n.º 9
0
void
feeder(struct dpipe *source, struct FeederState *state)
{
    if (!state->file || feof(state->file))
	next_fragment(source, state);

    if (state->file) {
	{
	    char * const transfer = emalloc(BUFSIZ, WHERE(feeder));
	    const int count = efread(transfer, 1, BUFSIZ, state->file, WHERE(feeder));
	    
	    if (count > 0)
		dpipe_Put(source, transfer, count);
	    else
		dpipe_Close(source);
	}
    } else
	dpipe_Close(source);
}
Exemplo n.º 10
0
void
oclEquationOfState(long offsetIP, long offsetID, long imin, long imax, 
		   const real_t Hsmallc, const real_t Hgamma,
		   const int slices, const int Hnxyt,
		   cl_mem qDEV, cl_mem eintDEV, cl_mem cDEV)
{
  WHERE("equation_of_state");
  OCLSETARG11(ker[LoopEOS], qDEV, eintDEV, cDEV, offsetIP, offsetID, imin, imax, Hsmallc, Hgamma, slices, Hnxyt);
  oclLaunchKernel2D(ker[LoopEOS], cqueue, Hnxyt, slices, THREADSSZ, __FILE__, __LINE__);
}                               // equation_of_state
Exemplo n.º 11
0
void
oclComputeDeltat(double *dt, const hydroparam_t H, hydrowork_t * Hw, hydrovar_t * Hv, hydrovarwork_t * Hvw)
{
  long j;
  cl_mem uoldDEV, qDEV, eDEV, cDEV, courantDEV;
  double *lcourant;
  double maxCourant;
  long Hnxyt = H.nxyt;
  cl_int err = 0;
  long offsetIP = IHVW(0, IP);
  long offsetID = IHVW(0, ID);

  WHERE("compute_deltat");

  //   compute time step on grid interior

  // on recupere les buffers du device qui sont deja alloues
  oclGetUoldQECDevicePtr(&uoldDEV, &qDEV, &eDEV, &cDEV);

  lcourant = (double *) calloc(Hnxyt, sizeof(double));
  courantDEV = clCreateBuffer(ctx, CL_MEM_COPY_HOST_PTR | CL_MEM_READ_WRITE, Hnxyt * sizeof(double), lcourant, &err);
  oclCheckErr(err, "clCreateBuffer");

//     status = cudaMalloc((void **) &courantDEV, H.nxyt * sizeof(double));
//     VERIF(status, "cudaMalloc cuComputeDeltat");
//     status = cudaMemset(courantDEV, 0, H.nxyt * sizeof(double));
//     VERIF(status, "cudaMemset cuComputeDeltat");

  for (j = H.jmin + ExtraLayer; j < H.jmax - ExtraLayer; j++) {
    oclComputeQEforRow(j, uoldDEV, qDEV, eDEV, H.smallr, H.nx, H.nxt, H.nyt, H.nxyt);
    oclEquationOfState(qDEV, eDEV, cDEV, offsetIP, offsetID, 0, H.nx, H.smallc, H.gamma);
    // on calcule courant pour chaque cellule de la ligne pour tous les j
    oclCourantOnXY(courantDEV, H.nx, H.nxyt, cDEV, qDEV, H.smallc);
  }

  err = clEnqueueReadBuffer(cqueue, courantDEV, CL_TRUE, 0, H.nx * sizeof(double), lcourant, 0, NULL, NULL);

  int ic;
  double lmax = 0.;
  for (ic = 0; ic < H.nx; ic++) {
    lmax = fmax(lmax, lcourant[ic]);
  }

  // on cherche le max global des max locaux
  maxCourant = oclReduceMax(courantDEV, H.nx);
  // fprintf(stderr, "Courant=%lg (%lg)\n", maxCourant, lmax);
  *dt = H.courant_factor * H.dx / maxCourant;
  err = clReleaseMemObject(courantDEV);
  oclCheckErr(err, "clReleaseMemObject");
  free(lcourant);
  // exit(0);
  // fprintf(stdout, "%g %g %g %g\n", cournox, cournoy, H.smallc, H.courant_factor);
}                               // compute_deltat
Exemplo n.º 12
0
Arquivo: common.c Projeto: pauley/pcc
/*
 * nonfatal error message
 * the routine where is different for pass 1 and pass 2;
 * it tells where the error took place
 */
void
uerror(char *s, ...)
{
	va_list ap;

	va_start(ap, s);
	WHERE('u');
	vfprintf(stderr, s, ap);
	fprintf(stderr, "\n");
	va_end(ap);
	incerr();
}
Exemplo n.º 13
0
static void vbinom(long count, double n[], long lengthN,
				   double p[], long lengthP, double * rvec)
{
	long            i, iN, iP;
	long            incN = (lengthN == 1) ? 0 : 1;
	long            incP = (lengthP == 1) ? 0 : 1;
	WHERE("vbinom");
	
	for (i = iN = iP = 0; i < count; i++, iN += incN, iP += incP)
	{
		rvec[i] = ranbinom((long) n[iN], p[iP]);
	} /*for (i = 0; i < count; i++)*/
} /*vbinom()*/
Exemplo n.º 14
0
long interrupted(unsigned long tickIncrement)
{ /*WxWin and Macintosh version*/
#if (0)
	WHERE("interrupted");
#endif /*0*/

	if (INTERRUPT == INTNOTSET &&
		tickIncrement > 0 && timetocheck(tickIncrement))
	{
		myYield();
	}

	return (INTERRUPT);
} /*interrupted()*/
Exemplo n.º 15
0
Arquivo: common.c Projeto: pauley/pcc
/*
 * warning
 */
void
werror(char *s, ...)
{
	va_list ap;

	va_start(ap, s);
	WHERE('w');
	fprintf(stderr, "warning: ");
	vfprintf(stderr, s, ap);
	fprintf(stderr, "\n");
	va_end(ap);
	if (warniserr)
		incerr();
}
static void AppendD2D(sqlite3* db_p, hw_handler_dev_to_dev_next_fp_t dev_next_d2d_fp)
{
    int rc = SQLITE_OK;
    sqlite3_stmt *stmt = NULL;
    const char* src_name = NULL;
    const char* dst_name = NULL;
    char *command = NULL;
    const unsigned char* data = NULL;
    int ret;

    ALOG_INFO("%s ENTER", __func__);

    command = malloc(1024 * sizeof(char));
    while(dev_next_d2d_fp(&src_name, &dst_name) == 0) {
        UpdateD2DFlags(src_name, dst_name);
        memset(command, 0, 1024);
        sprintf(command, "SELECT Data FROM HW_Settings_Data_D2D WHERE Idx=(\
                    SELECT Idx_Data FROM HW_Settings_Combo_D2D WHERE (Codec = '%s') AND (Src='%s') AND (Dst='%s'))",
                codec_name_ab8500_p, src_name, dst_name);

        rc = sqlite3_prepare_v2(db_p, command, -1, &stmt, NULL);
        if (rc != SQLITE_OK) {
            ALOG_ERR("%s: ERROR: Unable to prepare SQL-statement!", __func__);
            goto cleanup;
        }

        if (sqlite3_step(stmt) != SQLITE_ROW)
            goto cleanup;

        data = sqlite3_column_text(stmt, 0);
        if (data == NULL) {
            ALOG_ERR("%s: ERROR: Data not found !\n", __func__);
            goto cleanup;
        }
        ret = audio_hal_alsa_set_controls_cfg((const char*)data);
        if (ret < 0) {
            ALOG_ERR("%s: ERROR: Failed to write HW-settings! ste_adm_hw_handler_alsa_set_controls returned %d.", __func__, ret);
            goto cleanup;
        }
        ALOG_INFO("%s: found Match src: %s, dst :%s \n %s\n", __func__, src_name, dst_name, data);
    }

cleanup:
    if (command != NULL) free(command);
    if (stmt != NULL) {
        sqlite3_finalize(stmt);
        stmt = NULL;
    }
}
Exemplo n.º 17
0
void
slope(const int n,
      const int Hnvar,
      const int Hnxyt,
      const real_t Hslope_type,
      const int slices, const int Hstep, real_t q[Hnvar][Hstep][Hnxyt], real_t dq[Hnvar][Hstep][Hnxyt]) {
  int nbv, i, ijmin, ijmax, s;
  // long ihvwin, ihvwimn, ihvwipn;
  // #define IHVW(i, v) ((i) + (v) * Hnxyt)

  WHERE("slope");
  ijmin = 0;
  ijmax = n;

  // #define OLDSTYLE

#pragma omp parallel for private(nbv, s, i) shared(dq) COLLAPSE
    for (s = 0; s < slices; s++) {
      for (nbv = 0; nbv < Hnvar; nbv++) {
#pragma ivdep
      for (i = ijmin + 1; i < ijmax - 1; i++) {
     	real_t dlft, drgt, dcen, dsgn, slop, dlim;
	int llftrgt = 0;
	real_t t1;
        dlft = Hslope_type * (q[nbv][s][i] - q[nbv][s][i - 1]);
        drgt = Hslope_type * (q[nbv][s][i + 1] - q[nbv][s][i]);
        dcen = half * (dlft + drgt) / Hslope_type;
        dsgn = (dcen > 0) ? (real_t) 1.0 : (real_t) -1.0;       // sign(one, dcen);
#ifdef OLDSTYLE
        slop = fmin(fabs(dlft), fabs(drgt));
        dlim = slop;
        if ((dlft * drgt) <= zero) {
          dlim = zero;
        }
        dq[nbv][s][i] = dsgn * fmin(dlim, fabs(dcen));
#else
        llftrgt = ((dlft * drgt) <= zero);
	t1 = fmin(fabs(dlft), fabs(drgt));
        dq[nbv][s][i] = dsgn * fmin((1 - llftrgt) * t1, fabs(dcen));
#endif
      }
    }
  }
  { 
    int nops = Hnvar * slices * ((ijmax - 1) - (ijmin + 1));
    FLOPS(8 * nops, 1 * nops, 6 * nops, 0 * nops);
  }
}                               // slope
Exemplo n.º 18
0
void
constoprim(const int n,
           const int Hnxyt,
           const int Hnvar,
           const real_t Hsmallr,
           const int slices, const int Hstep,
           real_t u[Hnvar][Hstep][Hnxyt], real_t q[Hnvar][Hstep][Hnxyt], real_t e[Hstep][Hnxyt]) {
  int ijmin, ijmax, IN, i, s;
  real_t eken;
  // const int nxyt = Hnxyt;
  WHERE("constoprim");
  ijmin = 0;
  ijmax = n;

#pragma omp parallel for private(i, s, eken), shared(q,e) COLLAPSE
  for (s = 0; s < slices; s++) {
    for (i = ijmin; i < ijmax; i++) {
      real_t qid = MAX(u[ID][s][i], Hsmallr);
      q[ID][s][i] = qid;

      real_t qiu = u[IU][s][i] / qid;
      real_t qiv = u[IV][s][i] / qid;
      q[IU][s][i] = qiu;
      q[IV][s][i] = qiv;

      eken = half * (Square(qiu) + Square(qiv));

      real_t qip = u[IP][s][i] / qid - eken;
      q[IP][s][i] = qip;
      e[s][i] = qip;
    }
  }
  { 
    int nops = slices * ((ijmax) - (ijmin));
    FLOPS(5 * nops, 3 * nops, 1 * nops, 0 * nops);
  }

  if (Hnvar > IP) {
    for (IN = IP + 1; IN < Hnvar; IN++) {
      for (s = 0; s < slices; s++) {
        for (i = ijmin; i < ijmax; i++) {
          q[IN][s][i] = u[IN][s][i] / q[IN][s][i];
        }
      }
    }
  }
}                               // constoprim
Exemplo n.º 19
0
void
oclCmpflx(cl_mem qgdnv, cl_mem flux, const long narray, const long Hnxyt, const long Hnvar, const double Hgamma)
{
  cl_int err = 0;
  dim3 gws, lws;
  cl_event event;
  double elapsk;

  WHERE("cmpflx");

  // SetBlockDims(narray, THREADSSZ, block, grid);
  oclMkNDrange(narray, THREADSSZ, NDR_1D, gws, lws);

  // Compute fluxes
  // Loop1KcuCmpflx <<< grid, block >>> (qgdnv, flux, narray, Hnxyt, Hgamma);
  oclSetArg(ker[Loop1KcuCmpflx], 0, sizeof(cl_mem), &qgdnv, __FILE__, __LINE__);
  oclSetArg(ker[Loop1KcuCmpflx], 1, sizeof(cl_mem), &flux, __FILE__, __LINE__);
  oclSetArg(ker[Loop1KcuCmpflx], 2, sizeof(narray), &narray, __FILE__, __LINE__);
  oclSetArg(ker[Loop1KcuCmpflx], 3, sizeof(Hnxyt), &Hnxyt, __FILE__, __LINE__);
  oclSetArg(ker[Loop1KcuCmpflx], 4, sizeof(Hgamma), &Hgamma, __FILE__, __LINE__);

  err = clEnqueueNDRangeKernel(cqueue, ker[Loop1KcuCmpflx], 1, NULL, gws, lws, 0, NULL, &event);
  oclCheckErr(err, "clEnqueueNDRangeKernel Loop1KcuCmpflx");
  err = clWaitForEvents(1, &event);
  oclCheckErr(err, "clWaitForEvents");
  elapsk = oclChronoElaps(event);
  err = clReleaseEvent(event);
  oclCheckErr(err, "clReleaseEvent");

  // Other advected quantities
  if (Hnvar > IP + 1) {
    // Loop2KcuCmpflx <<< grid, block >>> (qgdnv, flux, narray, Hnxyt, Hnvar);
    oclSetArg(ker[Loop2KcuCmpflx], 0, sizeof(cl_mem), &qgdnv, __FILE__, __LINE__);
    oclSetArg(ker[Loop2KcuCmpflx], 1, sizeof(cl_mem), &flux, __FILE__, __LINE__);
    oclSetArg(ker[Loop2KcuCmpflx], 2, sizeof(narray), &narray, __FILE__, __LINE__);
    oclSetArg(ker[Loop2KcuCmpflx], 3, sizeof(Hnxyt), &Hnxyt, __FILE__, __LINE__);
    oclSetArg(ker[Loop2KcuCmpflx], 4, sizeof(Hnvar), &Hnvar, __FILE__, __LINE__);
    err = clEnqueueNDRangeKernel(cqueue, ker[Loop2KcuCmpflx], 1, NULL, gws, lws, 0, NULL, &event);
    oclCheckErr(err, "clEnqueueNDRangeKernel Loop1KcuCmpflx");
    err = clWaitForEvents(1, &event);
    oclCheckErr(err, "clWaitForEvents");
    elapsk = oclChronoElaps(event);
    err = clReleaseEvent(event);
    oclCheckErr(err, "clReleaseEvent");
  }
}                               // cmpflx
Exemplo n.º 20
0
void MainTest::modifyPost()
{
    auto q = db.posts()->createQuery();
    q->setWhere(Post::idField() == postId);

    Post *post = q->first();

    QTEST_ASSERT(post != 0);

    post->setTitle("new name");
    db.saveChanges();

    q = FROM(db.posts())
            WHERE(Post::idField() == postId);

    post = q->first();
    QTEST_ASSERT(post->title() == "new name");
}
Exemplo n.º 21
0
void
deallocate_work_space(const hydroparam_t H, hydrowork_t * Hw, hydrovarwork_t * Hvw)
{
  WHERE("deallocate_work_space");

  Free(Hw->e);
  Free(Hvw->u);
  Free(Hvw->q);
  Free(Hvw->dq);
  Free(Hvw->qxm);
  Free(Hvw->qxp);
  Free(Hvw->qleft);
  Free(Hvw->qright);
  Free(Hvw->qgdnv);
  Free(Hvw->flux);
  Free(Hw->sgnm);
  Free(Hw->c);
}                               // deallocate_work_space
Exemplo n.º 22
0
void
allocate_work_space(const hydroparam_t H, hydrowork_t * Hw, hydrovarwork_t * Hvw)
{
  WHERE("allocate_work_space");

  Hvw->u = DMalloc(H.nxystep * H.arVarSz);
  Hvw->q = DMalloc(H.nxystep * H.arVarSz);
  Hvw->dq = DMalloc(H.nxystep * H.arVarSz);
  Hvw->qxm = DMalloc(H.nxystep * H.arVarSz);
  Hvw->qxp = DMalloc(H.nxystep * H.arVarSz);
  Hvw->qleft = DMalloc(H.nxystep * H.arVarSz);
  Hvw->qright = DMalloc(H.nxystep * H.arVarSz);
  Hvw->qgdnv = DMalloc(H.nxystep * H.arVarSz);
  Hvw->flux = DMalloc(H.nxystep * H.arVarSz);
  Hw->e = DMalloc(H.nxystep * H.arSz);
  Hw->c = DMalloc(H.nxystep * H.arSz);
  Hw->sgnm = IMalloc(H.nxystep * H.arSz);
}                               // allocate_work_space
Exemplo n.º 23
0
static void
next_fragment(struct dpipe *source, struct FeederState *state)
{
    char filename[PATH_MAX];
    if (state->file) {
	fclose(state->file);

	if (destructive && state->destructive) {
	    sprintf(filename, "%s/%u", state->directory, state->sequence);
	    unlink(filename);
	}
    }
    
    sprintf(filename, "%s/%u", state->directory, ++state->sequence);
  
    if (state->file = state->sequence == 1 ? efopen(filename, "r", WHERE(next_fragment)) : fopen(filename, "r"))
	if (state->sequence > 1) skip_headers(state->file);
}
Exemplo n.º 24
0
void
oclQleftright(const long idim, const long Hnx, const long Hny, const long Hnxyt,
                const long Hnvar, 
		const int slices, const int Hstep,
		cl_mem qxm, cl_mem qxp, cl_mem qleft, cl_mem qright)
{
  long bmax;

  WHERE("qleftright");
  if (idim == 1) {
    bmax = Hnx + 1;
  } else {
    bmax = Hny + 1;
  }
  OCLSETARG09(ker[Loop1KcuQleftright], bmax, Hnvar, Hnxyt, slices, Hstep, qxm, qxp, qleft, qright);
  // oclLaunchKernel2D(ker[Loop1KcuQleftright], cqueue, Hnxyt, slices, THREADSSZ, __FILE__, __LINE__);
  oclLaunchKernel3D(ker[Loop1KcuQleftright], cqueue, Hnxyt, slices, Hnvar, THREADSSZ, __FILE__, __LINE__);
}
Exemplo n.º 25
0
/* take care of floating point errors for Unix & DOS */
#ifdef SIGNALARG
void fpeRoutine(int sig)
#else /*SIGNALARG*/
void fpeRoutine(void)
#endif /*SIGNALARG*/
{
	long      screenheight = SCREENHEIGHT;
	WHERE("fpeRoutine");
	
	SCREENHEIGHT = 0; /* make sure output will not trigger new interrupt */

	putOutErrorMsg("ERROR: floating point exception");
	closeBatch(1); /* shut down all batch files */
	SCREENHEIGHT = screenheight;
	INTERRUPT = FPESET;
	
#ifdef SIGNALARG
	intRoutine(0);
#else /*SIGNALARG*/
	intRoutine();
#endif /*SIGNALARG*/
	/* no return */
} /*fpeRoutine()*/
Exemplo n.º 26
0
Arquivo: common.c Projeto: pauley/pcc
/*
 * compiler error: die
 */
void
cerror(char *s, ...)
{
	va_list ap;

	va_start(ap, s);
	WHERE('c');

	/* give the compiler the benefit of the doubt */
	if (nerrors && nerrors <= 30) {
		fprintf(stderr,
		    "cannot recover from earlier errors: goodbye!\n");
	} else {
		fprintf(stderr, "compiler error: ");
		vfprintf(stderr, s, ap);
		fprintf(stderr, "\n");
	}
	va_end(ap);
	EXIT(1);
}
Exemplo n.º 27
0
void MainTest::testDate()
{
    QDateTime d = QDateTime::currentDateTime();
    QTime t = QTime(d.time().hour(), d.time().minute(), d.time().second());
    d.setTime(t);

    Post *newPost = new Post;
    newPost->setTitle("post title");
    newPost->setSaveDate(d);

    db.posts()->append(newPost);

    db.saveChanges();

    auto q = FROM(db.posts())
            WHERE(Post::idField() == newPost->id())
            FIRST();

    qDebug() << d << q->saveDate();
    QTEST_ASSERT(q->saveDate() == d);
}
Exemplo n.º 28
0
void
oclSlope(cl_mem q, cl_mem dq, const long narray, const long Hnvar, const long Hnxyt, const double slope_type)
{
  long ijmin, ijmax;

  WHERE("slope");
  ijmin = 0;
  ijmax = narray;
  //   SetBlockDims(((ijmax - 1) - (ijmin + 1)) * Hnvar, THREADSSZ, block, grid);
  //   LoopKcuSlope <<< grid, block >>> (q, dq, Hnvar, Hnxyt, slope_type, ijmin, ijmax);
  //   CheckErr("LoopKcuSlope");
  //   cudaThreadSynchronize();
  OCLINITARG;
  OCLSETARG(ker[LoopKcuSlope], q);
  OCLSETARG(ker[LoopKcuSlope], dq);
  OCLSETARG(ker[LoopKcuSlope], Hnvar);
  OCLSETARG(ker[LoopKcuSlope], Hnxyt);
  OCLSETARG(ker[LoopKcuSlope], slope_type);
  OCLSETARG(ker[LoopKcuSlope], ijmin);
  OCLSETARG(ker[LoopKcuSlope], ijmax);
  oclLaunchKernel(ker[LoopKcuSlope], cqueue, ((ijmax - 1) - (ijmin + 1)) * Hnvar, THREADSSZ, __FILE__, __LINE__);
}                               // slope
Exemplo n.º 29
0
void
slope(const int n,
      const int Hnvar,
      const int Hnxyt,
      const double Hslope_type,
      const int slices, const int Hstep, double *q, double *dq) {
  //const int slices, const int Hstep, double q[Hnvar][Hstep][Hnxyt], double dq[Hnvar][Hstep][Hnxyt]) {
  int nbv, i, ijmin, ijmax, s;
  double dlft, drgt, dcen, dsgn, slop, dlim;
  // long ihvwin, ihvwimn, ihvwipn;
  // #define IHVW(i, v) ((i) + (v) * Hnxyt)

  WHERE("slope");
  ijmin = 0;
  ijmax = n;

#pragma acc parallel pcopyin(q[0:Hnvar*Hstep*Hnxyt]) pcopy(dq[0:Hnvar*Hstep*Hnxyt])
#pragma acc loop gang collapse(2)
  for (nbv = 0; nbv < Hnvar; nbv++) {
    for (s = 0; s < slices; s++) {
#pragma acc loop vector
      for (i = ijmin + 1; i < ijmax - 1; i++) {
        dlft = Hslope_type * (q[IDX(nbv,s,i)] - q[IDX(nbv,s,i - 1)]);
        drgt = Hslope_type * (q[IDX(nbv,s,i + 1)] - q[IDX(nbv,s,i)]);
        dcen = half * (dlft + drgt) / Hslope_type;
        dsgn = (dcen > 0) ? (double) 1.0 : (double) -1.0;       // sign(one, dcen);
        slop = fmin(fabs(dlft), fabs(drgt));
        dlim = slop;
        if ((dlft * drgt) <= zero) {
          dlim = zero;
        }
        dq[IDX(nbv,s,i)] = dsgn * fmin(dlim, fabs(dcen));
#ifdef FLOPS
        flops += 8;
#endif
      }
    }
  }
}                               // slope
Exemplo n.º 30
0
/* take care of SIGINT for Unix & DOS */
#ifdef SIGNALARG
void intRoutine(int sig)
#else /*SIGNALARG*/
void intRoutine(void)
#endif /*SIGNALARG*/
{
	long     screenheight = SCREENHEIGHT;
	WHERE("intRoutine");
	
	SCREENHEIGHT = 0; /* make sure any output will not trigger new interrupt */

#if (0)
	if(GUBED & 65536 && INTWHERE[RDEPTH] != (char *) 0)
	{
		PRINT("INTWHERE[%ld] = %s\n", RDEPTH, INTWHERE[RDEPTH],0,0);
	}
#endif /*0*/

	if(INTERRUPT == INTNOTSET)
	{ /* actual interrupt */
		SCREENHEIGHT = 0; /* make sure output will not trigger new interrupt */
		myeol();
		myeol();
		putOutMsg("  *** INTERRUPT ***");
		myeol();
		SCREENHEIGHT = screenheight;
		INTERRUPT = INTSET;
		closeBatch(1); /* shutdown all batch files */
	}
	SCREENHEIGHT = screenheight;
	NLINES = 0;
	/* 
	  It is the responsibility of each function that sets up RestartBuf
	  to increment and decrement RDEPTH.  This should be automatic if
	  macros SETUPINT and RETURN are used.
	  [comment is a fossil]
	*/
	longjmp(RestartBuf[RDEPTH], 0);
} /*intRoutine()*/