Changeset - 1aeb6d2aebd0
[Not reviewed]
default
0 3 0
LordOfWar - 16 years ago 2009-10-24 17:01:27

created an almost working skeletal framework for a smarter frame_finder, which will assign frames in a much less linear order
3 files changed with 93 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -68,6 +68,7 @@ struct general_info {
 
  unsigned int highest_jobnum;
 
  short int hibernate;
 
  unsigned int timestamp;
 
  unsigned long int total_render_power;
 
} general_info;
 

	
 

	
 
@@ -418,6 +419,95 @@ int find_jobframe(struct distrenjob *hea
 
  return 0;
 
}
 

	
 
int find_jobframe_from_job(struct distrenjob *head, struct distrenjob *distrenjob_ptr, struct distrenjob **job, struct frameset **frame)
 
{
 
  unsigned int frame_counter;
 
  unsigned short int found;
 

	
 
  found = 0;
 
  for(frame_counter = (distrenjob_ptr->prev_frame_index + 1); frame_counter < distrenjob_ptr->total_frames; frame_counter ++)
 
  {
 
    if(distrenjob_ptr->frameset[frame_counter].status == FRAMESETSTATUS_UNASSIGNED) // jobframe found
 
      {
 
    	found = 1;
 
		distrenjob_ptr->frameset[frame_counter].status = FRAMESETSTATUS_ASSIGNED;
 
		distrenjob_ptr->frameset[frame_counter].start_time = clock();
 
		distrenjob_ptr->assigned_frames++;
 
		distrenjob_ptr->prev_frame_index = frame_counter;
 
		updateJobStatsXML(distrenjob_ptr);
 
      }
 

	
 
    if(found)
 
      break;
 
  }
 

	
 

	
 
  if(!found)
 
    {
 
      fprintf(stderr, "No more frames in this job number %d", distrenjob_ptr->jobnum);
 
      sleep(1); /*< @todo eliminate the need for this line*/
 
      return 1;
 
    }
 

	
 
  *job = distrenjob_ptr;
 
  *frame = &distrenjob_ptr->frameset[frame_counter];
 

	
 
  return 0;
 
}
 

	
 
// find a frame to render when the job that the last frame was for no longer exists
 
int find_jobframe_new(struct distrenjob *head, int rend_pwr, struct distrenjob **job, struct frameset **frame)
 
{
 
  if(general_info.hibernate)
 
    return 1;
 

	
 
  unsigned short int found;
 
  struct distrenjob *job_to_render;
 

	
 
  struct distrenjob *distrenjob_ptr;
 

	
 
  found = 0;
 
  /* iterate through jobs from first to last */
 
  for(distrenjob_ptr = head->next; distrenjob_ptr && !distrenjob_ptr->hibernate; distrenjob_ptr = distrenjob_ptr->next)
 
  {
 

	
 
	  job_to_render = distrenjob_ptr;
 
  }
 

	
 
  find_jobframe_from_job(head, job_to_render, job, frame);
 

	
 
  if(!found)
 
    {
 
      fprintf(stderr, "No more jobs to render\n");
 
      sleep(1); /*< @todo eliminate the need for this line*/
 
      return 1;
 
    }
 

	
 
  return 0;
 
}
 

	
 
// gets a frame to render from the same job that the previously rendered frame was from
 
int find_jobframe_again(struct distrenjob *head, int jobnum, int rend_pwr, struct distrenjob **job, struct frameset **frame)
 
{
 
  if(general_info.hibernate)
 
    return 1;
 

	
 
  struct distrenjob *distrenjob_ptr;
 

	
 
  distrenjob_ptr = distrenjob_get(head, jobnum);
 

	
 
  if(!distrenjob_ptr)
 
    {
 
      fprintf(stderr, "Job number %d has been finished, finding new job\n", jobnum);
 
      sleep(1); /*< @todo eliminate the need for this line*/
 
      return 1;
 
    }
 

	
 
  find_jobframe_new(head, rend_pwr, job, frame);
 

	
 
  return 0;
 
}
 

	
 
/** Checks for dead, latent, or stale slaves */
 
void frame_watchdog(struct distrenjob *distrenjob_head)
 
{
src/server/distrenjob.c
Show inline comments
 
@@ -65,6 +65,7 @@ int distrenjob_new(struct distrenjob **d
 
  dj->total_render_time = 0;
 
  dj->hibernate = 0;
 
  dj->prev_frame_index = -1;
 
  dj->assigned_render_power = 0;
 
  dj->watchdog_forgiveness = 3600; // initialize watchdog forgiveness at 1 hour
 
  dj->frameset = (struct frameset *)NULL; /*< @todo does frameset need to be initialized here? */
 

	
src/server/distrenjob.h
Show inline comments
 
@@ -49,7 +49,8 @@ struct distrenjob {
 
  short int hibernate;
 
  int prev_frame_index; // the position in the array of the last frame that was assigned
 
  time_t total_render_time; // total seconds of time spent on all the completed frames
 
  char *output_format; /*< currently is the file extention of the request output format. @todo make this mime-type based/not a string */
 
  char *output_format; /*< currently is the file extension of the request output format. @todo make this mime-type based/not a string */
 
  unsigned long int assigned_render_power;
 
  struct frameset *frameset;
 
};
 

	
0 comments (0 inline, 0 general)