Пример #1
0
int line_solve(Puzzle *puz, Solution *sol, int contradicting)
{
    extern dir_t cont_dir;
    extern line_t cont_line;
    dir_t dir;
    line_t i;
    int depth;

    while (next_job(puz, &dir, &i, &depth))
    {
        nlines++;
        if ((VB && !VC) || WL(dir,i))
            printf("*** %s %d\n",CLUENAME(puz->type,dir), i);
        if (VB || WL(dir,i))
            dump_line(stdout,puz,sol,dir,i);

        if (contradicting && depth >= contradepth)
        {
            /* At max depth we just check if the line is solvable */
            line_t *pos, *bcl;
            if (!left_solve(puz, sol, dir, i, 0, &pos, &bcl))
            {
                if ((VC&&VV) || WL(dir,i))
                    printf("C: %s %d OK AT DEPTH %d\n",
                           cluename(puz->type,dir),i,depth);
            }
            else
            {
                if ((VC&&VV) || WL(dir,i))
                    printf("C: %s %d FAILED AT DEPTH %d\n",
                           cluename(puz->type,dir),i,depth);
                if (contradicting) {
                    cont_dir= dir;
                    cont_line= i;
                }
                return 0;
            }
        }
        else if (apply_lro(puz, sol, dir, i, depth + 1))
        {
            /* Found a contradiction */
            if (contradicting) {
                cont_dir= dir;
                cont_line= i;
            }
            return 0;
        }

        if (VJ)
        {
            printf("CURRENT JOBS:\n");
            dump_jobs(stdout,puz);
        }
    }
    return 1;
}
Пример #2
0
void add_job(Puzzle *puz, dir_t k, line_t i, int depth, int bonus)
{
    Job *job;
    int priority;
    int j, par;

    /* Check if it is already on the job list */
    if ((j= puz->clue[k][i].jobindex) >= 0)
    {
        if (VJ || WL(puz->clue[k][i]))
            printf(" J: JOB ON %s %d ALREADY ON JOBLIST\n",
                   CLUENAME(puz->type,k),i);

        /* Increase the priority of the job, bubbling it up the heap if
         * necessary
         */

        puz->job[j].priority+= 4 + 25*bonus;
        if (puz->job[j].depth > depth) puz->job[j].depth= depth;

        while (j > 1 && puz->job[par= j/2].priority < puz->job[j].priority)
        {
            job_exchange(puz, j, par);
            j= par;
        }

        return;
    }

    /* Give higher priority to things on the edge */
    priority= abs(puz->n[k]/2 - i) + 25*bonus - 10*depth;


    if (VJ || WL(puz->clue[k][i]))
        printf(" J: JOB ON %s %d ADDED TO JOBLIST DEPTH %d PRIORITY %d\n",
               CLUENAME(puz->type,k),i,depth,priority);

    /* Bubble things down until we find the spot to insert the new key */
    j= ++puz->njob;
    while (j > 1 && puz->job[par= j/2].priority < priority)
    {
        job_move(puz, j, par);
        j= par;
    }

    /* Insert the new key */
    puz->clue[k][i].jobindex= j;
    job= &puz->job[j];
    job->priority= priority;
    job->depth= depth;
    job->dir= k;
    job->n= i;
}
Пример #3
0
void GEMENI_charsent() {
	unsigned long r = s->log[s->lc];
	if (UCA0IFG & UCTXIFG) {
		s->nch++;
		switch (s->nch) {
			case 1:
				UCA0TXBUF = SL(r) << 5 |TL(r)<<4|KL(r)<<3|PL(r)<<2|WL(r)<<1|HL(r);
			break;
			case 2:
				UCA0TXBUF = RL(r)<<6 | AL(r)<<5 | OL(r)<<4 | STAR(r)<<3;
			break;
			case 3:
				UCA0TXBUF = ER(r)<<3 | UR(r)<<2 | FR(r)<<1 | RR(r);
			break;
			case 4:
				UCA0TXBUF = PR(r)<<6 | BR(r)<<5 | LR(r)<<4 | GR(r)<<3 | TR(r)<<2 | SR(r)<<1 | DRS(r);
			break;
			case 5:
				UCA0TXBUF = POUND(r)<<1 | ZRS(r);
			break;
			default:
				s->lc++;
				if (s->lc != s->nc-1) {

  					s->nch = 0;
  					UCA0TXBUF = 1 << 7; // first packet, no fn or '#'
				} else {
					s->flags &= ~CSEND;
				}

		}
	}
}
Пример #4
0
void add_jobs(Puzzle *puz, Solution *sol, int except, Cell *cell,
              int depth, bit_type *old)
{
    dir_t k;
    line_t i, j;
    int lwork, rwork;

    /* While probing, we OR all bits set into our scratchpad.  These values
     * should not be probed on later during this sequence.
     */
    if (probing)
        fbit_or(propad(cell),cell->bit);

    if (!maylinesolve) return;

    for (k= 0; k < puz->nset; k++)
        if (k != except)
        {
            i= cell->line[k];
            j= cell->index[k];

            /* We only add the job only if either the saved left or right
             * solution for the line has been invalidated.
             */
            if (VL || WL(puz->clue[k][i]))
                printf ("L: CHECK OLD SOLN FOR %s %d CELL %d\n",
                        CLUENAME(puz->type,k),i,j);
            lwork= left_check(&puz->clue[k][i], j, cell->bit);
            rwork= right_check(&puz->clue[k][i], j, cell->bit);
            if (lwork || rwork)
            {
                add_job(puz, k, i, depth,
                        newedge(puz, sol->line[k][i], j, old, cell->bit) );

                if (!VJ && WL(puz->clue[k][i]))
                    dump_jobs(stdout,puz);
            }
        }
}
Пример #5
0
void init_poll()
{
  reg[1]=0x10;
  reg[2]=0;
  QLtrap(1,0x18,2000000l);
  
  if (*reg==0)
    {
      Ptr p=(Ptr)theROM+aReg[0];
      p = p + 4;
      
      WL( p, POLL_CMD_ADDR);
      WW((Ptr)theROM+POLL_CMD_ADDR, POLL_CMD_CODE);
      
      QLtrap(1,0x1c,200000l);
    }
}
Пример #6
0
int SoundContext::TickStreams(ALDriver &driver)
{
	int numBusy = 0;

	ReadLock L(m_m);

	for (Source::List::const_iterator it = m_streams.begin(); it != m_streams.end();) {
		Source *s = *it; ++it; // we may unmap this and invalidate it
		RAD_ASSERT(s->stream);
		Sound::StreamResult r = s->sound->TickStream(*s);
		if (r == Sound::kStreamResult_Finished) {
			UpgradeToWriteLock WL(m_m);
			UnmapSource(*s);
			s->doNotify = true;
		} else if (r == Sound::kStreamResult_Decoding) {
			++numBusy;
		}
	}

	return numBusy;
}
Пример #7
0
int SymbolType::getSymbol(const char *s){
    if(strlen(s)>MAXSYMBOLLEN)
        throw RUNT("ex$symbol","").set("symbol too long: %s",s);
    
    int n;
    
    // unpleasant - see
    // https://groups.google.com/forum/#!topic/comp.programming.threads/QsJI57oQZKc
    WriteLock l=WL(Types::tSymbol);
    
    if(locations.find(s)){
        n=locations.found();
    } else {
        n = symbolCtr;
        locations.set(s,symbolCtr++);
        SymbolName *ss = strings.set(n);
        strcpy(ss->s,s);
    }
    
    return n;
}
Пример #8
0
static void InitDevDriver(struct DRV *driver, int indx)
{
  w32	savedRegs[4];
  w32	*p;
  char  *name=(driver->namep)->name;

  BlockMoveData(aReg,savedRegs,4*sizeof(w32));
  reg[1]=40+strlen(name);
  if((strlen(name)&1)!=0) reg[1]++;

  if (driver->slot != 0)
    {
      if(driver->slot <reg[1])
	{
	  printf("requested driver size for driver %s too small: %d\n",*name,driver->slot);
	  goto ddier;
	}
      reg[1]=driver->slot;
    }
  
  reg[2]=0;
  QLtrap(1,0x18,200000l);		/* allocate memory for the driver linkage block */
  if((*reg)==0)
    {
      driver->ref=aReg[0];
      p=(w32*)(aReg[0]+(Ptr)theROM+4);
      WL(p,DEV_IO_ADDR);       /* io    */
      WL(p+1,(w32) ((Ptr)(p+3)-(Ptr)theROM));             /* open  */
      WL(p+2,DEV_CLOSE_ADDR);  /* close */

      WW(p+3,DEVO_CMD_CODE);

      strcpy((Ptr)(p+6)+4,name);      /* name for QPAC2 etc */
      WW((Ptr)(p+3+3)+2,strlen(name));
      WL((Ptr)(p+3)+2,0x264f4eba);    /* so much code is needed to fool QPAC2 ...*/
      WL((Ptr)(p+4)+2,0x2c566046);
      WL((Ptr)(p+5)+2,0x6044604a);


      if ((*(driver->init))(indx,p-1) <0)
	goto ddier;

      QLtrap(1,0x20,20000l);	/* link directory device driver in IOSS */
    }
 ddier:
  BlockMoveData(savedRegs,aReg,4*sizeof(w32));
}
Пример #9
0
void SoundContext::Tick(float dt, bool positional)
{
	if (m_alDriver->suspended)
		return;
	
	if (m_time[1] > 0.f) {
		m_time[0] += dt;
		if (m_time[0] >= m_time[1]) {
			m_volume[0] = m_volume[2];
			m_time[1] = 0.f;
		} else {
			m_volume[0] = math::Lerp(m_volume[1], m_volume[2], m_time[0]/m_time[1]);
		}
	}

	{
		if (m_volume[3] != m_volume[0]) {
			m_volume[3] = m_volume[0];
			m_alDriver->Listenerf(ALDRIVER_SIG AL_GAIN, m_volume[0]);
		}

		if (m_pos[1] != m_pos[0]) {
			m_pos[1] = m_pos[0];
			m_alDriver->Listener3f(ALDRIVER_SIG AL_POSITION, m_pos[0][0], m_pos[0][1], m_pos[0][2]);
		}

		if (m_vel[1] != m_vel[0]) {
			m_vel[1] = m_vel[0];
			m_alDriver->Listener3f(ALDRIVER_SIG AL_VELOCITY, m_vel[0][0], m_vel[0][1], m_vel[0][2]);
		}

		if (m_rot[1] != m_rot[0]) {
			m_rot[1] = m_rot[0];
			Vec3 fwd(1, 0, 0);
			Mat4 m = Mat4::Rotation(m_rot[0]);
			fwd = fwd * m;

			Vec3 up, left;
			fwd.FrameVecs(up, left);

			float f[6] = {
				fwd[0], fwd[1], fwd[2],
				 up[0],  up[1],  up[2]
			};

			m_alDriver->Listenerfv(ALDRIVER_SIG AL_ORIENTATION, f);
		}
	}

	Source::StackPtrVec callbacks;

	for (int i = 0; i < SC_Max; ++i) {
		Channel &channel = m_channels[i];

		if (channel.time[1] > 0.f) {
			channel.time[0] += dt;
			if (channel.time[0] >= channel.time[1]) {
				channel.time[1] = 0.f;
				channel.volume[0] = channel.volume[2];
			} else {
				channel.volume[0] = math::Lerp(channel.volume[1], channel.volume[2], channel.time[0]/channel.time[1]);
			}
		}

		Source::Map &map = channel.sources;

		ReadLock L(m_m);

		for (Source::Map::iterator it = map.begin(); it != map.end(); ++it) {
			Source::List &list = it->second;
			
			for (Source::List::iterator it = list.begin(); it != list.end();) {
				Source *source = *it;
				RAD_ASSERT(source&&source->sound);

				if (!source->paused && source->play && !source->stream) {
					m_alDriver->SourcePlay(ALDRIVER_SIG source->source);
					source->play = false;
					source->status = AL_PLAYING;
				}

				if (source->sound->Tick(dt, channel, *source, positional)) {
					UpgradeToWriteLock WL(m_m);
					Source::List::iterator next = it; ++next;
					list.erase(it);
					it = next;
					source->mapped = false;
					m_sources[source->priority].erase(source->it[1]);
					if (source->notify)
						callbacks->push_back(source);
					RAD_ASSERT(m_numSources>0);
					--m_numSources;
				} else {
					++it;
				}
			}
		}
	}

	// completion callbacks

	for(Source::StackPtrVec::const_iterator it = callbacks->begin(); it != callbacks->end(); ++it) {
		Source *source = *it;
		Notify::Ref r = source->notify;
		source->notify.reset();
		r->OnComplete(*source->sound);
	}

	// m_streams is modified by ALDriver thread
	ReadLock L(m_m);
	for (Source::List::const_iterator it = m_streams.begin(); it != m_streams.end(); ++it) {
		Source *s = *it;
		if (s->doNotify) {
			s->doNotify = false;
			if (s->notify) {
				s->notify->OnComplete(*s->sound);
				s->notify.reset();
			}
		}
	}
}
Пример #10
0
void InitROM(void)
{
  w32 saved_regs[16];
  char qvers[6];
  char *initstr="UQLX v%s, release\012      %s\012QDOS Version %s\012";
  long sysvars,sxvars;



	if((long)((Ptr)gPC-(Ptr)theROM)-2 != ROMINIT_CMD_ADDR)
	{	exception=4;
		extraFlag=true;
		return;
	}
#if 0
	printf("a6=%x, basic at %x\n",aReg[6],ReadLong(0x28010));
#endif	

	save_regs(saved_regs);

	do_update=1;  /* flip in screen RAM */

#ifdef OLD_PATCH
	/* lea $0C000,a3 */
	aReg[3]=0x0c000;
	gPC+=2;
#else
#warning UNUSED OLD_PATCH
	WW((Ptr)gPC-2,0x0c93);   /* restore original instruction */
#endif
#if 0	
	KillSound();
	CloseSerial();
	InitSerial();
	ZeroKeyboardBuffer();
#endif


	/* delete old MDV drivers (for optical reasons) */
	WriteLong(0x28048,0);

	InitFileDrivers();
	InitDrivers();

#ifdef XSCREEN
	/*printf("call init_xscreen\n");*/
	init_xscreen();
#else
#warning UNUSED XSCREEN
#endif


	SchedInit();

	init_bas_exts();

	QLtrap(1,0,20000l);
#if 0
	printf("QDOS vars at %x, trap res=%d, RTOP=%d\n",aReg[0],reg[0],RTOP);
#endif

	sysvars=aReg[0];
	sxvars=RL((Ptr)theROM+sysvars+0x7c);
#if 0
	if (isMinerva)
	  printf("Minerva extended vars at %x\n",sxvars);
#endif
	if (V3)
	  printf("sysvars at %x, ux RAMTOP %d, sys.ramt %d, qlscreen at %d\n",
		 sysvars,RTOP,sysvar_l(20),qlscreen.qm_lo);

	// QDOS version
	WL((Ptr)qvers,reg[2]);qvers[4]=0;
       
#if 0
	p=(Ptr)theROM+RTOP-0x07FFEl;
	sprintf(p,initstr,uqlx_version,release,qvers);
	WriteWord(aReg[1]=RTOP-0x08000l,strlen(p));	

#if 1
	QLvector(0xd0,200000);
#else
	WriteLong((*sp)-=4,(w32)gPC-(w32)theROM);
	gPC=(uw16*)((Ptr)theROM+RW((uw16*)((Ptr)theROM+0xd0)));	/* write string */
#endif
#endif

	/*HACK: allow breakpoints in ROM*/
#if DEBUG_ROM
	RamMap[0]=RamMap[1]=RamMap[2]=3;
	uqlx_protect(0,3*32768,QX_RAM);
#endif
	/* now install TKII defaults */

	reg[1]=0x6c;
	reg[2]=0;
	QLtrap(1,0x18,200000);
	if(reg[0]==0){
	  if (V3)printf("Initialising TK2 device defaults\n");
	  WriteLong(0x28070+0x3c,aReg[0]);
	  WriteLong(0x28070+0x40,32+aReg[0]);
	  WriteLong(0x28070+0x44,64+aReg[0]);
	  WriteWord(aReg[0],strlen(DATAD));strcpy((char*)((Ptr)theROM+aReg[0]+2),DATAD);
	  WriteWord(aReg[0]+32,strlen(PROGD));strcpy((char*)((Ptr)theROM+aReg[0]+34),PROGD);
	  WriteWord(aReg[0]+64,strlen(SPOOLD));strcpy((char*)((Ptr)theROM+aReg[0]+66),SPOOLD);
	}
	
	/* link in Minerva keyboard handling */
#if 1
	if (isMinerva)
	  {
	    reg[1]=8;
	    reg[2]=0;
	    QLtrap(1,0x18,200000);
	    if(reg[0]==0)
	      {
		WW((Ptr)theROM+MIPC_CMD_ADDR,MIPC_CMD_CODE);
		WL((Ptr)theROM+aReg[0],RL((Ptr)theROM+sxvars+0x14));
		WL((Ptr)theROM+aReg[0]+4,MIPC_CMD_ADDR);
		WL((Ptr)theROM+sxvars+0x14,aReg[0]);
	      }
	    WW((Ptr)theROM+KBENC_CMD_ADDR,KBENC_CMD_CODE);
	    orig_kbenc=RL((Ptr)theROM+sxvars+0x10);
	    WL((Ptr)theROM+sxvars+0x10,KBENC_CMD_ADDR); 
#if 0
	    printf("orig_kbenc=%x\nreplacement kbenc=%x\n",orig_kbenc,KBENC_CMD_ADDR); 
	    printf("sx_kbenc addr=%x\n",sxvars+0x10);
#endif
	}
#endif	

	init_poll();
	
	/* make sure it wasn't changed somewhere */
	restore_regs(saved_regs);
#ifdef OLD_PATCH
	aReg[3]=0x0c000;
#endif

#ifndef OLD_PATCH
	table[code=0x0c93]();    /* run the original routine */
#endif

}
Пример #11
0
/*
 * The mixing of read and write locks is not allowed:
 */
