Changeset - c6e0422d180e
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 16 years ago 2009-07-14 22:29:38
ohnobinki@ohnopublishing.net
fixed status_report_generator() to use struct blendjob *
1 file changed with 79 insertions and 49 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -150,62 +150,92 @@ jobnum++; // Advance the jobnumber for t
 
}
 

	
 

	
 
// **** Status Report Generator: figures out how much of the job is done, where jobnum corresponds to the job number
 
// This uses pointers, so when it is run it updates certain values in memory
 
void status_report_generator(){
 

	
 
	while(blendjob[(hcfjob+1)].priority == 0)  //If the job after the highest consecutively finished job is finished
 
		hcfjob++;  // adds 1 to the highest consecutively finished job and checks the next one, till the job after the hcfjob is not done
 

	
 
	int num1 = hcfjob+1; // to scan through jobs
 
	unsigned short int workers_working; // used to count the total number of workers working
 

	
 
/*
 
  Status Report Generator: figures out how much of the job is done, where jobnum corresponds to the job number
 
*/
 
void status_report_generator(struct blendjob *blendjobs_head)
 
{
 
  struct blendjob *blendjob_ptr;
 
  unsigned short workers_working; /*< used to count the total number of workers working */
 
  unsigned int numjobs; /*< used to track number of jobs */
 

	
 
	while(num1 <= highest_jobnum){
 
			if(blendjob[num1].priority != 0){ // If the job is not done, scan it
 
  blendjob_ptr = blendjobs_head;
 
  workers_working = 0;
 
  numjobs = 0;
 
  
 
  while(blendjob_ptr)
 
    {
 
      if(blendjob_ptr->priority != 0)
 
	/* If the job is not done, scan it */
 
	{
 
	  unsigned int framecounter;  /*< to scan through frames */
 
	  unsigned long finished_frames; /*< variable that counts the completed frames */
 
	  unsigned int pending_frames; /*< variable that counts the assigned frames */
 
	  float percent_frames_finished;  /*< variable that stores the percent done of the blendjob */
 
	  unsigned int total_time;  /*< total time taken to render all the completed frames for a job */
 

	
 
				int num2 = 0;  // to scan through frames
 
				float finished_frames = 0; // variable that counts the completed frames
 
				int pending_frames = 0; // variable that counts the assigned frames
 
				float percent = 0;  // variable that stores the percent done of the blendjob
 
				unsigned int total_time = 0;  // total time taken to render all the completed frames for a job
 

	
 
				while(num2 <= blendjob[num1].total_frames){ // scans through frames, based on their status it runs a statement(s)
 
					if(blendjob[num1].frameset[num2].frame_status == 2){ // If the frame is done
 
						finished_frames++;
 
						total_time = total_time + blendjob[num1].frameset[num2].time_to_render;
 
					}
 
	  framecounter = 0;
 
	  finished_frames = 0;
 
	  pending_frames = 0;
 
	  percent_frames_finished = 0;
 
	  total_time = 0;
 

	
 
					if(blendjob[num1].frameset[num2].frame_status == 1){ // If the frame is assigned
 
						pending_frames++;
 
						workers_working++;
 
					}
 
					num2++;
 
				}
 
	  while(framecounter < blendjob_ptr->total_frames)
 
	    /* scans through frames, based on their status it runs a statement(s) */
 
	    {
 
	      if(blendjob_ptr->frameset[framecounter].frame_status == 2)
 
		/* If the frame is done */
 
		{
 
		  finished_frames ++;
 
		  total_time += blendjob_ptr->frameset[framecounter].time_to_render;
 
		}
 
	      
 
	      if(blendjob_ptr->frameset[framecounter].frame_status == 1)
 
		/* If the frame is assigned */
 
		{
 
		  pending_frames ++;
 
		  workers_working ++;
 
		}
 
	      
 
	      framecounter ++;
 
	    } /* while(framecounter < blendjob_ptr->total_frames) */
 

	
 
				// find the percent of completed frames
 
				percent = (finished_frames / blendjob[num1].total_frames) * 100;
 
	  // find the percent of completed frames
 
	  percent_frames_finished = (finished_frames / blendjob_ptr->total_frames) * 100; /*< @LordofWar: extraneous parentheses! */
 

	
 
				// updates values in the blendjob struct for jobnum held by the variable num1
 
				blendjob[num1].completed_frames = finished_frames;
 
				blendjob[num1].assigned_frames = pending_frames;
 
				blendjob[num1].percent_done = percent;
 
				blendjob[num1].avg_render_time = (total_time / finished_frames);
 
				blendjob[num1].time_remaining = (blendjob[num1].avg_render_time * (blendjob[num1].total_frames - finished_frames));
 
	  /* updates values in the blendjob struct */
 
	  blendjob_ptr->completed_frames = finished_frames;
 
	  blendjob_ptr->assigned_frames = pending_frames;
 
	  blendjob_ptr->percent_done = percent_frames_finished;
 
	  blendjob_ptr->avg_render_time = (total_time / finished_frames); /*< extraneous parentheses! */
 
	  blendjob_ptr->time_remaining = (blendjob_ptr->avg_render_time * (blendjob_ptr->total_frames - finished_frames)); /*< extraneous parentheses! */
 

	
 
				if(finished_frames == blendjob[num1].total_frames){  // If all frames are complete
 
					blendjob[num1].priority = 0;					//set priority to zero to indicate job is complete
 
					general_info.total_finished_jobs++; // add one to the total finished jobs
 

	
 
				}
 
			}
 
	  if(finished_frames == blendjob_ptr->total_frames)
 
	    /* If all frames are complete */
 
	    {
 
	      blendjob_ptr->priority = 0; /*< set priority to zero to indicate job is complete */
 
	      general_info.total_finished_jobs++; /*< add one to the total finished jobs */
 
	      
 
	    }
 
	  else if (finished_frames > blendjob_ptr->total_frames)
 
	    /* just in case ;-) */
 
	    {
 
	      fprintf(stderr, "%s:%d: finished_frames (%lu) > blendjob_ptr->total_frames (%d)",
 
		      __FILE__, __LINE__, 
 
		      finished_frames, 
 
		      blendjob_ptr->total_frames);
 
	      abort();
 
	    }
 
	}
 

	
 
			num1++;
 
			general_info.rendering_clients = workers_working;
 
		}
 

	
 
		general_info.jobs_in_queue = (highest_jobnum - general_info.total_finished_jobs);
 
	}
 
      general_info.rendering_clients = workers_working; /*< should this be a +=? */
 
      
 
      blendjob_ptr = blendjob_ptr->next; /*< This is the essence of linked lists and iterating through them */
 
      numjobs ++;
 
    } /* while(blendjob_ptr) */
 
  
 
  general_info.jobs_in_queue = (highest_jobnum - general_info.total_finished_jobs); /*< extraneous parentheses! */
 
}
 

	
 

	
 
// **** Structure Builder: This function creates frame array based on the total number of frames to be rendered, which will then be parsed by function frame_farmer.
0 comments (0 inline, 0 general)