Beispiel #1
0
int main( int argc , char **argv )
{

	unsigned long cliaddr;
	unsigned short cliport;
	
	int ufd , nfd;

	fprintf( stderr, "start\n");

	uinit(INADDR_ANY);
	fprintf( stderr, "inited\n");	
	ufd = usocket_serv( 8 );
	fprintf( stderr, "socketd %d\n", ufd );
	ulisten( ufd );
	fprintf( stderr, "listened\n");
	while(1){
		int r =uproc();
/*		fprintf( stderr, "uproced %d\n" , r);*/
		nfd = uaccept( ufd , &cliaddr ,&cliport);
		if( nfd >= 0 ){
			fprintf( stderr, "accepted! nfd:%d %x %d\n" , nfd ,cliaddr , ntohs(cliport) );
			break;
		}
	}
	while(1){
		int r = uproc();
		
		fprintf( stderr,"." );

		if( ureadable( nfd ) ){
			char buffer[800];
			int r;
			fprintf( stderr, "REadable!!\n");
			bzero( buffer ,sizeof(buffer));
			if( (r = uread( nfd, buffer , sizeof( buffer ) )) >= 0 ){
				int wr;
				fprintf( stderr , "ReadData %d: [%s]\n" ,r, buffer );
				wr = uwrite( nfd , buffer , r );
				fprintf( stderr ,"Wrote %dbytes\n",wr );
				
			}
		}
		
		usleep(100*1000);

	}
	

	
}
Beispiel #2
0
static void bootstrap()
{
	const int moduleClock = 60000000;
	const int KHzInHz = 1000;
	const int baud = 115200;
	mcgInit();
	sdramInit();
	svcInit_SetSVCPriority(7);
	uartInit(UART2_BASE_PTR, moduleClock/KHzInHz, baud);
	lcdcInit();
	lcdcConsoleInit(&console);
	adc_init();
	vfs_init();
	ledInitAll();
	pushbuttonInitAll();
	TSI_Init();
	TSI_Calibrate();
	init_memory();
	uinit();
	privUnprivileged();
}
Beispiel #3
0
void main(void){

  uinit();							// uart initialisierung

 
  uputs((unsigned char*)"\nBoot");

  while (mmc_init() !=0){ 		//ist der Rückgabewert ungleich NULL ist ein Fehler aufgetreten	
	;	
	}  
	
  uputs((unsigned char*)"... ");		

  if(0==fat_initfat()){				//ist der Rückgabewert ungleich NULL ist ein Fehler aufgetreten	

	 uputs((unsigned char*)"Ok\n");		// wenn auf dem terminal "Boot... OK" zu lesen ist, ist init ok. jetzt kann man schreiben/lesen
	
    beispiele();
  }


}
Beispiel #4
0
/* initialize hardware */
void
init(void)
{
  led_init();
  ledon();

  strobo_init();
  strobooff();

  door_init();
  doordisengage();

  ring_init();

  /* timer initialization
   *
   * CTC mode
   * clocked from system clock
   * prescaler /1024
   * compare value 10
   *
   * this gives about 100 Hz at 1 MHz system clock
   *
   * we also enable the compare match interrupt
   * 
   */
  TCNT2 =  0;
  OCR2  = 10;
  TCCR2 = _BV(WGM21)|_BV(CS22)|_BV(CS21)|_BV(CS20);
  TIMSK = _BV(OCIE2);

  /* initialize usart */
  uinit(9600);

  /* enable interrupts */
  sei();
}
Beispiel #5
0
int main(int argc,char** argv)
{

	int myrank=0,nprocs=1;
	int latsize[4],localsize[4];
	int netSize[16],netPos[16],netDim;
	int i,j,t,npIn,nsite;
	int Niter = QCD_NITER;
	QCDSpinor* pSrc;
	QCDSpinor* pDest;
	QCDMatrix* pGauge;

	QCDReal Enorm = QCD_ENORM;
	QCDReal Cks = QCD_CKS;
	QCDReal* pCorr;
	double tstart,tend,ttotal;
	char* pStr;
	int ItimeS,NtimeS,ics,ids,is,ie,ipet,it,Nconv,cnt;
	double CorrF,Diff,rr;
	unsigned long flops;
	double tt;

	latsize[0] = 0;
	latsize[1] = 0;
	latsize[2] = 0;
	latsize[3] = 0;

	netDim = 4;
	netSize[0] = 0;
	netSize[1] = 0;
	netSize[2] = 0;
	netSize[3] = 0;

	for(i=1;i<argc;i++){
		if(argv[i][0] == 'L'){
			t = 0;
			for(j=1;j<strlen(argv[i]);j++){
				if(argv[i][j] == 'x'){
					t++;
				}
				else if(argv[i][j] >= '0' && argv[i][j] <= '9'){
					latsize[t] = 10*latsize[t] + (int)(argv[i][j] - '0');
				}
			}
		}
		else if(argv[i][0] == 'P'){
			t = 0;
			for(j=1;j<strlen(argv[i]);j++){
				if(argv[i][j] == 'x'){
					t++;
				}
				else if(argv[i][j] >= '0' && argv[i][j] <= '9'){
					netSize[t] = 10*netSize[t] + (int)(argv[i][j] - '0');
				}
			}
		}
	}

	t = 0;
	for(i=0;i<4;i++){
		if(latsize[0] == 0){
			t++;
		}
	}
	if(t > 0){
		latsize[0] = QCD_NX;
		latsize[1] = QCD_NY;
		latsize[2] = QCD_NZ;
		latsize[3] = QCD_NT;
	}

	MPI_Init(&argc,&argv);

	MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
	MPI_Comm_rank(MPI_COMM_WORLD,&myrank);

	npIn = 1;
	for(i=0;i<4;i++){
		npIn *= netSize[i];

		//debug
		/* printf("netSize[%d] == %d\n", i, netSize[i]); */

	}
	if(npIn != nprocs){
		if(myrank == 0){
			printf("Number of processes is invalid\n");
		}
		return 0;
	}

	nsite = 1;
	for(i=0;i<4;i++){
		localsize[i] = latsize[i] / netSize[i];
		nsite *= localsize[i];
	}

	t = myrank;
	for(i=0;i<4;i++){
		netPos[i] = t % netSize[i];
		t /= netSize[i];
	}

	QCDDopr_Init(localsize[0],localsize[1],localsize[2],localsize[3],netSize[0],netSize[1],netSize[2],netSize[3],myrank);

	if(myrank == 0){
		printf("=============================================\n");
		printf("QCD base MPI program\n");
		printf("          Lattice size = %dx%dx%dx%d\n",latsize[0],latsize[1],latsize[2],latsize[3]);
		printf("Decomposed by %d procs : %dx%dx%dx%d\n",nprocs,netSize[0],netSize[1],netSize[2],netSize[3]);
		printf("    Local Lattice size = %dx%dx%dx%d\n",localsize[0],localsize[1],localsize[2],localsize[3]);
		printf("\n Cks = %f\n",Cks);
		printf("=============================================\n");
	}

	//debug
	/* printf("xxx\n"); */

	pGauge = (QCDMatrix*)malloc(sizeof(QCDMatrix) * 4 * nsite + 512);
	uinit((double*)pGauge,latsize[0],latsize[1],latsize[2],latsize[3]);

	//debug
	/* printf("xxx\n"); */

	pSrc = (QCDSpinor*)malloc(sizeof(QCDSpinor) * nsite + 128);
	pDest = (QCDSpinor*)malloc(sizeof(QCDSpinor) * nsite + 128);

	pCorr = (QCDReal*)malloc(sizeof(QCDReal) * latsize[3]);
	for(i=0;i<latsize[3];i++){
		pCorr[i] = 0.0;
	}

	ttotal = 0.0;
	/* for(ics=0;ics<QCD_NCOL;ics++){ */
	/* 	for(ids=0;ids<QCD_ND;ids++){ */
	for(ics=0;ics<1;ics++){
		for(ids=0;ids<1;ids++){
			set_src(ids,ics,pSrc,0);

			MPI_Barrier(MPI_COMM_WORLD);
			tstart = mysecond();
			Solve_CG(pDest,pGauge,pSrc,Cks,Enorm,&Nconv,&Diff);
			MPI_Barrier(MPI_COMM_WORLD);
			tend = mysecond() - tstart;
			ttotal += tend;

			if(myrank == 0){
				printf(" %3d %3d  %6d %12.4e ... %f sec\n", ics, ids, Nconv, Diff,tend);
			}

			for(i=0;i<latsize[3];i++){
				ipet = i/localsize[3];
				it = i % localsize[3];
				if(ipet == netPos[3]){
					is = it*localsize[0]*localsize[1]*localsize[2];
					QCDLA_Norm(&CorrF,pDest + is,localsize[0]*localsize[1]*localsize[2]);
				}
				else{
					CorrF = 0.0;
				}
				MPI_Allreduce(&CorrF,&rr,1,MPI_DOUBLE_PRECISION,MPI_SUM,MPI_COMM_WORLD);
				pCorr[i] = pCorr[i] + rr;
			}
		}
    }

	if(myrank == 0){

		printf("\nPs meson correlator:\n");
		for(i=0;i<latsize[3];i++){
			printf("%d: %0.8E\n",i,pCorr[i]);
		}

		printf("\n Avg. Solver Time = %f [sec]\n",ttotal / 12);
	}

	MPI_Barrier(MPI_COMM_WORLD);


	//debug
	/* printf("finish\n"); */


	return 0;
}
Beispiel #6
0
int main(int argc, char *argv[]) {
	uinit();
	wchar_t *text = ureadtext(argv[1]);
	wprintf(L"text=%s", text);
}
 ~remote_block_input_iterator()
 {
   uinit();
 }
 ~remote_block_output_iterator()
 {
   uinit();
 }
Beispiel #9
0
void runShell(int argc,char *argv[])
{
	uinit();
	process_input();
}