static void rlock_AA2(void)
{
	RL(X1);
	WL(X2); // this one should fail
}
static void rlock_AA3(void)
{
	WL(X1);
	RL(X2); 
}
static void rlock_AA2(void)
{
	RL(X1);
	WL(X2); 
}
Пример #14
0
static const struct workload workloads[] = {
	WLA(createwrite, size),
	WLA(rewrite, size),
	WLA(randupdate, size),
	WLA(truncwrite, size),
	WLA(makehole, size),
	WLA(fillhole, size),
	WLA(truncfill, size),
	WLA(append, size),
	WLA(trunczero, size),
	WLA(trunconeblock, size),
	WLA(truncsmallersize, size),
	WLA(trunclargersize, size),
	WLA(appendandtrunczero, size),
	WLA(appendandtruncpartly, size),
	WL(mkfile),
	WL(mkdir),
	WL(mkmanyfile),
	WL(mkmanydir),
	WL(mktree),
	WLA(mkrandtree, seed),
	WL(rmfile),
	WL(rmdir),
	WL(rmfiledelayed),
	WL(rmfiledelayedappend),
	WL(rmdirdelayed),
	WL(rmmanyfile),
	WL(rmmanyfiledelayed),
	WL(rmmanyfiledelayedandappend),
	WL(rmmanydir),
	WL(rmmanydirdelayed),
Пример #15
0
	WL getWL() const {
		return WL(getOrigLit(), getWeight());
	}
Пример #16
0
inline void DEP_CURRENT_2D
(double * const current, int const * const size, int const * const offset, 
 double * const norm, t_vpbuf2D * const part)
{
        
  typedef struct Current { double j1, j2, j3; } t_current;
  t_current *pjpart, *p0; 
  
  dvec j3[NP][NP];
  

  dvec vwp1[NP], vwp2[NP]; 
  dvec vwl1[ORDER], vwl2[ORDER];
  
  __m128d vx0, vx1, vy0, vy1, vq, vvz;
  
  DECLARE_ALIGNED_16( int ix[4] );
  DECLARE_ALIGNED_16( int iy[4] );

		  
  __m128d vqnx, vqny, vqvz;
  __m128d vs0x[NP], vs1x[NP], vs0y[NP], vs1y[NP]; 

  int np;
  int i, k, k1, k2;

  __m128d const oneThird = _mm_set1_pd( 1.0/3.0 );

  const int Dy = size[0];
  t_current* const pj = (t_current *) (current + ( offset[0] - OFFSET ) * 3 + 
                                                 ( offset[1] - OFFSET ) * 3 * Dy );


  __m128d const vnorm1 = _mm_set1_pd(norm[0]);
  __m128d const vnorm2 = _mm_set1_pd(norm[1]);
  
  np = part -> np;
  
  // If number of particles in buffer is not multiple of 2 add dummy particles to the end

  if ( np % 2 != 0 ) {
    for( i = 0; i < 2 - np%2; i ++ ) {
       t_vp2D * vpt = ((t_vp2D *) part -> p) + i;
       
       vpt -> x0 = vpt -> x1 = 0.;
       vpt -> y0 = vpt -> y1 = 0.;
       vpt -> q  = vpt -> vz = 0.;
       vpt -> ix = vpt -> iy  = 1;
    }
  }

  double* vp = (double *) part -> buf;

  for( i = 0; i < np; i+=2, vp+=16 ) {

    // load 2 particles
    LOAD2VP2D( vp, vx0, vx1, vy0, vy1, vq, vvz, ix, iy );
    
    // Get splines    
    SPLINE( vx0, vs0x );
    SPLINE( vx1, vs1x );
    SPLINE( vy0, vs0y );
    SPLINE( vy1, vs1y );
    
    vqnx = _mm_mul_pd( vq, vnorm1);
    vqny = _mm_mul_pd( vq, vnorm2);
    vqvz = _mm_mul_pd( vq, vvz);
    vqvz = _mm_mul_pd( vqvz, oneThird );

 
    // get longitudinal weights
    WL( vqnx, vx0, vx1, (__m128d *) vwl1 );
    WL( vqny, vy0, vy1, (__m128d *) vwl2 );

    // get perpendicular weights
    for( k = 0; k < NP; k++ ) {
      vwp1[k].v2 = _mm_add_pd(vs0y[k], vs1y[k]);
      vwp2[k].v2 = _mm_add_pd(vs0x[k], vs1x[k]);
    }
     
    // get j3 current
    for( k2 = 0; k2 < NP; k2++ ) {
      for ( k1 = 0; k1 < NP; k1++ ) {
        __m128d const oneHalf  = _mm_set1_pd( 0.5 );
        __m128d tmp1, tmp2;
  		
		tmp1 = _mm_add_pd( _mm_mul_pd( vs0x[k1], vs0y[k2] ), _mm_mul_pd( vs1x[k1], vs1y[k2] ) );
		tmp2 = _mm_add_pd( _mm_mul_pd( vs0x[k1], vs1y[k2] ), _mm_mul_pd( vs1x[k1], vs0y[k2] ) );

		j3[k1][k2].v2 = _mm_mul_pd( vqvz, _mm_add_pd( tmp1, _mm_mul_pd( tmp2, oneHalf ) ) );
      }
    }

    // New version loop by particle on the outside loop
    for ( k = 0; k < 2; k ++ ) {

      pjpart = pj + ix[k] + iy[k] * Dy;

	  // accumulate j1
	  for( k2 = 0; k2 < NP; k2++ ) {
		p0 = pjpart + k2*Dy;
		for ( k1 = 0; k1 < ORDER; k1++ ) {
		  p0[k1].j1 += vwl1[k1].v[k] * vwp1[k2].v[k];
		}
	  }
  
	  // accumulate j2 - making k2 the outside loop gives marginal perf. gain
	  for( k2 = 0; k2 < ORDER; k2++ ) {
		p0 = pjpart + k2*Dy;
		for ( k1 = 0; k1 < NP; k1++ ) {
		   p0[k1].j2 += vwl2[k2].v[k] * vwp2[k1].v[k];
		}
	  }
  
	  // accumulate j3
	  for( k2 = 0; k2 < NP; k2++ ) {
		p0 = pjpart + k2*Dy;
		for ( k1 = 0; k1 < NP; k1++ ) {
		   p0[k1].j3 += (j3[k1][k2]).v[k];
		}
	  }
	  
    }
	  
  }
}
Пример #17
0
inline void DEP_CURRENT_3D
(double * const  current, int const * const  size, int const * const  offset,
                       double * const norm, t_vpbuf3D * const part)
{
        
  typedef struct Current { double j1, j2, j3; } t_current;
  t_current *pjpart, *p0; 
  
  dvec vwl1[ORDER], vwl2[ORDER], vwl3[ORDER];
  dvec vwp1[NP][NP], vwp2[NP][NP], vwp3[NP][NP];
  
  __m128d vx0, vx1, vy0, vy1,  vz0, vz1, vq; 
  DECLARE_ALIGNED_16( int ix[4] );
  DECLARE_ALIGNED_16( int iy[4] );
  DECLARE_ALIGNED_16( int iz[4] );
  
  __m128d vqnx, vqny, vqnz;
  __m128d vs0x[NP], vs1x[NP], vs0y[NP], vs1y[NP], vs0z[NP], vs1z[NP]; 
  
  
  int np;
  int i, k, k1, k2, k3;
  
  int const Dy = size[0];    
  int const Dz = Dy * size[1]; 
  
  t_current* const pj = (t_current *) ( current + ( offset[0] - OFFSET ) * 3 + 
                                                  ( offset[1] - OFFSET ) * 3 * Dy + 
                                                  ( offset[2] - OFFSET ) * 3 * Dz );

  __m128d const vnorm1 = _mm_set1_pd(norm[0]);
  __m128d const vnorm2 = _mm_set1_pd(norm[1]);
  __m128d const vnorm3 = _mm_set1_pd(norm[2]);
  
  np = part -> np;
  
  // If number of particles in buffer is not multiple of 2 add dummy particles to the end
  if ( np % 2 != 0 ) {
    for( i = 0; i < 2 - np%2; i ++ ) {
       t_vp3D * vpt = (t_vp3D *) part -> p + i;
       
       vpt -> x0 = vpt -> x1 = 0.;
       vpt -> y0 = vpt -> y1 = 0.;
       vpt -> z0 = vpt -> z1 = 0.;
       vpt -> q = 0.;
       vpt -> ix = vpt -> iy = vpt -> iz = 1;
    }
  }

  double* vp = (double *) part -> buf;

  for( i = 0; i < np; i += 2, vp += 2 * 10 ) {
      
	// load 2 particles
    LOAD2VP3D( vp, vx0, vx1, vy0, vy1, vz0, vz1, vq, ix, iy, iz );

    // Get spline weights
    SPLINE( vx0, vs0x );
    SPLINE( vx1, vs1x );
    SPLINE( vy0, vs0y );
    SPLINE( vy1, vs1y );
    SPLINE( vz0, vs0z );
    SPLINE( vz1, vs1z );
    
    vqnx = _mm_mul_pd( vq, vnorm1);
    vqny = _mm_mul_pd( vq, vnorm2);
    vqnz = _mm_mul_pd( vq, vnorm3);
    
    // get longitudinal weights
    WL( vqnx, vx0, vx1, (__m128d *) vwl1 );
    WL( vqny, vy0, vy1, (__m128d *) vwl2 );
    WL( vqnz, vz0, vz1, (__m128d *) vwl3 );

    
    // get perpendicular weights
    for( k2 = 0; k2 < NP; k2++ ) {
      for( k1 = 0; k1 < NP; k1++ ) {
		 __m128d tmp1, tmp2;        
		 const __m128d oneHalf = _mm_set1_pd(0.5);
         
         // wp1[k2][k1] = s0y[k1]*s0z[k2] + s1y[k1]*s1z[k2] + 
         //               0.5*( s0y[k1]*s1z[k2] + s1y[k1]*s0z[k2] )
         
         tmp1 =  _mm_add_pd( _mm_mul_pd( vs0y[k1], vs0z[k2]), _mm_mul_pd( vs1y[k1], vs1z[k2]));
         tmp2 =  _mm_add_pd( _mm_mul_pd( vs0y[k1], vs1z[k2]), _mm_mul_pd( vs1y[k1], vs0z[k2]));
         vwp1[k2][k1].v2 = _mm_add_pd( tmp1, _mm_mul_pd( tmp2, oneHalf));

         tmp1 =  _mm_add_pd( _mm_mul_pd( vs0x[k1], vs0z[k2]), _mm_mul_pd( vs1x[k1], vs1z[k2]));
         tmp2 =  _mm_add_pd( _mm_mul_pd( vs0x[k1], vs1z[k2]), _mm_mul_pd( vs1x[k1], vs0z[k2]));
         vwp2[k2][k1].v2 = _mm_add_pd( tmp1, _mm_mul_pd( tmp2, oneHalf));

         tmp1 =  _mm_add_pd( _mm_mul_pd( vs0x[k1], vs0y[k2]), _mm_mul_pd( vs1x[k1], vs1y[k2]));
         tmp2 =  _mm_add_pd( _mm_mul_pd( vs0x[k1], vs1y[k2]), _mm_mul_pd( vs1x[k1], vs0y[k2]));
         vwp3[k2][k1].v2 = _mm_add_pd( tmp1, _mm_mul_pd( tmp2, oneHalf));

      }
    }
    
    // loop by particle on the outside loop
    for ( k = 0; k < 2; k ++ ) {
       
       pjpart = pj + ix[k] + iy[k] * Dy + iz[k] * Dz;
          
	   // accumulate j1
	   for( k3 = 0; k3 < NP; k3++ ) {
		 for( k2 = 0; k2 < NP; k2++ ) {
		   p0 = pjpart + k2*Dy + k3*Dz;
		   for ( k1 = 0; k1 < ORDER; k1++ ) {
			  p0[k1].j1 += vwl1[k1].v[k] * vwp1[k3][k2].v[k];
		   }
		 }
	   }
   
	   // accumulate j2
	   for( k3 = 0; k3 < NP; k3++ ) {
		 for( k2 = 0; k2 < ORDER; k2++ ) {
		   p0 = pjpart + k2*Dy + k3*Dz;
		   for ( k1 = 0; k1 < NP; k1++ ) {
			 p0[k1].j2 += vwl2[k2].v[k] * vwp2[k3][k1].v[k];
		   }
		 }
	   }
   
	   
	   // accumulate j3
	   for( k3 = 0; k3 < ORDER; k3++ ) {
		 for( k2 = 0; k2 < NP; k2++ ) {
		   p0 = pjpart + k2*Dy + k3*Dz;
		   for ( k1 = 0; k1 < NP; k1++ ) {
			 p0[k1].j3  += vwl3[k3].v[k] * vwp3[k2][k1].v[k];
		   }
		 }
	   }

    }

  }
}
Пример #18
0
int undo(Puzzle *puz, Solution *sol, int leave_branch)
{
    Hist *h;
    Clue *clue;
    Cell **line;
    dir_t k;
    int is_branch;
    line_t i;

    while (puz->nhist > 0)
    {
        h= HIST(puz, puz->nhist-1);

        /* Invalidate any saved positions for lines crossing undone cell.
         * We can't just have the fact that nhist < stamp mean the line is
         * invalid, because we might backtrack and then advance past stamp
         * again before we recheck the line.
         */
        for (k= 0; k < puz->nset; k++)
        {

            i= h->cell->line[k];
            clue= &(puz->clue[k][i]);
            line= sol->line[k][i];

            if ((VL && VU) || WL(*clue))
                printf("U: CHECK %s %d", CLUENAME(puz->type,k),i);

            left_undo(puz, clue, line, h->cell->index[k], h->bit);
            right_undo(puz, clue, line,  h->cell->index[k], h->bit);

            if ((VL && VU) || WL(*clue)) printf("\n");
        }

        is_branch= h->branch;

        if (!is_branch || !leave_branch)
        {
            /* If undoing a solved cell, decrement completion count */
            if (h->cell->n == 1) solved_a_cell(puz, h->cell, -1);

            /* Restore saved value */
            h->cell->n= h->n;
            fbit_cpy(h->cell->bit, h->bit);

            if (VU || WC(h->cell))
            {
                printf("U: UNDOING CELL ");
                for (k= 0; k < puz->nset; k++)
                    printf(" %d",h->cell->line[k]);
                printf(" TO ");
                dump_bits(stdout,puz,h->cell->bit);
                printf(" (%d)\n",h->cell->n);
            }

            puz->nhist--;
        }

        if (is_branch)
            return 0;
    }
    return 1;
}
Пример #19
0
void dosignal()
{
  uw32 t;
  
  doPoll=0;

#if 0 /*VTIME*/
  if (poll_req>1)
    printf("poll_req=%d in dosignal()\n",poll_req);
#endif
  
#ifdef SOUND
  if (delay_list)
    qm_sound();
#endif

#ifndef XAW
  if (!script && !QLdone)
    process_events();
#endif

#ifdef SHOWINTS
  aa_cnt+=alrm_count;
  alrm_count=0;
  if (++a_ticks>49)
    {
      printf("received %d alarm signals, processed %d\n",aa_cnt,a_ticks);
      a_ticks=aa_cnt=0;
    }
#endif
    
  if(--scrcnt<0)
    {
      /*scrcnt=5;*/  /* update screen at least every so much ticks */
      doscreenflush=1;

#if 1
      set_rtc_emu();
#else 
      mprotect((Ptr)theROM+0x18000,pagesize,PROT_READ | PROT_WRITE);
      GetDateTime(&t);
      /*WriteByte(0x18021,theInt);*/
      WL((Ptr)theROM+0x18000,t);
      mprotect((Ptr)theROM+0x18000,pagesize,PROT_NONE);
#endif
    }

  if (flptest++>25)
    {
      flptest=0;
      TestCloseDevs();
      process_ipc();
    }
  
#if 0
  pendingInterrupt=2; /* cause 50 Hz interrupt */
  theInt=1<<(7-4);
  extraFlag=true;
  nInst2=nInst;
  nInst=0;
#else
#ifndef xx_VTIME
  FrameInt(); 
#endif
#endif
}
Пример #20
0
static void rlock_AA3(void)
{
	WL(X1);
	RL(X2); // this one should fail
}
Пример #21
0
void SymbolType::deleteAll(){
    WriteLock l=WL(Types::tSymbol);
    locations.clear();
    strings.clear();
}