Exemplo n.º 1
0
void Frame()
{
  long starttime,stoptime,exectime,i;

  Init_Options();

  printf("*****Entering init_decomposition with num_nodes = %ld\n",num_nodes);
  fflush(stdout);

  Init_Decomposition();

  printf("*****Exited init_decomposition with num_nodes = %ld\n",num_nodes);
  fflush(stdout);



  Global = (struct GlobalMemory *)NU_MALLOC(sizeof(struct GlobalMemory),0);
  BARINIT(Global->SlaveBarrier, num_nodes);
  BARINIT(Global->TimeBarrier, num_nodes);
  LOCKINIT(Global->IndexLock);
  LOCKINIT(Global->CountLock);
  ALOCKINIT(Global->QLock,MAX_NUMPROC+1);

  /* load dataset from file to each node */
#ifndef RENDER_ONLY
  CLOCK(starttime);
  Load_Map(filename);
  CLOCK(stoptime);
  mclock(stoptime,starttime,&exectime);
  printf("wall clock execution time to load map:  %lu ms\n", exectime);
#endif

  CLOCK(starttime);
#ifndef RENDER_ONLY
  Compute_Normal();
#ifdef PREPROCESS
  Store_Normal(filename);
#endif
#else
  Load_Normal(filename);
#endif
  CLOCK(stoptime);
  mclock(stoptime,starttime,&exectime);
  printf("wall clock execution time to compute normal:  %lu ms\n", exectime);

  CLOCK(starttime);
#ifndef RENDER_ONLY
  Compute_Opacity();
#ifdef PREPROCESS
  Store_Opacity(filename);
#endif
#else
  Load_Opacity(filename);
#endif
  CLOCK(stoptime);
  mclock(stoptime,starttime,&exectime);
  printf("wall clock execution time to compute opacity:  %lu ms\n", exectime);

  Compute_Pre_View();
  shd_length = LOOKUP_SIZE;
  Allocate_Shading_Table(&shd_address,shd_length);
  /* allocate space for image */
  image_len[X] = frust_len;
  image_len[Y] = frust_len;
  image_length = image_len[X] * image_len[Y];
  Allocate_Image(&image_address,image_length);

  if (num_nodes == 1) {
    block_xlen = image_len[X];
    block_ylen = image_len[Y];
    num_blocks = 1;
    num_xblocks = 1;
    num_yblocks = 1;
    image_block = image_address;
  }
  else {
    num_xblocks = ROUNDUP((float)image_len[X]/(float)block_xlen);
    num_yblocks = ROUNDUP((float)image_len[Y]/(float)block_ylen);
    num_blocks = num_xblocks * num_yblocks;
    Lallocate_Image(&image_block,block_xlen*block_ylen);
  }

  CLOCK(starttime);
#ifndef RENDER_ONLY
  Compute_Octree();
#ifdef PREPROCESS
  Store_Octree(filename);
#endif
#else
  Load_Octree(filename);
#endif
  CLOCK(stoptime);
  mclock(stoptime,starttime,&exectime);
  printf("wall clock execution time to compute octree:  %lu ms\n", exectime);

#ifdef PREPROCESS
  return;
#endif

  if (adaptive) {
    printf("1.\n");
    for (i=0; i<NI; i++) {
      mask_image_len[i] = image_len[i];
    }
    mask_image_length = image_length;
    Allocate_MImage(&mask_image_address, mask_image_length);
    if (num_nodes == 1)
      mask_image_block = (PIXEL *)mask_image_address;
    else
      Lallocate_Image(&mask_image_block, block_xlen*block_ylen);
    printf("2.\n");
  }

#ifndef RENDER_ONLY
  Deallocate_Map(&map_address);
#endif

  Global->Index = NODE0;

  printf("\nRendering...\n");
  printf("node\tframe\ttime\titime\trays\thrays\tsamples trilirped\n");

  CREATE(Render_Loop, num_nodes);
}
Exemplo n.º 2
0
void Frame()
{
  long starttime,stoptime,exectime,i;

  Init_Options();

  printf("*****Entering init_decomposition with num_nodes = %ld\n",num_nodes);
  fflush(stdout);

  Init_Decomposition();

  printf("*****Exited init_decomposition with num_nodes = %ld\n",num_nodes);
  fflush(stdout);



//  Global = (struct GlobalMemory *)valloc(sizeof(struct GlobalMemory));;

  posix_memalign(&Global, sizeof(struct GlobalMemory *), sizeof(struct GlobalMemory));
  {
#line 120
	unsigned long	Error;
#line 120

#line 120
	Error = pthread_mutex_init(&(Global->SlaveBarrier).mutex, NULL);
#line 120
	if (Error != 0) {
#line 120
		printf("Error while initializing barrier.\n");
#line 120
		exit(-1);
#line 120
	}
#line 120

#line 120
	Error = pthread_cond_init(&(Global->SlaveBarrier).cv, NULL);
#line 120
	if (Error != 0) {
#line 120
		printf("Error while initializing barrier.\n");
#line 120
		pthread_mutex_destroy(&(Global->SlaveBarrier).mutex);
#line 120
		exit(-1);
#line 120
	}
#line 120

#line 120
	(Global->SlaveBarrier).counter = 0;
#line 120
	(Global->SlaveBarrier).cycle = 0;
#line 120
};
  {
#line 121
	unsigned long	Error;
#line 121

#line 121
	Error = pthread_mutex_init(&(Global->TimeBarrier).mutex, NULL);
#line 121
	if (Error != 0) {
#line 121
		printf("Error while initializing barrier.\n");
#line 121
		exit(-1);
#line 121
	}
#line 121

#line 121
	Error = pthread_cond_init(&(Global->TimeBarrier).cv, NULL);
#line 121
	if (Error != 0) {
#line 121
		printf("Error while initializing barrier.\n");
#line 121
		pthread_mutex_destroy(&(Global->TimeBarrier).mutex);
#line 121
		exit(-1);
#line 121
	}
#line 121

#line 121
	(Global->TimeBarrier).counter = 0;
#line 121
	(Global->TimeBarrier).cycle = 0;
#line 121
};
  {pthread_mutex_init(&(Global->IndexLock), NULL);};
  {pthread_mutex_init(&(Global->CountLock), NULL);};
  {
#line 124
	unsigned long	i, Error;
#line 124

#line 124
	for (i = 0; i < MAX_NUMPROC+1; i++) {
#line 124
		Error = pthread_mutex_init(&Global->QLock[i], NULL);
#line 124
		if (Error != 0) {
#line 124
			printf("Error while initializing array of locks.\n");
#line 124
			exit(-1);
#line 124
		}
#line 124
	}
#line 124
};

  /* load dataset from file to each node */
#ifndef RENDER_ONLY
  {
#line 128
	struct timeval	FullTime;
#line 128

#line 128
	gettimeofday(&FullTime, NULL);
#line 128
	(starttime) = (unsigned long)(FullTime.tv_usec + FullTime.tv_sec * 1000000);
#line 128
};
  Load_Map(filename);
  {
#line 130
	struct timeval	FullTime;
#line 130

#line 130
	gettimeofday(&FullTime, NULL);
#line 130
	(stoptime) = (unsigned long)(FullTime.tv_usec + FullTime.tv_sec * 1000000);
#line 130
};
  mclock(stoptime,starttime,&exectime);
  printf("wall clock execution time to load map:  %lu ms\n", exectime);
#endif

  {
#line 135
	struct timeval	FullTime;
#line 135

#line 135
	gettimeofday(&FullTime, NULL);
#line 135
	(starttime) = (unsigned long)(FullTime.tv_usec + FullTime.tv_sec * 1000000);
#line 135
};
#ifndef RENDER_ONLY
  Compute_Normal();
#ifdef PREPROCESS
  Store_Normal(filename);
#endif
#else
  Load_Normal(filename);
#endif
  {
#line 144
	struct timeval	FullTime;
#line 144

#line 144
	gettimeofday(&FullTime, NULL);
#line 144
	(stoptime) = (unsigned long)(FullTime.tv_usec + FullTime.tv_sec * 1000000);
#line 144
};
  mclock(stoptime,starttime,&exectime);
  printf("wall clock execution time to compute normal:  %lu ms\n", exectime);

  {
#line 148
	struct timeval	FullTime;
#line 148

#line 148
	gettimeofday(&FullTime, NULL);
#line 148
	(starttime) = (unsigned long)(FullTime.tv_usec + FullTime.tv_sec * 1000000);
#line 148
};
#ifndef RENDER_ONLY
  Compute_Opacity();
#ifdef PREPROCESS
  Store_Opacity(filename);
#endif
#else
  Load_Opacity(filename);
#endif
  {
#line 157
	struct timeval	FullTime;
#line 157

#line 157
	gettimeofday(&FullTime, NULL);
#line 157
	(stoptime) = (unsigned long)(FullTime.tv_usec + FullTime.tv_sec * 1000000);
#line 157
};
  mclock(stoptime,starttime,&exectime);
  printf("wall clock execution time to compute opacity:  %lu ms\n", exectime);

  Compute_Pre_View();
  shd_length = LOOKUP_SIZE;
  Allocate_Shading_Table(&shd_address,shd_length);
  /* allocate space for image */
  image_len[X] = frust_len;
  image_len[Y] = frust_len;
  image_length = image_len[X] * image_len[Y];
  Allocate_Image(&image_address,image_length);

  if (num_nodes == 1) {
    block_xlen = image_len[X];
    block_ylen = image_len[Y];
    num_blocks = 1;
    num_xblocks = 1;
    num_yblocks = 1;
    image_block = image_address;
  }
  else {
    num_xblocks = ROUNDUP((float)image_len[X]/(float)block_xlen);
    num_yblocks = ROUNDUP((float)image_len[Y]/(float)block_ylen);
    num_blocks = num_xblocks * num_yblocks;
    Lallocate_Image(&image_block,block_xlen*block_ylen);
  }

  {
#line 185
	struct timeval	FullTime;
#line 185

#line 185
	gettimeofday(&FullTime, NULL);
#line 185
	(starttime) = (unsigned long)(FullTime.tv_usec + FullTime.tv_sec * 1000000);
#line 185
};
#ifndef RENDER_ONLY
  Compute_Octree();
#ifdef PREPROCESS
  Store_Octree(filename);
#endif
#else
  Load_Octree(filename);
#endif
  {
#line 194
	struct timeval	FullTime;
#line 194

#line 194
	gettimeofday(&FullTime, NULL);
#line 194
	(stoptime) = (unsigned long)(FullTime.tv_usec + FullTime.tv_sec * 1000000);
#line 194
};
  mclock(stoptime,starttime,&exectime);
  printf("wall clock execution time to compute octree:  %lu ms\n", exectime);

#ifdef PREPROCESS
  return;
#endif

  if (adaptive) {
    printf("1.\n");
    for (i=0; i<NI; i++) {
      mask_image_len[i] = image_len[i];
    }
    mask_image_length = image_length;
    Allocate_MImage(&mask_image_address, mask_image_length);
    if (num_nodes == 1)
      mask_image_block = (PIXEL *)mask_image_address;
    else
      Lallocate_Image(&mask_image_block, block_xlen*block_ylen);
    printf("2.\n");
  }

#ifndef RENDER_ONLY
  Deallocate_Map(&map_address);
#endif

  Global->Index = NODE0;

  printf("\nRendering...\n");
  printf("node\tframe\ttime\titime\trays\thrays\tsamples trilirped\n");

  {
#line 225
	long	i, Error;
#line 225

#line 225
	for (i = 0; i < (num_nodes) - 1; i++) {
#line 225
		Error = pthread_create(&PThreadTable[i], NULL, (void * (*)(void *))(Render_Loop), NULL);
#line 225
		if (Error != 0) {
#line 225
			printf("Error in pthread_create().\n");
#line 225
			exit(-1);
#line 225
		}
#line 225
	}
#line 225

#line 225
	Render_Loop();
#line 225
};
}