ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rholo.c
(Generate patch)

Comparing ray/src/hd/rholo.c (file contents):
Revision 3.39 by gwlarson, Thu May 14 13:05:27 1998 UTC vs.
Revision 3.47 by gwlarson, Wed Jan 20 13:28:49 1999 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1998 Silicon Graphics, Inc. */
1 > /* Copyright (c) 1999 Silicon Graphics, Inc. */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ SGI";
# Line 14 | Line 14 | static char SCCSid[] = "$SunId$ SGI";
14   #include <sys/types.h>
15   #include <sys/stat.h>
16  
17 + #ifndef RTFLUSH
18 + #define RTFLUSH         0               /* flush one at a time in batch */
19 + #endif
20 + #ifndef FRAGWARN
21 + #define FRAGWARN        20              /* fragmentation for warning (%) */
22 + #endif
23   #ifndef MAXQTIME
24   #define MAXQTIME        5               /* target maximum seconds in queue */
25   #endif
# Line 26 | Line 32 | char   *progname;              /* our program name */
32   char    *hdkfile;               /* holodeck file name */
33   char    froot[256];             /* root file name */
34  
29 int     nowarn = 0;             /* turn warnings off? */
30
35   int     ncprocs = 0;            /* desired number of compute processes */
36  
37   char    *outdev = NULL;         /* output device name */
# Line 55 | Line 59 | int    totqlen;                /* maximum queue length when full */
59  
60   char  *sigerr[NSIG];            /* signal error messages */
61  
62 + extern int      nowarn;         /* turn warnings off? */
63 +
64   extern time_t   time();
65  
66  
# Line 144 | Line 150 | int  signo;
150   {
151          static int  gotsig = 0;
152  
153 <        if (gotsig++)                   /* two signals and we're gone! */
153 >        if (gotsig > 1)                 /* we're going as fast as we can! */
154 >                return;
155 >        if (gotsig++) {                 /* two signals and we split */
156 >                hdsync(NULL, 0);        /* don't leave w/o saying goodbye */
157                  _exit(signo);
158 <
159 <        alarm(60);                      /* allow 60 seconds to clean up */
151 <        signal(SIGALRM, SIG_DFL);       /* make certain we do die */
158 >        }
159 >        alarm(300);                     /* allow 5 minutes to clean up */
160          eputs("signal - ");
161          eputs(sigerr[signo]);
162          eputs("\n");
# Line 269 | Line 277 | memerr:
277  
278   rholo()                         /* holodeck main loop */
279   {
280 +        static long     nextfragwarn = 100*(1L<<20);
281          static int      idle = 0;
282          PACKET  *pl = NULL, *plend;
283 +        long    fsiz;
284          int     pksiz;
285          register PACKET *p;
286          time_t  t;
# Line 284 | Line 294 | rholo()                                /* holodeck main loop */
294                          return(1);
295          } else if (idle)
296                  return(0);              /* all done */
297 <                                        /* check file size */
298 <        if (maxdisk > 0 && hdfilen(hdlist[0]->fd) >= maxdisk) {
297 >        fsiz = hdfilen(hdlist[0]->fd);  /* check file size */
298 >        if (maxdisk > 0 && fsiz >= maxdisk) {
299                  error(WARNING, "file limit exceeded");
300                  done_rtrace();
301                  return(1);      /* comes back */
302          }
303 + #if FRAGWARN
304 +        if (fsiz >= nextfragwarn &&
305 +                (fsiz-hdfiluse(hdlist[0]->fd,0))/(fsiz/100) > FRAGWARN) {
306 +                sprintf(errmsg, "holodeck file fragmentation is %.0f%%",
307 +                                100.*(fsiz-hdfiluse(hdlist[0]->fd,1))/fsiz);
308 +                error(WARNING, errmsg);
309 +                nextfragwarn = fsiz + (fsiz>>2);        /* decent interval */
310 +        }
311 + #endif
312          t = time(NULL);                 /* check time */
313          if (endtime > 0 && t >= endtime) {
314                  error(WARNING, "time limit exceeded");
# Line 367 | Line 386 | register HDGRID        *gp;
386                  for (i = 0; i < 3; i++)
387                          len[i] = VLEN(gp->xv[i]);
388                  if (!vdef(GRID)) {
389 <                        d = 2/5e5*( len[0]*len[0]*(len[1]*len[1] +
389 >                        d = 2/2e5*( len[0]*len[0]*(len[1]*len[1] +
390                                          len[2]*len[2] + 4*len[1]*len[2])
391                                  + len[1]*len[1]*len[2]*(len[2] + 4*len[0])
392                                  + 4*len[0]*len[1]*len[2]*len[2] );
# Line 420 | Line 439 | HDGRID *gp;
439   }
440  
441  
442 + int
443   headline(s)                     /* process information header line */
444   char    *s;
445   {
# Line 433 | Line 453 | char   *s;
453                                          HOLOFMT, hdkfile, FMTSTR, fmt);
454                          error(USER, errmsg);
455                  }
456 <                return;
456 >                return(0);
457          }
458          for (cp = s; *cp; cp++)         /* take off any comments */
459                  if (*cp == '#') {
# Line 441 | Line 461 | char   *s;
461                          break;
462                  }
463          setvariable(s, matchvar);       /* don't flag errors */
464 +        return(0);
465   }
466  
467  
# Line 495 | Line 516 | PACKET *pl;
516                                  p->nr*sizeof(RAYVAL));
517                          if (outdev != NULL)     /* display it */
518                                  disp_packet((PACKHEAD *)p);
519 <                        if (hdcachesize <= 0)   /* manual flushing */
519 >                        if (hdcachesize <= 0) {
520 > #if RTFLUSH
521 >                                if (outdev == NULL)
522 >                                        hdfreebeam(hdlist[p->hd], p->bi);
523 > #endif
524                                  n2flush++;
525 +                        }
526                          nraysdone += p->nr;
527                          npacksdone++;
528                          p->nr = 0;
# Line 504 | Line 530 | PACKET *pl;
530                  p->next = freepacks;            /* push onto free list */
531                  freepacks = p;
532          }
533 + #if MAXQTIME
534          if (n2flush > 300/MAXQTIME*totqlen) {
535 <                hdflush(NULL);                  /* flush holodeck buffers */
535 > #else
536 >        if (n2flush > 50*totqlen) {
537 > #endif
538 > #if RTFLUSH
539 >                hdsync(NULL, outdev!=NULL);     /* sync beams & directories */
540 > #else
541 >                if (outdev != NULL)
542 >                        hdsync(NULL, 1);
543 >                else
544 >                        hdflush(NULL);
545 > #endif
546                  n2flush = 0;
547          }
548   }
# Line 550 | Line 587 | register char  *s;
587                  fflush(stderr);
588                  midline = 0;
589          }
553 }
554
555
556 wputs(s)                        /* put warning string to stderr */
557 char    *s;
558 {
559        if (!nowarn)
560                eputs(s);
590   }
591  
592  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines