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

Comparing ray/src/util/rad.c (file contents):
Revision 2.93 by greg, Tue May 18 00:01:02 2010 UTC vs.
Revision 2.101 by greg, Sat Oct 9 17:14:01 2010 UTC

# Line 165 | Line 165 | static int touch(char  *fn);
165   static int runcom(char  *cs);
166   static int rmfile(char  *fn);
167   static int mvfile(char  *fold, char     *fnew);
168 < static int next_process(void);
168 > static int next_process(int     reserve);
169   static void wait_process(int    all);
170   static void finish_process(void);
171   static void badvalue(int        vc);
# Line 751 | Line 751 | lowqopts(                      /* low quality rendering options */
751                  op = addarg(op, "-ds .4");
752          else
753                  op = addarg(op, "-ds 0");
754 <        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5");
754 >        op = addarg(op, "-dt .2 -dc .25 -dr 0 -ss 0 -st .5");
755          if (vdef(AMBFILE)) {
756                  sprintf(op, " -af %s", vval(AMBFILE));
757                  op += strlen(op);
# Line 826 | Line 826 | medqopts(                      /* medium quality rendering options */
826                  op = addarg(op, "-ds .2 -dj .9");
827          else
828                  op = addarg(op, "-ds .3");
829 <        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1");
829 >        op = addarg(op, "-dt .1 -dc .5 -dr 1 -ss 1 -st .1");
830          if ( (overture = vint(INDIRECT)) ) {
831                  sprintf(op, " -ab %d", overture);
832                  op += strlen(op);
# Line 904 | Line 904 | hiqopts(                               /* high quality rendering options */
904                  op = addarg(op, "-ds .1 -dj .9");
905          else
906                  op = addarg(op, "-ds .2");
907 <        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01");
907 >        op = addarg(op, "-dt .05 -dc .75 -dr 3 -ss 16 -st .01");
908          sprintf(op, " -ab %d", overture=vint(INDIRECT)+1);
909          op += strlen(op);
910          if (vdef(AMBFILE)) {
# Line 1316 | Line 1316 | rpict(                         /* run rpict and pfilt for each view */
1316                                          getview(0, vs) != NULL) {
1317                  if (!strcmp(c_rpict, DEF_RPICT_PATH) &&
1318                                  getview(1, NULL) == NULL) {
1319 <                        sprintf(sfile, "rpiece_%s.txt", vs);
1319 >                        sprintf(sfile, "rpsync_%s.txt", vs);
1320                          strcpy(rppopt, "-PP pfXXXXXX");
1321                  } else {
1322                          strcpy(rppopt, "-S 1 -PP pfXXXXXX");
1323                  }
1324                  pfile = rppopt + strlen(rppopt) - 8;
1325 <                if (mktemp(pfile) == NULL)
1325 >                if (mktemp(pfile) == NULL) {
1326                          if (do_rpiece) {
1327                                  fprintf(stderr, "%s: cannot create\n", pfile);
1328                                  quit(1);
1329 <                        } else
1330 <                                pfile = NULL;
1329 >                        }
1330 >                        pfile = NULL;
1331 >                }
1332          }
1333          vn = 0;                                 /* do each view */
1334          while ((vw = getview(vn++, vs)) != NULL) {
# Line 1356 | Line 1357 | rpict(                         /* run rpict and pfilt for each view */
1357                  }
1358                                                  /* parallel running? */
1359                  if (do_rpiece) {
1360 <                        if (rfdt < oct1date || fdate(sfile) < oct1date) {
1360 >                        if (rfdt < oct1date || !fdate(sfile)) {
1361 >                                int     xdiv = 8+nprocs/3, ydiv = 8+nprocs/3;
1362                                  rfdt = 0;               /* start fresh */
1363 +                                if (!silent)
1364 +                                        printf("\techo %d %d > %s\n",
1365 +                                                        xdiv, ydiv, sfile);
1366                                  if ((fp = fopen(sfile, "w")) == NULL) {
1367                                          fprintf(stderr, "%s: cannot create\n",
1368                                                          sfile);
1369                                          quit(1);
1370                                  }
1371 <                                fprintf(fp, "%d %d\n", 8+nprocs/3, 8+nprocs/3);
1371 >                                fprintf(fp, "%d %d\n", xdiv, ydiv);
1372                                  fclose(fp);
1373                          }
1374 <                } else if (next_process()) {
1374 >                } else if (next_process(0)) {
1375                          if (pfile != NULL)
1376                                  sleep(10);
1377                          continue;
# Line 1379 | Line 1384 | rpict(                         /* run rpict and pfilt for each view */
1384                                  sprintf(combuf, "%s -R %s %s%s %s %s%s%s -o %s %s",
1385                                                  c_rpiece, sfile, rppopt, rep, vw,
1386                                                  res, opts, po, rawfile, oct1name);
1387 <                                while (children_running < nprocs-1 &&
1383 <                                                        next_process()) {
1387 >                                while (next_process(1)) {
1388                                          sleep(10);
1389                                          combuf[strlen(c_rpiece)+2] = 'F';
1390                                  }
# Line 1392 | Line 1396 | rpict(                         /* run rpict and pfilt for each view */
1396                  } else {
1397                          if (overture) {         /* run overture calculation */
1398                                  sprintf(combuf,
1399 <                                "%s%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1399 >                                        "%s%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1400                                                  c_rpict, rep, vw, opts,
1401                                                  oct1name, overfile);
1402 <                                if (runcom(combuf)) {
1403 <                                        fprintf(stderr,
1402 >                                if (!do_rpiece || !next_process(0)) {
1403 >                                        if (runcom(combuf)) {
1404 >                                                fprintf(stderr,
1405                                          "%s: error in overture for view %s\n",
1406 <                                                progname, vs);
1407 <                                        quit(1);
1408 <                                }
1406 >                                                        progname, vs);
1407 >                                                quit(1);
1408 >                                        }
1409   #ifndef NULL_DEVICE
1410 <                                rmfile(overfile);
1410 >                                        rmfile(overfile);
1411   #endif
1412 +                                } else if (do_rpiece)
1413 +                                        sleep(20);
1414                          }
1415                          if (do_rpiece) {
1416                                  sprintf(combuf, "%s -F %s %s%s %s %s%s%s -o %s %s",
1417                                                  c_rpiece, sfile, rppopt, rep, vw,
1418                                                  res, opts, po, rawfile, oct1name);
1419 <                                while (children_running < nprocs-1 &&
1413 <                                                        next_process())
1419 >                                while (next_process(1))
1420                                          sleep(10);
1421                          } else {
1422                                  sprintf(combuf, "%s%s %s %s%s%s%s %s > %s",
# Line 1467 | Line 1473 | rpict(                         /* run rpict and pfilt for each view */
1473                          finish_process();       /* exit if child */
1474          }
1475          wait_process(1);                /* wait for children to finish */
1476 <        if (pfile != NULL) {            /* clean up rpict persistent mode */
1476 >        if (pfile != NULL) {            /* clean up persistent rpict */
1477                  RT_PID  pid;
1478                  fp = fopen(pfile, "r");
1479                  if (fp != NULL) {
# Line 1494 | Line 1500 | touch(                 /* update a file */
1500                  printf("\ttouch %s\n", fn);
1501          if (!nprocs)
1502                  return(0);
1497 #ifdef notused
1498        if (access(fn, F_OK) == -1)             /* create it */
1499                if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1)
1500                        return(-1);
1501 #endif
1503          return(setfdate(fn, time((time_t *)NULL)));
1504   }
1505  
# Line 1546 | Line 1547 | mvfile(                /* move a file */
1547  
1548   #ifdef RHAS_FORK_EXEC
1549   static int
1550 < next_process(void)                      /* fork the next process (max. nprocs) */
1550 > next_process(int reserve)               /* fork the next process */
1551   {
1552          RT_PID  child_pid;
1553  
# Line 1557 | Line 1558 | next_process(void)                     /* fork the next process (max. np
1558                                  progname);
1559                  quit(1);
1560          }
1561 +        if (reserve > 0 && children_running >= nprocs-reserve)
1562 +                return(0);              /* caller holding back process(es) */
1563          if (children_running >= nprocs)
1564                  wait_process(0);        /* wait for someone to finish */
1565          fflush(NULL);                   /* flush output */
1566          child_pid = fork();             /* split process */
1567          if (child_pid == 0) {           /* we're the child */
1568                  children_running = -1;
1569 +                nprocs = 1;
1570                  return(0);
1571          }
1572          if (child_pid > 0) {            /* we're the parent */
# Line 1604 | Line 1608 | wait_process(                  /* wait for process(es) to finish */
1608   }
1609   #else   /* ! RHAS_FORK_EXEC */
1610   static int
1611 < next_process(void)
1611 > next_process(int reserve)
1612   {
1613          return(0);                      /* cannot start new process */
1614   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines