Exemplo n.º 1
0
static int
vtbe_attach(device_t dev)
{
	uint8_t macaddr[ETHER_ADDR_LEN];
	struct vtbe_softc *sc;
	struct ifnet *ifp;
	int reg;

	sc = device_get_softc(dev);
	sc->dev = dev;

	sc->hdrsize = sizeof(struct virtio_net_hdr_mrg_rxbuf);

	if (bus_alloc_resources(dev, vtbe_spec, sc->res)) {
		device_printf(dev, "could not allocate resources\n");
		return (ENXIO);
	}

	/* Memory interface */
	sc->bst = rman_get_bustag(sc->res[0]);
	sc->bsh = rman_get_bushandle(sc->res[0]);

	mtx_init(&sc->mtx, device_get_nameunit(sc->dev),
	    MTX_NETWORK_LOCK, MTX_DEF);

	if (setup_offset(dev, &sc->beri_mem_offset) != 0)
		return (ENXIO);
	if (setup_pio(dev, "pio-send", &sc->pio_send) != 0)
		return (ENXIO);
	if (setup_pio(dev, "pio-recv", &sc->pio_recv) != 0)
		return (ENXIO);

	/* Setup MMIO */

	/* Specify that we provide network device */
	reg = htobe32(VIRTIO_ID_NETWORK);
	WRITE4(sc, VIRTIO_MMIO_DEVICE_ID, reg);

	/* The number of desc we support */
	reg = htobe32(DESC_COUNT);
	WRITE4(sc, VIRTIO_MMIO_QUEUE_NUM_MAX, reg);

	/* Our features */
	reg = htobe32(VIRTIO_NET_F_MAC |
			VIRTIO_NET_F_MRG_RXBUF |
    			VIRTIO_F_NOTIFY_ON_EMPTY);
	WRITE4(sc, VIRTIO_MMIO_HOST_FEATURES, reg);

	/* Get MAC */
	if (vtbe_get_hwaddr(sc, macaddr)) {
		device_printf(sc->dev, "can't get mac\n");
		return (ENXIO);
	}

	/* Set up the ethernet interface. */
	sc->ifp = ifp = if_alloc(IFT_ETHER);
	ifp->if_baudrate = IF_Gbps(10);
	ifp->if_softc = sc;
	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
	ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX |
			 IFF_MULTICAST | IFF_PROMISC);
	ifp->if_capabilities = IFCAP_VLAN_MTU;
	ifp->if_capenable = ifp->if_capabilities;
	ifp->if_start = vtbe_txstart;
	ifp->if_ioctl = vtbe_ioctl;
	ifp->if_init = vtbe_init;
	IFQ_SET_MAXLEN(&ifp->if_snd, DESC_COUNT - 1);
	ifp->if_snd.ifq_drv_maxlen = DESC_COUNT - 1;
	IFQ_SET_READY(&ifp->if_snd);
	ifp->if_hdrlen = sizeof(struct ether_vlan_header);

	/* All ready to run, attach the ethernet interface. */
	ether_ifattach(ifp, macaddr);

	sc->is_attached = true;

	return (0);
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
int meascount;
int prompt;
Real avm_iters,avs_iters;

double ssplaq,stplaq;


double starttime,endtime;
double dtime;

int MinCG,MaxCG;
Real size_r,RsdCG;

register int i,j,l;
register site *s;

int spinindex,spin,color,k,kk,t;
int flag;
int ci,si,sf,cf;
int num_prop;
Real space_vol;

int status;

int source_chirality;

    wilson_vector **eigVec ;
    double *eigVal ;
    int total_R_iters ;
    double norm;
    Real re,im,re5,im5;
    complex cc;
    char label[20] ;

    double *grad, *err, max_error;
  Matrix Array,V ;

int key[4];
#define restrict rstrict /* C-90 T3D cludge */
int restrict[4];

Real norm_fac[10];

static char *mes_kind[10] = {"PION","PS505","PS055","PS0505",
		"RHO33","RHO0303","SCALAR","SCALA0","PV35","B12"};
static char *bar_kind[4] = {"PROTON","PROTON0","DELTA","DELTA0"};

complex *pmes_prop[MAX_MASSES][10];
complex *smes_prop[MAX_MASSES][10];
complex *bar_prop[MAX_MASSES][4];

w_prop_file *fp_in_w[MAX_MASSES];        /* For propagator files */
w_prop_file *fp_out_w[MAX_MASSES];       /* For propagator files */

    initialize_machine(&argc,&argv);

  /* Remap standard I/O */
  if(remap_stdio_from_args(argc, argv) == 1)terminate(1);

    g_sync();
    /* set up */
    prompt = setup_p();
    /* loop over input sets */


    while( readin(prompt) == 0)
    {



	starttime=dclock();
	MaxCG=niter;

	avm_iters=0.0;
	meascount=0;



	if(this_node==0)printf("END OF HEADER\n");
	setup_offset();

/*
if(this_node==0)printf("warning--no fat link\n");
*/
	monte_block_ape_b(1);
                /* call plaquette measuring process */
                d_plaquette(&ssplaq,&stplaq);
                if(this_node==0)printf("FATPLAQ  %e %e\n",
                    (double)ssplaq,(double)stplaq);




/* flip the time oriented fat links 
if(this_node==0) printf("Periodic time BC\n");
*/
if(this_node==0) printf("AP time BC\n");
boundary_flip(MINUS);





	setup_links(SIMPLE);

/*	if(this_node==0) printf("num_masses = %d\n", num_masses); */
	/* Loop over mass */
	for(k=0;k<num_masses;k++){

	  m0=mass[k];
	if(m0 <= -10.0) exit(1);
	  RsdCG=resid[k];
	  if(this_node==0)printf("mass= %g r0= %g residue= %g\n",
		(double)m0,(double)wqs[k].r0,(double)RsdCG);
	  build_params(m0);
	  make_clov1();


                eigVal = (double *)malloc(Nvecs*sizeof(double));
                eigVec = (wilson_vector **)malloc(Nvecs*sizeof(wilson_vector*));
                for(i=0;i<Nvecs;i++)
                  eigVec[i]=
                    (wilson_vector*)malloc(sites_on_node*sizeof(wilson_vector));


          /* open files for wilson propagators */
          fp_in_w[k]  = r_open_wprop(startflag_w[k], startfile_w[k]);
          fp_out_w[k] = w_open_wprop(saveflag_w[k],  savefile_w[k],
				     wqs[k].type);


                    if(startflag_w[k] == FRESH)flag = 0;
                    else
                      flag = 1;
spin=color=0; /* needed by wilson writing routines */




		/* initialize the CG vectors */
		    if(flag==0){
if(this_node==0) printf("random (but chiral) initial vectors\n");
  /* Initiallize all the eigenvectors to a random vector */
  for(j=0;j<Nvecs;j++)
    {
      if(j< Nvecs/2){ source_chirality=1;}
      else{source_chirality= -1;}
      printf("source chirality %d\n",source_chirality);
      grsource_w();
      FORALLSITES(i,s){
        copy_wvec(&(s->g_rand),&(eigVec[j][i]));
	if(source_chirality==1){
	  for(kk=2;kk<4;kk++)for(l=0;l<3;l++)
	    eigVec[j][i].d[kk].c[l]=cmplx(0.0,0.0);
	}

	if(source_chirality== -1){
	  for(kk=0;kk<2;kk++)for(l=0;l<3;l++)
	    eigVec[j][i].d[kk].c[l]=cmplx(0.0,0.0);
	}
      }
      eigVal[j]=1.0e+16;
    }
		    }
		    else{
if(this_node==0) printf("reading in %d wilson_vectors--must be <= 12\n",Nvecs);
                    /* load psi if requested */
for(j=0;j<Nvecs;j++){
printf("reading %d %d %d\n",j,spin,color);
#ifdef IOTIME
                    status = reload_wprop_sc_to_site( startflag_w[k], fp_in_w[k], 
                                      spin, color, F_OFFSET(psi),1);
#else
                    status = reload_wprop_sc_to_site( startflag_w[k], fp_in_w[k], 
                                      spin, color, F_OFFSET(psi),0);
#endif

		    /* compute eigenvalue */
		    herm_delt(F_OFFSET(psi),F_OFFSET(chi));

		  re=im=0.0;
		  FORALLSITES(i,s){
		    cc = wvec_dot( &(s->chi), &(s->psi) );
		    re += cc.real ;
		  }
		  g_floatsum(&re);
		  eigVal[j]=re;
printf("trial eigenvalue of state %d %e\n",j,eigVal[j]);
		  FORALLSITES(i,s){eigVec[j][i]=s->psi;}
spin++;
if((spin %4) == 0){spin=0;color++;}
}

		    }
Exemplo n.º 3
0
void foo(void)
{
  __builtin_unwind_init ();
  setup_offset();
  __builtin_eh_return (offset, handler);
}