Exemple #1
0
int             main(int argc, char *argv[])
{
  t_gameboy     gb;

  g_gb = &gb;
  signal(SIGINT, &sighandler);

  /*
  ** First call the initializers to set the default values,
  ** then call the argument parser to modify them if needed.
  */
  memset(&gb, 0, sizeof(gb));
  init_debug(&gb);
  init_timing(&gb);
  init_gpu(&gb);
  if (get_args(argc, argv, &gb) || init_gameboy(&gb) || start_gpu(&gb))
    return (EXIT_FAILURE);
  run_gameboy(&gb);
  SDL_Quit();
  return (EXIT_SUCCESS);
}
Exemple #2
0
void *lat_ctx2_thread0(void *ptr)
{
	int tmp_iterations;
	Pr_Time overhead;
	Pr_Time time_spent, tmp, total_time;
	
	/* Obtain the timing overhead */
	printf("Task0: Hello, let's init_timing()\n");
	init_timing();

	/* Calculate the number of executions of do_overhead1() that can
	 * be done in 1 second */
	 
	tmp_iterations = generate_iterations (&do_overhead1, 1);
	printf("%d complete iterations in 1 second\n", tmp_iterations);
	
	/* Now obtains the token passing overhead */
	tmp_iterations >>= 1;
	overhead = 0.0;
	do_overhead2(tmp_iterations, &overhead);
	
	/* After obtaining all the overheads, it launches the context swith latency
	 * measuring process */
	do_context_switch(NUM_ITERATIONS, &time_spent);
	
	/* Now, it calculates the context swith latency time */
	printf("Time spent: %d\n", (uint32)time_spent.Micros());
	tmp = (float)(overhead.Secns() * (float)(NUM_ITERATIONS * NUM_TASKS));
	printf("Total overhead: %d\n", (uint32)tmp.Micros());
	time_spent -= tmp;

	total_time = (float)(time_spent.Secns() / (NUM_ITERATIONS * NUM_TASKS));
	
	printf("Latency of context switch: %d usecs\n", (uint32)total_time.Micros());
	
	Testlat_ctx2.End();
	
    return NULL;
}
Exemple #3
0
int main(int argc, char *argv[], char *envp[])
	{
	char	answer[128], filename[64];
	int	cache_page, line_offset, value;
	FILE	*logfp;
	int	i, j, k, ret;
	int	*tmparray;	/* for malloc'd static array */
	struct	rlimit rlims;
	struct	rusage	r_start, r_stop;

	cache_page = getpagesize();

			/* Ask for line_offset */
again:	fprintf(stdout, "\nEnter line_offset: ");
	fgets(answer, sizeof(answer) - 1, stdin);
	fflush(stdin);
	line_offset = atoi(answer);
	if ( (cache_page < line_offset) || (line_offset < 1) )
		{
		fprintf(stderr,
			"\nline_offset=%d out of range [1, %d]",
				line_offset, cache_page); 
		fflush(stderr);
		goto again;
		}

			/* Reduce MAX_RSS to be NICE to other users */
#if defined(__alpha)
	rlims.rlim_cur = NEW_MAX_RSS;		/* soft */
	rlims.rlim_max = NEW_MAX_RSS;		/* hard */
	if(setrlimit(RLIMIT_RSS, &rlims) < 0)
		{
		perror("setrlimit: ");
		exit(-1);
		} 
#endif
			/* Reduce our priority to be NICE to other users 
		PRIO_MAX is 20 on pegasus so we are doing nice(19) */
	if (nice(PRIO_MAX - 1) < 0)
		{
		perror("nice: ");
		exit(-1);
		}

			/* open log file */
	sprintf(filename, "cache_%4.4d.log", line_offset);
	logfp = fopen(filename, "w");	
	if (logfp == (FILE *)NULL)
		{
		fprintf(stderr, 
	  "\n\nmain: *** fopen(\"%s\",\"w\") failed ***\n\n", filename);
		fflush(stderr);
		return(-3);
		}

			/* get starting baseline resource usage */
	ret = get_resource_usage(RUSAGE_SELF, &r_start);
	if (ret != 0)
		{
		fprintf(stderr,
		"\n..get_resource_usage(RUSAGE_SELF,..) return %d ", ret);
		fflush(stderr);
		}
			/* initialize and start timers */
	init_timing();

			/* allocate tmparray[] in data segment */
	tmparray = (int *)malloc(NUM_ENTRIES * cache_page * sizeof(int));
	if (tmparray == (int *)NULL)
		{
		fprintf(stderr,
			"\nmalloc: fatal error:");
		fflush(stderr);
		exit(-4);
		}
	fprintf(stdout,
		"\nUsing line_offset=%d cache_page=%d..",
			line_offset, cache_page);
	fflush(stdout);
	fprintf(logfp,
		"\nUsing line_offset=%d cache_page=%d..",
			line_offset, cache_page);
	fflush(logfp);

	value = 0;
	for (k = 0 ; k < REPEAT ; k++)
	    {
	    i = 0;	/* only for fprintf() */
    	    j = 0;
	    if ((k % 32) == 0)
		{
		fprintf(stdout,
	"\n..setting entry, tmparry[], value [%9d,%9d,%9d]", i, j, value);
		fflush(stdout);
		}
	    for (i = 0 ; i < NUM_ENTRIES ; i++)
		{
		tmparray[j] = value;	/* tmparray[j] will be kept
				in the L2 cache until cache contention
				with newer data forces it to be written
				out to (slower) main memory */
		j = j + line_offset;
		value++; 

		if  ( ((i % 1024) == 0) && ((k % 32) == 0) )
			{
			putchar(0x08); putchar(0x08);
			putchar(0x08); putchar(0x08);
			putchar(0x08); putchar(0x08);
			putchar(0x08); putchar(0x08);
			putchar(0x08); putchar(0x08);
			putchar(0x08); putchar(0x08);
			putchar(0x08); putchar(0x08);
			putchar(0x08); putchar(0x08);
			putchar(0x08); putchar(0x08);
			putchar(0x08); putchar(0x08);
			putchar(0x08); putchar(0x08);
			putchar(0x08); putchar(0x08);
			putchar(0x08); putchar(0x08);
			putchar(0x08); putchar(0x08);
			putchar(0x08); putchar(0x08);
			fprintf(stdout, "%9d,%9d,%9d]", i, j, value);
			fflush(stdout);
			} 
		}  /* end of for (i = .. */
	    }  /* end of for (k = .. */

			/* get ending resource usage */
	ret = get_resource_usage(RUSAGE_SELF, &r_stop);
	if (ret != 0)
		{
		fprintf(stderr,
		"\n..get_resource_usage(RUSAGE_SELF,..) return %d ", ret);
		fflush(stderr);
		}

			/* read timers and then stop them */
	read_timing(&real_sec, &real_usec, &virt_sec, &virt_usec,
			&prof_sec, &prof_usec);
	pause_timing();

			/* print out resources used in rusage struct's 
		to both stdout and our logfile */
	fprintf(stdout, "\n..stopping timers ");
	fprintf_rusage(stdout, &r_start, &r_stop);

	fprintf(logfp, "\n..stopping timers ");
	fprintf_rusage(logfp, &r_start, &r_stop);

			/* printout the total times to both stdout and
		our logfile */
	printf_timing();
	fprintf(stdout, "\nNet Memory Bandwidth %8.3f Mbytes/sec: ",
  ((double)(value*sizeof(int))/((double)prof_sec + (double)prof_usec/1000000.0))
		/1000000.0 );
	fprintf(stdout, "\n\n");
	fflush(stdout);

	fprintf_timing(logfp,
	  real_sec, real_usec, virt_sec, virt_usec, prof_sec, prof_usec);
	fprintf(logfp, "\nNet Memory Bandwidth %8.3f Mbytes/sec: ",
  ((double)(value*sizeof(int))/((double)prof_sec + (double)prof_usec/1000000.0))
		/1000000.0 );
	fprintf(logfp, "\n\n");
	fflush(logfp);
	fclose(logfp);	/* close logfile */
	return(0);
	}  /* end of main */