コード例 #1
0
void mips1::init(int ac, char *av[]) {
  extern char* appfilename;
  initCache();
  ac_init_opt( ac, av);
  ac_init_app( ac, av);
  APP_MEM->load(appfilename);
  set_args(ac_argc, ac_argv);
#ifdef AC_VERIFY
  set_queue(av[0]);
#endif

  ac_pc = ac_start_addr;
  ISA._behavior_begin();
  cerr << "ArchC: -------------------- Starting Simulation --------------------" << endl;
  InitStat();

  hazard_count = 0;
  memset(hazard_count_by_type, 0, sizeof(hazard_count_by_type));

  signal(SIGINT, sigint_handler);
  signal(SIGTERM, sigint_handler);
  signal(SIGSEGV, sigsegv_handler);
  signal(SIGUSR1, sigusr1_handler);
#ifdef USE_GDB
  signal(SIGUSR2, sigusr2_handler);
#endif
#ifndef AC_COMPSIM
  set_running();
#else
  void Execute(int argc, char *argv[]);
  Execute(argc, argv);
#endif
}
コード例 #2
0
ファイル: mips1.cpp プロジェクト: erimaroli/mc723-ex4
void mips1::init() {
  set_args(ac_argc, ac_argv);
#ifdef AC_VERIFY
  set_queue(av[0]);
#endif

  ISA._behavior_begin();
  cerr << "ArchC: -------------------- Starting Simulation --------------------" << endl;
  InitStat();

  signal(SIGINT, sigint_handler);
  signal(SIGTERM, sigint_handler);
  signal(SIGSEGV, sigsegv_handler);
  signal(SIGUSR1, sigusr1_handler);
#ifdef USE_GDB
  signal(SIGUSR2, sigusr2_handler);
#endif
#ifndef AC_COMPSIM
  set_running();
#else
  ac_pc = 0;
  void Execute(int argc, char *argv[]);
  Execute(argc, argv);
#endif
}
コード例 #3
0
ファイル: mdt.cpp プロジェクト: yingjinqian/Lustre-Simulator
void MDT::Start()
{
	Print(NOW"%s is starting...\n", now, name);
	InitStat();
	Server::Start();
	handler = Handle;
}
コード例 #4
0
ファイル: archc.cpp プロジェクト: AmlaanKar96/ArchC
//Initialize simulation
void ac_initialize()
{
#ifdef USE_GDB
  if (gdbstub && !gdbstub->is_disabled()) 
    gdbstub->connect();
#endif /* USE_GDB */
  ac_pc = ac_start_addr;
  ac_begin::behavior();
  cerr << "ArchC: -------------------- Starting Simulation --------------------" << endl;
  InitStat();
  signal(SIGINT, sigint_handler);
  signal(SIGTERM, sigint_handler);
  signal(SIGSEGV, sigsegv_handler);
  signal(SIGUSR1, sigusr1_handler);
#ifdef USE_GDB
  signal(SIGUSR2, sigusr2_handler);
#endif
}
コード例 #5
0
ファイル: GaussTerminal.c プロジェクト: mikelehu/IRK-Code
int main()
{

/*------ declarations --------------------------------------------------*/    

     int i;   
	
     gauss_method gsmethod,gsmethod2;
     solution u,u2;
     toptions options,options2;
     parameters params;
     ode_sys system;   
     solver_stat thestat,thestat2;

     clock_t clock0, clock1; 
     time_t  wtime0,wtime1;

     params.rpar =(val_type *)malloc(MAXPARAM*sizeof(val_type));
     params.ipar =(int *)malloc(MAXPARAM*sizeof(int));

     u.uu = (val_type *)malloc(MAXNEQ*sizeof(val_type));
     u.ee = (val_type *)malloc(MAXNEQ*sizeof(val_type));
     u2.uu = (val_type *)malloc(MAXNEQ*sizeof(val_type));
     u2.ee = (val_type *)malloc(MAXNEQ*sizeof(val_type));

     options.rtol=malloc(MAXNEQ*sizeof(val_type));
     options.atol=malloc(MAXNEQ*sizeof(val_type));
  
#    if PREC ==2  //QUADRUPLEPRECISION
     int n;
     int width = 46;
     char buf[128];
#    endif

/* ----------- implementation  ---------------------------------------*/     


/* ----------- integration parameters---------------------------------*/  

     gsmethod.ns = 6;     				 //	 Stages.
     options.h = POW(2,-7);	       			 //	 Stepsize. 
     options.sampling=1;   			 	 //      

     system.f = Ode1;					 //	 Odefun (GaussUserProblem.c: OdePendulum,OdeNBody)
     system.ham= Ham1;					 //      Hamiltonian (GaussUserProblem.c: HamPendulum,HamNBody)

     system.problem =1; 				 //	 Initial values (GaussInitData.c).

     options.approximation=1;   			 //      Approximation: Y^[0] (GaussCommon.c/Yi_init()).
	
     strncpy(thestat.filename, "AllSolve1.bin",STRMAX);   //     Output filename.

     options.algorithm=1;    				 //	 1=Jacobi;  11=Seidel;    
     options.rdigits=0;       
     options2.rdigits=3;

/* ----------- execution  ------------------------------------------*/

     printf("Begin execution \n");
     printf("method=%i, problem=%i, algorithm=%i\n",gsmethod.ns,system.problem,options.algorithm);
     printf("approximation=%i,sampling=%i\n",options.approximation,options.sampling);

#if PREC ==2  //QUADRUPLEPRECISION
     printf("options.h=");
     n = quadmath_snprintf(buf, sizeof buf, "%+-#*.30Qe", width, options.h);
     if ((size_t) n < sizeof buf) printf("%s\n",buf);
#else         //DOUBLEPRECISION
     printf("options.h=%lg\n", options.h);        
#endif 
     printf("----------------\n");
        
     InitialData (&options,&u,&params,&system);                 
     system.params.rpar=&params.rpar[0];
     system.params.ipar=&params.ipar[0];
     
     for (i=0; i<system.neq; i++)
     {
          options.rtol[i]=RTOL;
          options.atol[i]=ATOL;
     }

     if (options.rdigits>0) options.mrdigits=pow(2,options.rdigits);
     if (options2.rdigits>0) options2.mrdigits=pow(2,options2.rdigits);

     GaussCoefficients(&gsmethod,&options);
   
     InitStat(&system,&gsmethod,&thestat);	
   

     print_u(system.neq, u.uu);

     wtime0= time(NULL);
     clock0= clock();

     select_gauss(&gsmethod, &gsmethod2, &u, &u2,&system,
                  &options, &options2, &thestat, &thestat2);
  
     clock1=clock();
     wtime1= time(NULL);

     printf("End execution \n");
        
     if (thestat.convergence==SUCCESS)
     {
           printf("Execution Correct\n");
           printf("convergence=%i.  (=0 correct;=-1 incorrect)\n",thestat.convergence);        

           print_u (system.neq,u.uu);
#if PREC ==2  //QUADRUPLEPRECISION
           printf("Max-DE");
           n = quadmath_snprintf(buf, sizeof buf, "%+-#*.30Qe", width, thestat.MaxDE);
           if ((size_t) n < sizeof buf) printf("%s\n",buf);
#else  // DOUBLEPRECISION    
           printf("Energy MaxDE=%.20lg\n",thestat.MaxDE);
#endif                      

           printf ("\nCPU time:%lg\n", (double) (clock1 - clock0)/CLOCKS_PER_SEC);
	   printf ("Elapsed wall clock time: %ld\n", (wtime1 - wtime0));
           printf ("Elapsed wall clock time: %lg\n", difftime(wtime1, wtime0));

           printf("\n");
           
           printf("stepcount=%i\n",thestat.stepcount);
           printf("nout=%i\n",thestat.nout);
           
           printf("fixed-point iterations=%i\n",thestat.totitcount);
           printf("max fixed-point iterations=%i\n",thestat.maxitcount);        
           printf("deltaZero iterations=%i\n",thestat.itzero); 
 
           printf("\n");

           printf ("function ebaluations\n");
           printf("fcn=%i\n",thestat.fcn);
           printf ("\n");

     }
     else
     {
           printf("Execution InCorrect\n");
           printf("convergence=%i.  (=0 correct;=-1 incorrect)\n",thestat.convergence);
     }
 
     free(params.rpar); free(params.ipar);
     free(u.uu); free(u.ee);
     free(u2.uu); free(u2.ee);
    
     exit(0);

}
コード例 #6
0
ファイル: nftrack.c プロジェクト: SiSGroup/hap4nfsen
int main( int argc, char **argv ) {
struct stat stat_buff;
char c, *wfile, *rfile, *Rfile, *Mdirs, *ffile, *filter, *timeslot, *DBdir;
char datestr[64];
int ffd, ret, DBinit, AddDB, GenStat, AvStat, output_mode;
unsigned int lastupdate, topN;
data_row *port_table;
time_t	when;
struct tm * t1;

	wfile = rfile = Rfile = Mdirs = ffile = filter = DBdir = timeslot = NULL;
	DBinit = AddDB = GenStat = AvStat = 0;
	lastupdate = output_mode = 0;
	topN = 10;
	while ((c = getopt(argc, argv, "d:hln:pr:st:w:AIM:R:SV")) != EOF) {
		switch (c) {
			case 'h':
				usage(argv[0]);
				exit(0);
				break;
			case 'I':
				DBinit = 1;
				break;
			case 'M':
				Mdirs = strdup(optarg);
				break;
			case 'R':
				Rfile = strdup(optarg);
				break;
			case 'd':
				DBdir = strdup(optarg);
				ret  = stat(DBdir, &stat_buff);
				if ( !(stat_buff.st_mode & S_IFDIR) ) {
					fprintf(stderr, "No such directory: %s\n", DBdir);
					exit(255);
				}
				break;
			case 'l':
				lastupdate = 1;
				break;
			case 'n':
				topN = atoi(optarg);
				if ( topN < 0 ) {
					fprintf(stderr, "TopnN number %i out of range\n", topN);
					exit(255);
				}
				break;
			case 'p':
				output_mode = 1;
				break;
			case 'r':
				rfile = strdup(optarg);
				break;
			case 'w':
				wfile = strdup(optarg);
				break;
			case 's':
				GenStat = 1;
				break;
			case 't':
				timeslot = optarg;
				if ( !ISO2UNIX(timeslot) ) {
					exit(255);
				}
				break;
			case 'A':
				AddDB = 1;
				break;
			case 'S':
				AvStat = 1;
				break;
			default:
				usage(argv[0]);
				exit(0);
		}
	}

	if (argc - optind > 1) {
		usage(argv[0]);
		exit(255);
	} else {
		/* user specified a pcap filter */
		filter = argv[optind];
	}

	openlog(argv[0] , LOG_CONS|LOG_PID, LOG_DAEMON);

	if ( !filter && ffile ) {
		if ( stat(ffile, &stat_buff) ) {
			perror("Can't stat file");
			exit(255);
		}
		filter = (char *)malloc(stat_buff.st_size);
		if ( !filter ) {
			perror("Memory error");
			exit(255);
		}
		ffd = open(ffile, O_RDONLY);
		if ( ffd < 0 ) {
			perror("Can't open file");
			exit(255);
		}
		ret = read(ffd, (void *)filter, stat_buff.st_size);
		if ( ret < 0   ) {
			perror("Error reading file");
			close(ffd);
			exit(255);
		}
		close(ffd);
	}

	if ( !DBdir ) {
		fprintf(stderr, "DB directory required\n");
		exit(255);
	}

	InitStat(DBdir);

	if ( !filter )
		filter = "any";

	Engine = CompileFilter(filter);
	if ( !Engine ) 
		exit(254);
	
	if ( DBinit ) {
		when = time(NULL);
		when -= ((when % 300) + 300);
		InitStatFile(when, NUM_AV_SLOTS);
		if ( !CreateRRDBs(DBdir, when) ) {
			fprintf(stderr, "Init DBs failed\n");
			exit(255);
		}
		fprintf(stderr, "Port DBs initialized.\n");
		exit(0);
	}

	if ( lastupdate ) {
		when = RRD_LastUpdate(DBdir);
		if ( !when )
			exit(255);
		t1 = localtime(&when);
		strftime(datestr, 63, "%b %d %Y %T", t1);
		printf("Last Update: %i, %s\n", (int)when, datestr);
		exit(0);
	}

	port_table = NULL;
	if ( Mdirs || Rfile || rfile ) {
		SetupInputFileSequence(Mdirs, rfile, Rfile);
		port_table = process(filter);
//		Lister(port_table);
		if ( !port_table ) {
			exit(255);
		}
		if ( AddDB ) {
			if ( !timeslot ) {
				fprintf(stderr, "Timeslot required!\n");
				exit(255);
			}
			UpdateStat(port_table, ISO2UNIX(timeslot));
			RRD_StoreDataRow(DBdir, timeslot, port_table);
		}
	}

	if ( AvStat ) {
		port_table = GetStat();
		if ( !port_table ) {
			fprintf(stderr, "Unable to get port table!\n");
			exit(255);
		}
		// DoStat
		Generate_TopN(port_table, topN, NUM_AV_SLOTS, 0, output_mode, wfile);

	} 


	if ( GenStat ) {
		when = ISO2UNIX(timeslot);
		if ( !port_table ) {
			if ( !timeslot ) {
				fprintf(stderr, "Timeslot required!\n");
				exit(255);
			}
			port_table = RRD_GetDataRow(DBdir, when);
		}
		if ( !port_table ) {
			fprintf(stderr, "Unable to get port table!\n");
			exit(255);
		}
		// DoStat
		Generate_TopN(port_table, topN, 1, when, output_mode, wfile);
	}

	CloseStat();

	return 0;
}